Graph
*****

class psynet.trial.graph.GraphChainEdge(*args, **kwargs)

   Bases: "Base", "SQLMixin"

   Stores directed dependencies between graph-chain vertices.

   A target vertex can grow at a given degree only once each origin
   vertex for its incoming edges has a ready head node at the same
   degree.

   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.graph.GraphChainNetwork(*args, **kwargs)

   Bases: "ChainNetwork"

   A Network class for graph chains. A graph chain corresponds to the
   evolution of a vertex within a graph.


   Parameters (for now stating the new ones)
   =========================================

   vertex_id
      The id of the vertex that the network is representing within the
      graph.

   source_seed
      Source seed to use when initializing the graph in the
      trialmaker.

   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...

   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.

   vars

class psynet.trial.graph.GraphChainNode(*args, **kwargs)

   Bases: "ChainNode"

   A Node class for graph chains.


   Parameters (for now stating the new ones)
   =========================================

   vertex_id
      The id of the vertex that the network is representing within the
      graph.

   create_definition_from_seed(seed, experiment, participant)

      (Built-in) In a graph chain, the next node in the chain is a
      faithful reproduction of the previous iteration.

      Parameters:
         * **seed** -- The seed being passed to the node.

         * **experiment** -- An instantiation of
           "psynet.experiment.Experiment", corresponding to the
           current experiment.

         * **participant** -- Current participant, if relevant.

      Returns:
         * *object* -- The node's new definition, which is a faithful
           reproduction of the seed that it was passed.

   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...

   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)

      (Abstract method, to be overridden) This method should summarize
      the answers to the provided trials. A default method is
      implemented for cases when there is just one trial per node; in
      this case, the method extracts and returns the trial's answer,
      available in "trial.answer". The method must be extended if it
      is to cope with multiple trials per node, however.

      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 async
           job) 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.graph.GraphChainTrial(*args, **kwargs)

   Bases: "ChainTrial"

   A Trial class for graph chains.

   complete

      Whether the trial has been completed (i.e. received a response
      from the participant). It is set once all of "show_trial()"'s
      pages have ended, before "show_feedback()", and also when a
      barrier's release ends the trial's page in "waiting_logic"
      before it is answered, in which case the trial is failed with
      "failed_reason="interrupted_by_release"", not finalized, and
      gets no "show_feedback()". The user should not typically change
      this directly.

   creation_time

      the time at which the Network was created.

   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.

   group_round

      The "SyncGroupRound" this trial was played in, shared with the
      trials of the other members in the round, or "None" for
      ungrouped trials. Its "var" holds the group's results for the
      round, and "group_round.trials" the partners' trials.

   id

      a unique number for every entry. 1, 2, 3 and so on...

   make_definition(experiment, participant)

      (Built-in) In a graph chain, the trial's definition equals the
      definition of the node that created it.

      Parameters:
         * **experiment** -- An instantiation of
           "psynet.experiment.Experiment", corresponding to the
           current experiment.

         * **participant** -- Optional participant with which to
           associate the trial.

      Returns:
         * *object* -- The trial's definition, equal to the node's
           definition.

   position

      Zero-based creation position among all trials from this trial
      maker for the participant, or, for trials made by "Trial.cue()",
      among the participant's trials in the same module.

   sync_group_id

      The group of the trial maker's (or, for cued trials, the trial
      class's) "sync_group_type" that the participant was in when the
      trial was created, kept after the group ends.

   sync_group_outcome

      when the trial maker prepares the group's next trials,
      ""stayed"" is written on the complete trials of the members
      still in the group. "None" while nothing has happened yet, and
      for ungrouped trials.

      Type:
         How the group's round ended for this player, for a trial in a
         group's round ("group_round"), one of "SyncGroupOutcome". It
         is written during the trial's pages, that is, before
         "complete" is set

      Type:
         ""stayed"" once a "GroupBarrier" in those pages, such as in
         "show_trial()", releases the group with the player in it,
         after which it doesn't change. Before that, why the player
         left the group, one of the reasons of "remove_participant()",
         such as ""late"", ""waited_too_long"", ""left_experiment"" or
         ""group_dissolved"" or ""removed_by_experimenter"". Leaving
         after a release, for example by being late at a later
         barrier, shows in "sync_group_removal_reason()" and in the
         "left" of the next barrier's "on_release" instead. Barriers
         and departures after the trial's pages, such as in
         "show_feedback()" or between rounds, write nothing. The
         exception is a trial maker's round that no barrier in the
         trial's pages released

   sync_group_role

      The participant's role in "sync_group_id", if a Regrouper gave
      one.

   sync_group_round

      Which round of "sync_group_id" this trial belongs to, counted
      from 0. A member who joined the group late shares the group's
      numbers. In a trial maker, a leader told to wait gives the group
      no trials, so the followers wait too and no number is used up.
      It equals the "number" of "group_round".

   sync_group_round_id

      ID of "group_round".

   time_of_death

      the time at which failing occurred

   type

   vars

class psynet.trial.graph.GraphChainTrialMaker(*, id_, node_class, trial_class, network_structure, chain_type, expected_trials_per_participant, max_trials_per_participant, chains_per_participant, trials_per_node, check_performance_at_end, check_performance_every_trial, recruit_mode=None, target_n_participants=None, n_participants_completion='experiment', max_nodes_per_chain=None, max_trials_per_block=None, block_order='random', chain_order='random', interleave_chains=True, balance_across_chains=None, fail_trials_on_premature_exit=False, fail_trials_on_participant_performance_check=False, propagate_failure=True, n_repeat_trials=0, wait_for_networks=False, allow_revisiting_networks_in_across_chains=False, choose_participant_group=None, sync_group_type=None, sync_group_max_wait_time=<class 'psynet.utils.NoArgumentProvided'>, sync_group_max_wait_action='fail', sync_group_late_after=None, sync_group_late_action=None, sync_group_also_leave=None, sync_group_waiting_message=None, sync_group_newcomer_max_wait=None)

   Bases: "ChainTrialMaker"

   A TrialMaker class for graph chains; see the documentation for
   "ChainTrialMaker" for usage instructions.

   Parameters:
      **network_structure** --

      A representation of the graph structure to instantiate. The
      representation consistes of a dictionary of vertices and edges.
      E.g. {"vertices": [1,2], "edges": [{"origin": 1, "target": 2,
      "properties": {"type": "default"}}]}

      The "blocks" and "participant_groups" keys are optional and can
      be used to specify the blocks and participant groups for each
      vertex. E.g. {"vertices": [1,2], "edges": [{"origin": 1,
      "target": 2}], "blocks": {1: "block1", 2: "block2"],
      "participant_groups": {1: "group1", 2: "group2"}}

   get_candidate_network_ids_after_finalized_node(finalized_node)

      Return graph networks that can be newly unlocked by a finalized
      node.

      A graph node at vertex "u" and degree "d" can only affect target
      networks "v" with an edge "u -> v" whose current head is also at
      degree "d". The full readiness predicate is applied by the
      caller.

   grow_network(network, experiment, check_readiness=True)

      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.

   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.

class psynet.trial.graph.GraphChainVertex(*args, **kwargs)

   Bases: "Base", "SQLMixin"

   Stores the static vertex metadata for a graph chain trial maker.

   Graph topology is normalized into vertices and edges so graph
   readiness can be queried efficiently in SQL instead of relying on
   serialized Python lists.

   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
