Skip to content

Latest commit

 

History

History
602 lines (375 loc) · 14.5 KB

classes.rst

File metadata and controls

602 lines (375 loc) · 14.5 KB

Database API

dallinger.models

The classes involved in a Dallinger experiment are: Network, ~Node, ~Vector, ~Info, ~Transmission, ~Transformation, ~Participant, and ~Question. The code for all these classes can be seen in models.py. Each class has a corresponding table in the database, with each instance stored as a row in the table. Accordingly, each class is defined, in part, by the columns that constitute the table it is stored in. In addition, the classes have relationships to other objects and a number of functions.

The classes have relationships to each other as shown in the diagram below. Be careful to note which way the arrows point. A ~Node is a point in a ~Network that might be associated with a Participant. A Vector is a directional connection between a Node and another Node. An Info is information created by a Node. A Transmission is an instance of an Info being sent along a Vector. A Transformation is a relationship between an Info and another Info. A Question is a survey response created by a Participant.

SharedMixin

All Dallinger classes inherit from a SharedMixin which provides multiple columns that are common across tables:

dallinger.models.SharedMixin.id

dallinger.models.SharedMixin.creation_time

dallinger.models.SharedMixin.property1

dallinger.models.SharedMixin.property2

dallinger.models.SharedMixin.property3

dallinger.models.SharedMixin.property4

dallinger.models.SharedMixin.property5

dallinger.models.SharedMixin.details

dallinger.models.SharedMixin.failed

dallinger.models.SharedMixin.time_of_death

dallinger.models.SharedMixin.visualization_html

Network

The Network object can be imagined as a set of other objects with some functions that perform operations over those objects. The objects that Network's have direct access to are all the Node's in the network, the Vector's between those Nodes, Infos created by those Nodes, Transmissions sent along the Vectors by those Nodes and Transformations of those Infos. Participants and Questions do not exist within Networks. An experiment may involve multiple Networks, Transmissions can only occur within networks, not between them.

dallinger.models.Network

Columns

dallinger.models.Network.type

dallinger.models.Network.max_size

dallinger.models.Network.full

dallinger.models.Network.role

Relationships

dallinger.models.Network.all_nodes

All the Nodes in the network.

dallinger.models.Network.all_vectors

All the vectors in the network.

dallinger.models.Network.all_infos

All the infos in the network.

dallinger.models.Network.networks_transmissions

All the transmissions int he network.

dallinger.models.Network.networks_transformations

All the transformations in the network.

Methods

dallinger.models.Network.__repr__

dallinger.models.Network.__json__

dallinger.models.Network.calculate_full

dallinger.models.Network.fail

dallinger.models.Network.infos

dallinger.models.Network.latest_transmission_recipient

dallinger.models.Network.nodes

dallinger.models.Network.print_verbose

dallinger.models.Network.size

dallinger.models.Network.transformations

dallinger.models.Network.transmissions

dallinger.models.Network.vectors

Node

Each Node represents a single point in a single network. A Node must be within a Network and may also be associated with a Participant.

dallinger.models.Node

Columns

dallinger.models.Node.type

dallinger.models.Node.network_id

dallinger.models.Node.participant_id

Relationships

dallinger.models.Node.network

dallinger.models.Node.participant

dallinger.models.Node.all_outgoing_vectors

All the vectors going out from this Node.

dallinger.models.Node.all_incoming_vectors

All the vectors coming in to this Node.

dallinger.models.Node.all_infos

All Infos created by this Node.

dallinger.models.Node.all_outgoing_transmissions

All Transmissions sent from this Node.

dallinger.models.Node.all_incoming_transmissions

All Transmissions sent to this Node.

dallinger.models.Node.transformations_here

All transformations that took place at this Node.

Methods

dallinger.models.Node.__repr__

dallinger.models.Node.__json__

dallinger.models.Node._to_whom

dallinger.models.Node._what

dallinger.models.Node.connect

dallinger.models.Node.fail

dallinger.models.Node.is_connected

dallinger.models.Node.infos

dallinger.models.Node.mutate

dallinger.models.Node.neighbors

dallinger.models.Node.receive

dallinger.models.Node.received_infos

dallinger.models.Node.replicate

dallinger.models.Node.transformations

dallinger.models.Node.transmissions

dallinger.models.Node.transmit

dallinger.models.Node.update

dallinger.models.Node.vectors

Vector

A vector is a directional link between two nodes. Nodes connected by a vector can send Transmissions to each other, but because Vectors have a direction, two Vectors are needed for bi-directional Transmissions.

dallinger.models.Vector

Columns

dallinger.models.Vector.origin_id

dallinger.models.Vector.destination_id

dallinger.models.Vector.network_id

Relationships

dallinger.models.Vector.origin

dallinger.models.Vector.destination

dallinger.models.Vector.network

dallinger.models.Vector.all_transmissions

All Transmissions sent along the Vector.

Methods

dallinger.models.Vector.__repr__

dallinger.models.Vector.__json__

dallinger.models.Vector.fail

dallinger.models.Vector.transmissions

Info

An Info is a piece of information created by a Node. It can be sent along Vectors as part of a Transmission.

dallinger.models.Info

Columns

dallinger.models.Info.id

dallinger.models.Info.creation_time

dallinger.models.Info.property1

dallinger.models.Info.property2

dallinger.models.Info.property3

dallinger.models.Info.property4

dallinger.models.Info.property5

dallinger.models.Info.details

dallinger.models.Info.failed

dallinger.models.Info.time_of_death

dallinger.models.Info.type

dallinger.models.Info.origin_id

dallinger.models.Info.network_id

dallinger.models.Info.contents

Relationships

dallinger.models.Info.origin

dallinger.models.Info.network

dallinger.models.Info.all_transmissions

All Transmissions of this Info.

dallinger.models.Info.transformation_applied_to

All Transformations of which this info is the info_in

dallinger.models.Info.transformation_whence

All Transformations of which this info is the info_out

Methods

dallinger.models.Info.__repr__

dallinger.models.Info.__json__

dallinger.models.Info._mutated_contents

dallinger.models.Info.fail

dallinger.models.Info.transformations

dallinger.models.Info.transmissions

Transmission

A transmission represents an instance of an Info being sent along a Vector. Transmissions are not necessarily received when they are sent (like an email) and must also be received by the Node they are sent to.

dallinger.models.Transmission

Columns

dallinger.models.Transmission.origin_id

dallinger.models.Transmission.destination_id

dallinger.models.Transmission.vector_id

dallinger.models.Transmission.network_id

dallinger.models.Transmission.info_id

dallinger.models.Transmission.receive_time

dallinger.models.Transmission.status

Relationships

dallinger.models.Transmission.origin

dallinger.models.Transmission.destination

dallinger.models.Transmission.vector

dallinger.models.Transmission.network

dallinger.models.Transmission.info

Methods

dallinger.models.Transmission.__repr__

dallinger.models.Transmission.__json__

dallinger.models.Transmission.fail

dallinger.models.Transmission.mark_received

Transformation

A Transformation is a relationship between two Infos. It is similar to how a Vector indicates a relationship between two Nodes, but whereas a Vector allows Nodes to Transmit to each other, Transformations don't allow Infos to do anything new. Instead they are a form of book-keeping allowing you to keep track of relationships between various Infos.

dallinger.models.Transformation

Columns

dallinger.models.Transformation.type

dallinger.models.Transformation.node_id

dallinger.models.Transformation.network_id

dallinger.models.Transformation.info_in_id

dallinger.models.Transformation.info_out_id

Relationships

dallinger.models.Transformation.node

dallinger.models.Transformation.network

dallinger.models.Transformation.info_in

dallinger.models.Transformation.info_out

Methods

dallinger.models.Transformation.__repr__

dallinger.models.Transformation.__json__

dallinger.models.Transformation.fail

Participant

The Participant object corresponds to a real world participant. Each person who takes part will have a corresponding entry in the Participant table. Participants can be associated with Nodes and Questions.

dallinger.models.Participant

Columns

dallinger.models.Participant.type

dallinger.models.Participant.worker_id

dallinger.models.Participant.assignment_id

dallinger.models.Participant.unique_id

dallinger.models.Participant.hit_id

dallinger.models.Participant.mode

dallinger.models.Participant.end_time

dallinger.models.Participant.base_pay

dallinger.models.Participant.bonus

dallinger.models.Participant.status

Relationships

dallinger.models.Participant.all_questions

All the questions associated with this participant.

dallinger.models.Participant.all_nodes

All the Nodes associated with this participant.

Methods

dallinger.models.Participant.__json__

dallinger.models.Participant.fail

dallinger.models.Participant.infos

dallinger.models.Participant.nodes

dallinger.models.Participant.questions

Question

A Question is a way to store information associated with a Participant as opposed to a Node (Infos are made by Nodes, not Participants). Questions are generally useful for storing responses debriefing questions etc.

dallinger.models.Question

Columns

dallinger.models.Question.type

dallinger.models.Question.participant_id

dallinger.models.Question.number

dallinger.models.Question.question

dallinger.models.Question.response

Relationships

dallinger.models.Question.participant

Methods

dallinger.models.Question.__json__

dallinger.models.Question.fail