Chain¶
- class psynet.trial.chain.ChainNetwork(*args, **kwargs)¶
Bases:
TrialNetwork
Implements a network in the form of a chain. Intended for use with
ChainTrialMaker
. Typically the user won’t have to override anything here, but they can optionally overridevalidate()
.- Parameters:
experiment – An instantiation of
psynet.experiment.Experiment
, corresponding to the current experiment.chain_type – Either
"within"
for within-participant chains, or"across"
for across-participant chains.trials_per_node – Number of satisfactory trials to be received by the last node in the chain before another chain will be added. Most paradigms have this equal to 1.
target_n_nodes – Indicates the target number of nodes for that network. In a network with one trial per node, the total number of nodes will generally be one greater than the total number of trials. This is because we start with one node, representing the random starting location of the chain, and each new trial takes us to a new node.
participant – Optional participant with which to associate the network.
id_within_participant – If
participant is not None
, then this provides an optional ID for the network that is unique within a given participant.sync_group_type (Optional[str]) – The
sync_group_type
attribute of the trial maker that owns this network.sync_group (Optional[SyncGroup]) – The SyncGroup that owns this network (normally only relevant for within-style chains).
- target_n_trials¶
Indicates the target number of trials for that network. Left empty by default, but can be set by custom
__init__
functions.- Type:
int or None
- earliest_async_process_start_time¶
Time at which the earliest pending async process was called.
- Type:
Optional[datetime]
- n_alive_nodes¶
Returns the number of non-failed nodes in the network.
- Type:
int
- n_completed_trials¶
Returns the number of completed and non-failed trials in the network (irrespective of asynchronous processes, but excluding repeat trials).
- Type:
int
- participant_id¶
The ID of the associated participant, or
None
if there is no such participant. Set by default in the__init__
function.- Type:
int
- id_within_participant¶
If
participant is not None
, then this provides an optional ID for the network that is unique within a given participant. Set by default in the__init__
function.
- chain_type¶
Either
"within"
for within-participant chains, or"across"
for across-participant chains. Set by default in the__init__
function.
- trials_per_node¶
Number of satisfactory trials to be received by the last node in the chain before another chain will be added. Most paradigms have this equal to 1. Set by default in the
__init__
function.
- add_node(node)¶
Adds a node to the network. This method is responsible for setting
self.full = True
if the network is full as a result.
- balance_across_networks(values)¶
Chooses a value from a list, with choices being balanced across networks. Relies on the fact that network IDs are guaranteed to be consecutive. sequences of integers.
Suppose we wish to assign our networks to colors, and we want to balance color assignment across networks. We might write the following:
colors = ["red", "green", "blue"] chosen_color = self.balance_across_networks(colors)
In across-participant chain designs,
balance_across_networks()
will ensure that the distribution of colors is maximally uniform across the experiment by assigning the first network to red, the second network to green, the third to blue, then the fourth to red, the fifth to green, the sixth to blue, and so on. This is achieved by referring to the network’sid
attribute. In within-participant chain designs, the same method is used but within participants, so that each participant’s first network is assigned to red, their second network to green, their third to blue, then their fourth, fifth, and sixth to red, green, and blue respectively.- Parameters:
values (
list
) – The list of values from which to choose.- Returns:
Object – An object from the provided list.
- creation_time¶
the time at which the Network was created.
- details¶
a generic column for storing structured JSON data
- failed¶
boolean indicating whether the Network has failed which prompts Dallinger to ignore it unless specified otherwise. Objects are usually failed to indicate something has gone wrong.
- failed_reason¶
an optional reason the object was failed. If the object is failed as part of a cascading failure triggered from another object, the chain of objects will be captured in this field.
- full¶
Whether the network is currently full
- id¶
a unique number for every entry. 1, 2, 3 and so on…
- make_definition()¶
Derives the definition for the network. This definition represents some collection of attributes that is shared by all nodes/trials in a network, but that may differ between networks.
Suppose one wishes to have multiple networks in the experiment, each characterised by a different value of an attribute (e.g. a different color). One approach would be to sample randomly; however, this would not guarantee an even distribution of attribute values. In this case, a better approach is to use the
psynet.trial.chain.ChainNetwork.balance_across_networks()
method, as follows:colors = ["red", "green", "blue"] return { "color": self.balance_across_networks(colors) }
See
psynet.trial.chain.ChainNetwork.balance_across_networks()
for details on how this balancing works.- Returns:
object – By default this returns an empty dictionary, but this can be customised by subclasses. The object should be suitable for serialisation to JSON.
- max_size¶
How big the network can get, this number is used by the full() method to decide whether the network is full
- property1¶
a generic column that can be used to store experiment-specific details in String form.
- property2¶
a generic column that can be used to store experiment-specific details in String form.
- property3¶
a generic column that can be used to store experiment-specific details in String form.
- property4¶
a generic column that can be used to store experiment-specific details in String form.
- property5¶
a generic column that can be used to store experiment-specific details in String form.
- role¶
The role of the network. By default dallinger initializes all networks as either “practice” or “experiment”
- time_of_death¶
the time at which failing occurred
- type¶
A String giving the name of the class. Defaults to “network”. This allows subclassing.
- validate()¶
Runs at the end of the constructor function to check that the network object has a legal structure. This can be useful for checking that the user hasn’t passed illegal argument values.
- vars¶
- class psynet.trial.chain.ChainNode(*args, **kwargs)¶
Bases:
TrialNode
Represents a node in a chain network. In an experimental context, the node represents a state in the experiment; in particular, the last node in the chain represents a current state in the experiment.
This class is intended for use with
ChainTrialMaker
. It subclassesdallinger.models.Node
.The most important attribute is
definition
. This is the core information that represents the current state of the node. In a transmission chain of drawings, this might be an (encoded) drawing; in a Markov Chain Monte Carlo with People paradigm, this might be the current state from the proposal is sampled.The user is required to override the following abstract methods:
create_definition_from_seed()
, which creates a node definition from the seed passed from the previous source or node in the chain;summarize_trials()
, which summarizes the trials at a given node to produce a seed that can be passed to the next node in the chain.
- Parameters:
seed – The seed which is used to initialize the node, potentially stochastically. This seed typically comes from either a
ChainSource
or from anotherChainNode
via thecreate_seed()
method. For example, in a transmission chain of drawings, the seed might be a serialised version of the last drawn image.degree – The position of the node in the chain, where 0 indicates the source, where 1 indicates the first node, 2 the second node, and so on.
network – The network with which the node is to be associated.
experiment – An instantiation of
psynet.experiment.Experiment
, corresponding to the current experiment.propagate_failure – If
True
, the failure of a trial is propagated to other parts of the experiment (the nature of this propagation is left up to the implementation).participant – Optional participant with which to associate the node.
- degree¶
See the
__init__
function.
- child_id¶
See the
__init__
function.
- seed¶
See the
__init__
function.
- definition¶
This is the core information that represents the current state of the node. In a transmission chain of drawings, this might be an (encoded) drawing; in a Markov Chain Monte Carlo with People paradigm, this might be the current state from the proposal is sampled. It is set by the
ChainNode:create_definition_from_seed()
method.
- propagate_failure¶
See the
__init__
function.
- child¶
The node’s child (i.e. direct descendant) in the chain, or
None
if no child exists.
- target_n_trials¶
The target number of trials for the node, set from
psynet.trial.chain.ChainNetwork.trials_per_node
.
- ready_to_spawn¶
Returns
True
if the node is ready to spawn a child. Not intended for overriding.
- complete_and_processed_trials¶
Returns all completed trials associated with the node, excluding those that are awaiting some asynchronous processing. excludes failed nodes.
- completed_trials¶
Returns all completed trials associated with the node. Excludes failed nodes and repeat trials.
- n_completed_trials¶
Counts the number of completed trials associated with the node. Excludes failed nodes and repeat_trials.
- all_trials¶
A list of all trials owned by that node.
- Type:
list
- alive_trials¶
A list of all non-failed trials owned by that node.
- Type:
list
- failed_trials¶
A list of all failed trials owned by that node.
- Type:
list
- viable_trials¶
Returns all viable trials associated with the node, i.e. all trials that have not failed.
- create_definition_from_seed(seed, experiment, participant)¶
Creates a node definition from a seed. The seed comes from the previous node in the chain. In many cases (e.g. iterated reproduction) the definition will be trivially equal to the seed, but in some cases we may introduce some kind of stochastic alteration to produce the definition.
- Parameters:
seed (object) – The seed, passed from the previous state in the chain.
experiment – An instantiation of
psynet.experiment.Experiment
, corresponding to the current experiment.participant – The participant who initiated the creation of the node.
- Returns:
object – The derived definition. Should be suitable for serialisation to JSON.
- creation_time¶
the time at which the Network was created.
- details¶
a generic column for storing structured JSON data
- fail(reason=None)¶
Fail this object, and potentially its related objects.
Set
failed
toTrue
andtime_of_death
to now.If a reason argument is passed, this will be stored in
failed_reason
.Failure will then be propagated to related objects as defined by the failure_cascade property.
- failed¶
boolean indicating whether the Network has failed which prompts Dallinger to ignore it unless specified otherwise. Objects are usually failed to indicate something has gone wrong.
- failed_reason¶
an optional reason the object was failed. If the object is failed as part of a cascading failure triggered from another object, the chain of objects will be captured in this field.
- property failure_cascade¶
When we fail, also fails all vectors that connect to or from the node. You cannot fail a node that has already failed, but you can fail a dead node.
Instruct all not-failed vectors connected to this node, infos made by this node, transmissions to or from this node and transformations made by this node to fail.
- id¶
a unique number for every entry. 1, 2, 3 and so on…
- network¶
the network the node is in
- network_id¶
the id of the network that this node is a part of
- participant¶
the participant the node is associated with
- participant_id¶
the id of the participant whose node this is
- property1¶
a generic column that can be used to store experiment-specific details in String form.
- property2¶
a generic column that can be used to store experiment-specific details in String form.
- property3¶
a generic column that can be used to store experiment-specific details in String form.
- property4¶
a generic column that can be used to store experiment-specific details in String form.
- property5¶
a generic column that can be used to store experiment-specific details in String form.
- summarize_trials(trials, experiment, participant)¶
Summarizes the trials at the node to produce a seed that can be passed to the next node in the chain.
- Parameters:
trials (
list
) – Trials to be summarized. By default only trials that are completed (i.e. have received a response) and processed (i.e. aren’t waiting for an asynchronous process) are provided here.experiment – An instantiation of
psynet.experiment.Experiment
, corresponding to the current experiment.participant – The participant who initiated the creation of the node.
- Returns:
object – The derived seed. Should be suitable for serialisation to JSON.
- time_of_death¶
the time at which failing occurred
- type¶
A String giving the name of the class. Defaults to
node
. This allows subclassing.
- vars¶
- class psynet.trial.chain.ChainTrial(*args, **kwargs)¶
Bases:
Trial
Represents a trial in a
ChainNetwork
. The user is expected to override the following methods:make_definition()
, responsible for deciding on the content of the trial.show_trial()
, determines how the trial is turned into a webpage for presentation to the participant.show_feedback()
. defines an optional feedback page to be displayed after the trial.
The user must also override the
time_estimate
class attribute, providing the estimated duration of the trial in seconds. This is used for predicting the participant’s reward and for constructing the progress bar.The user may also wish to override the
async_post_trial()
method if they wish to implement asynchronous trial processing.This class subclasses the ~psynet.trial.main.Trial class, which in turn subclasses the
Info
class from Dallinger, hence it can be found in theInfo
table in the database. It inherits these class’s methods, which the user is welcome to use if they seem relevant.Instances can be retrieved using SQLAlchemy; for example, the following command retrieves the
ChainTrial
object with an ID of 1:ChainTrial.query.filter_by(id=1).one()
- Parameters:
experiment – An instantiation of
psynet.experiment.Experiment
, corresponding to the current experiment.node – An object of class
dallinger.models.Node
to which theTrial
object should be attached. Complex experiments are often organised around networks of nodes, but in the simplest case one could just make oneNetwork
for each type of trial and oneNode
for each participant, and then assign theTrial
to thisNode
. Ask us if you want to use this simple use case - it would be worth adding it as a default to this implementation, but we haven’t done that yet, because most people are using more complex designs.participant – An instantiation of
psynet.participant.Participant
, corresponding to the current participant.propagate_failure (bool) – Whether failure of a trial should be propagated to other parts of the experiment depending on that trial (for example, subsequent parts of a transmission chain).
run_async_post_trial (bool) – Set this to
True
if you want theasync_post_trial()
method to run after the user responds to the trial.
- time_estimate¶
The estimated duration of the trial (including any feedback), in seconds. This should generally correspond to the (sum of the)
time_estimate
parameters in the page(s) generated byshow_trial
, plus thetime_estimate
parameter in the page generated byshow_feedback
(if defined). This is used for predicting the participant’s reward and for constructing the progress bar.- Type:
numeric
- node¶
The class:dallinger.models.Node to which the
Trial
belongs.
- participant_id¶
The ID of the associated participant. The user should not typically change this directly. Stored in
property1
in the database.- Type:
int
- complete¶
Whether the trial has been completed (i.e. received a response from the participant). The user should not typically change this directly. Stored in
property2
in the database.- Type:
bool
- answer¶
The response returned by the participant. This is serialised to JSON, so it shouldn’t be too big. The user should not typically change this directly. Stored in
details
in the database.- Type:
Object
- earliest_async_process_start_time¶
Time at which the earliest pending async process was called.
- Type:
Optional[datetime]
- propagate_failure¶
Whether failure of a trial should be propagated to other parts of the experiment depending on that trial (for example, subsequent parts of a transmission chain).
- Type:
bool
- definition¶
An arbitrary Python object that somehow defines the content of a trial. Often this will be a dictionary comprising a few named parameters. The user should not typically change this directly, as it is instead determined by
make_definition()
.- Type:
Object
- complete¶
whether the info is ‘complete’, i.e. has received its contents
- creation_time¶
the time at which the Network was created.
- details¶
a generic column for storing structured JSON data
- fail(reason=None)¶
Fail this object, and potentially its related objects.
Set
failed
toTrue
andtime_of_death
to now.If a reason argument is passed, this will be stored in
failed_reason
.Failure will then be propagated to related objects as defined by the failure_cascade property.
- failed¶
boolean indicating whether the Network has failed which prompts Dallinger to ignore it unless specified otherwise. Objects are usually failed to indicate something has gone wrong.
- failed_reason¶
an optional reason the object was failed. If the object is failed as part of a cascading failure triggered from another object, the chain of objects will be captured in this field.
- property failure_cascade¶
When we fail, propagate the failure to our related Transmissions and Transformations.
- id¶
a unique number for every entry. 1, 2, 3 and so on…
- network¶
the network the info is in
- network_id¶
the id of the network the info is in
- origin¶
the Node that created the info.
- origin_id¶
the id of the Node that created the info
- property1¶
a generic column that can be used to store experiment-specific details in String form.
- property2¶
a generic column that can be used to store experiment-specific details in String form.
- property3¶
a generic column that can be used to store experiment-specific details in String form.
- property4¶
a generic column that can be used to store experiment-specific details in String form.
- property5¶
a generic column that can be used to store experiment-specific details in String form.
- time_of_death¶
the time at which failing occurred
- type¶
a String giving the name of the class. Defaults to “info”. This allows subclassing.
- vars¶
- class psynet.trial.chain.ChainTrialMaker(*, id_, trial_class, node_class, network_class=None, chain_type, expected_trials_per_participant, max_trials_per_participant=<class 'psynet.utils.NoArgumentProvided'>, max_trials_per_block=None, max_nodes_per_chain=None, chains_per_participant=None, chains_per_experiment=None, trials_per_node=1, n_repeat_trials=0, target_n_participants=None, balance_across_chains=False, start_nodes=None, check_performance_at_end=False, check_performance_every_trial=False, recruit_mode='n_participants', fail_trials_on_premature_exit=False, fail_trials_on_participant_performance_check=False, propagate_failure=True, wait_for_networks=False, allow_revisiting_networks_in_across_chains=False, assets=None, choose_participant_group=None, sync_group_type=None, sync_group_max_wait_time=45.0)¶
Bases:
NetworkTrialMaker
Administers a sequence of trials in a chain-based paradigm. This trial maker is suitable for implementing paradigms such as Markov Chain Monte Carlo with People, iterated reproduction, and so on. It is intended for use with the following helper classes, which should be customised for the particular paradigm:
ChainNetwork
; a special type ofTrialNetwork
ChainNode
; a special type ofNode
ChainTrial
; a special type ofNetworkTrial
A chain is initialized with a
ChainSource
object. ThisChainSource
object provides the initial seed to the chain. TheChainSource
object is followed by a series ofChainNode
objects which are generated through the course of the experiment. The lastChainNode
in the chain represents the current state of the chain, and it determines the properties of the next trials to be drawn from that chain. A newChainNode
object is generated once sufficientChainTrial
objects have been created for thatChainNode
. There can be multiple chains in an experiment, with these chains either being owned by individual participants (“within-participant” designs) or shared across participants (“across-participant” designs).- Parameters:
network_class (
Type
[ChainNetwork
]) – The class object for the networks used by this maker. This should subclassChainNetwork
.node_class (
Type
[ChainNode
]) – The class object for the networks used by this maker. This should subclassChainNode
.trial_class (
Type
[ChainTrial
]) – The class object for trials administered by this maker (should subclassChainTrial
).chain_type (
str
) – Either"within"
for within-participant chains, or"across"
for across-participant chains.expected_trials_per_participant (
int
) – Expected number of trials that each participant will complete. This is used for timeline/progress estimation purposes.max_trials_per_participant (
Optional
[int
]) – Maximum number of trials that each participant may complete; once this number is reached, the participant will move on to the next stage in the timeline.chains_per_participant (
Optional
[int
]) – Number of chains to be created for each participant; only relevant ifchain_type="within"
.chains_per_experiment (
Optional
[int
]) – Number of chains to be created for the entire experiment; only relevant ifchain_type="across"
.max_nodes_per_chain (
Optional
[int
]) – Specifies chain length in terms of the number of data-collection iterations that are required to complete a chain. The number of successful participant trials required to complete the chain then corresponds totrials_per_node * max_nodes_per_chain
.max_nodes_per_chain – Maximum number of nodes in the chain before the chain is marked as full and no more nodes will be added.
trials_per_node (
int
) – Number of satisfactory trials to be received by the last node in the chain before another chain will be added. Most paradigms have this equal to 1.balance_across_chains (
bool
) – Whether trial selection should be actively balanced across chains, such that trials are preferentially sourced from chains with fewer valid trials.start_nodes (
Union
[callable
,List
[ChainNode
],None
]) – A list of nodes that are used to initialize the chains. In an across-participant trial maker, this should be a simple list of instances of the classnode_class
. In a within-participant trial maker, a fresh set of nodes should be created for each new participant. To achieve this,start_nodes
should be a lambda function that returns a list of newly created nodes. This lambda function may acceptparticipant
as one of its arguments.balance_strategy (#) – # A two-element list that determines how balancing occurs, if
balance_across_chains
isTrue
. # If the list contains “across”, then the balancing will take into account trials from other participants. # If it contains “within”, then the balancing will take into account trials from the present participant. # If both are selected, then the balancing strategy will prioritize balancing within the current participant, # but will use counts from other participants as a tie breaker.check_performance_at_end (
bool
) – IfTrue
, the participant’s performance is evaluated at the end of the series of trials.check_performance_every_trial (
bool
) – IfTrue
, the participant’s performance is evaluated after each trial.recruit_mode (
str
) – Selects a recruitment criterion for determining whether to recruit another participant. The built-in criteria are"n_participants"
and"n_trials"
, though the latter requires overriding ofn_trials_still_required
.target_n_participants (
Optional
[int
]) – Target number of participants to recruit for the experiment. All participants must successfully finish the experiment to count towards this quota. This target is only relevant ifrecruit_mode="n_participants"
.fail_trials_on_premature_exit (
bool
) – IfTrue
, a participant’s trials are marked as failed if they leave the experiment prematurely. Defaults toFalse
because failing such trials can end up destroying large parts of existing chains.fail_trials_on_participant_performance_check (
bool
) – IfTrue
, a participant’s trials are marked as failed if the participant fails a performance check. Defaults toFalse
because failing such trials can end up destroying large parts of existing chains.propagate_failure (
bool
) – IfTrue
, the failure of a trial is propagated to other parts of the experiment (the nature of this propagation is left up to the implementation).n_repeat_trials (
int
) – Number of repeat trials to present to the participant. These trials are typically used to estimate the reliability of the participant’s responses. Defaults to0
.wait_for_networks (
bool
) – IfTrue
, then the participant will be made to wait if there are still more networks to participate in, but these networks are pending asynchronous processes.allow_revisiting_networks_in_across_chains (bool) – If this is set to
True
, then participants can revisit the same network in across-participant chains. The default isFalse
.choose_participant_group (
Optional
[callable
]) – Only relevant if the trial maker uses nodes with non-default participant groups. In this case the experimenter is expected to supply a function that takes participant as an argument and returns the chosen participant group for that trial maker.sync_group_type (
Optional
[str
]) – Optional SyncGroup type to use for synchronizing participant allocation to nodes. When this is set, then the ordinary node allocation logic will only apply to the ‘leader’ of each SyncGroup. The other members of this SyncGroup will follow that leader around, so that in every given trial the SyncGroup works on the same node together.sync_group_max_wait_time (
float
) – The maximum time that the participant will be allowed to wait for the SyncGroup to be ready. If this time is exceeded then the participant will be failed and the experiment will terminate early. Defaults to 45.0 seconds.
- check_timeout_interval_sec¶
How often to check for trials that have timed out, in seconds (default = 30). Users are invited to override this.
- Type:
float
- response_timeout_sec¶
How long until a trial’s response times out, in seconds (default = 60) (i.e. how long PsyNet will wait for the participant’s response to a trial). This is a lower bound on the actual timeout time, which depends on when the timeout daemon next runs, which in turn depends on
check_timeout_interval_sec
. Users are invited to override this.- Type:
float
- async_timeout_sec¶
How long until an async process times out, in seconds (default = 300). This is a lower bound on the actual timeout time, which depends on when the timeout daemon next runs, which in turn depends on
check_timeout_interval_sec
. Users are invited to override this.- Type:
float
- network_query¶
An SQLAlchemy query for retrieving all networks owned by the current trial maker. Can be used for operations such as the following:
self.network_query.count()
.- Type:
sqlalchemy.orm.Query
- n_networks¶
Returns the number of networks owned by the trial maker.
- Type:
int
- networks¶
Returns the networks owned by the trial maker.
- Type:
list
- performance_threshold¶
Score threshold used by the default performance check method, defaults to 0.0. By default, corresponds to the minimum proportion of non-failed trials that the participant must achieve to pass the performance check.
- Type:
float
- end_performance_check_waits¶
If
True
(default), then the final performance check waits until all trials no longer have any pending asynchronous processes.- Type:
bool
- choose_block_order(experiment, participant, blocks)¶
Determines the order of blocks for the current participant. By default this function shuffles the blocks randomly for each participant. The user is invited to override this function for alternative behaviour.
- Parameters:
experiment – An instantiation of
psynet.experiment.Experiment
, corresponding to the current experiment.participant – An instantiation of
psynet.participant.Participant
, corresponding to the current participant.
- Returns:
list – A list of blocks in order of presentation, where each block is identified by a string label.
- custom_network_filter(candidates, participant)¶
Override this function to define a custom filter for choosing the participant’s next network.
- Parameters:
candidates – The current list of candidate networks as defined by the built-in chain procedure.
participant – The current participant.
- Returns:
An updated list of candidate networks. The default implementation simply returns the original list.
The experimenter might alter this function to remove certain networks from the list.
- finalize_trial(answer, trial, experiment, participant)¶
This function is run after the participant completes the trial. It can be optionally customised, for example to add some more postprocessing. If you override this, make sure you call
super().finalize_trial(...)
somewhere in your new method.- Parameters:
answer – The
answer
object provided by the trial.trial – The
Trial
object representing the trial.experiment – An instantiation of
psynet.experiment.Experiment
, corresponding to the current experiment.participant – An instantiation of
psynet.participant.Participant
, corresponding to the current participant.
- find_networks(participant, experiment)¶
- Parameters:
participant
experiment
- Returns:
Either “exit”, “wait”, or a list of networks.
- find_node(network, participant, experiment)¶
Finds the node to which the participant should be attached for the next trial.
- Parameters:
network – The network to be potentially extended.
participant – An instantiation of
psynet.participant.Participant
, corresponding to the current participant.experiment – An instantiation of
psynet.experiment.Experiment
, corresponding to the current experiment.
- grow_network(network, experiment)¶
Extends the network if necessary by adding one or more nodes. Returns
True
if any nodes were added.- Parameters:
network – The network to be potentially extended.
experiment – An instantiation of
psynet.experiment.Experiment
, corresponding to the current experiment.
- init_participant(experiment, participant)¶
Initializes the participant at the beginning of the sequence of trials. If you override this, make sure you call
super().init_particiant(...)
somewhere in your new method.- Parameters:
experiment – An instantiation of
psynet.experiment.Experiment
, corresponding to the current experiment.participant – An instantiation of
psynet.participant.Participant
, corresponding to the current participant.
- pre_deploy_routine(experiment)¶
Defines a routine for setting up the experiment prior to deployment. This is a good place to prepare networks etc.
- Parameters:
experiment – An instantiation of
psynet.experiment.Experiment
, corresponding to the current experiment.
- state_class¶
alias of
ChainTrialMakerState
- class psynet.trial.chain.ChainTrialMakerState(*args, **kwargs)¶
Bases:
NetworkTrialMakerState
- creation_time¶
the time at which the Network was created.
- details¶
a generic column for storing structured JSON data
- failed¶
boolean indicating whether the Network has failed which prompts Dallinger to ignore it unless specified otherwise. Objects are usually failed to indicate something has gone wrong.
- failed_reason¶
an optional reason the object was failed. If the object is failed as part of a cascading failure triggered from another object, the chain of objects will be captured in this field.
- id¶
a unique number for every entry. 1, 2, 3 and so on…
- property1¶
a generic column that can be used to store experiment-specific details in String form.
- property2¶
a generic column that can be used to store experiment-specific details in String form.
- property3¶
a generic column that can be used to store experiment-specific details in String form.
- property4¶
a generic column that can be used to store experiment-specific details in String form.
- property5¶
a generic column that can be used to store experiment-specific details in String form.
- time_of_death¶
the time at which failing occurred
- type¶
- vars¶
- class psynet.trial.chain.ChainVector(*args, **kwargs)¶
Bases:
SQLMixinDallinger
,Vector
- creation_time¶
the time at which the Network was created.
- destination¶
the Node at which the vector terminates.
- destination_id¶
the id of the Node at which the vector terminates.
- details¶
a generic column for storing structured JSON data
- failed¶
boolean indicating whether the Network has failed which prompts Dallinger to ignore it unless specified otherwise. Objects are usually failed to indicate something has gone wrong.
- failed_reason¶
an optional reason the object was failed. If the object is failed as part of a cascading failure triggered from another object, the chain of objects will be captured in this field.
- id¶
a unique number for every entry. 1, 2, 3 and so on…
- network¶
the network the vector is in.
- network_id¶
the id of the network the vector is in.
- origin¶
the Node at which the vector originates.
- origin_id¶
the id of the Node at which the vector originates
- property1¶
a generic column that can be used to store experiment-specific details in String form.
- property2¶
a generic column that can be used to store experiment-specific details in String form.
- property3¶
a generic column that can be used to store experiment-specific details in String form.
- property4¶
a generic column that can be used to store experiment-specific details in String form.
- property5¶
a generic column that can be used to store experiment-specific details in String form.
- time_of_death¶
the time at which failing occurred
- type¶
A String giving the name of the class. Defaults to
vector
. This allows subclassing.Note: The type column was added in 9/2022, 7+ years after the Vector ORM class was introduced. To support importing datasets which don’t include this column we define a default value which will be used when deploying experiments from zip files.
- vars¶