aepsych.database

Submodules

aepsych.database.db module

class aepsych.database.db.Database(db_path=None)[source]

Bases: object

get_engine()[source]
delete_db()[source]
is_update_required()[source]
perform_updates()[source]

Perform updates on known tables. SQLAlchemy doesn’t do alters so they’re done the old fashioned way.

session_scope()[source]

Provide a transactional scope around a series of operations.

execute_sql_query(query, vals)[source]

Execute an arbitrary query written in sql.

Parameters:
  • query (str) –

  • vals (Dict[str, str]) –

get_master_records()[source]

Grab the list of master records.

get_master_record(experiment_id)[source]

Grab the list of master record for a specific experiment (master) id.

get_replay_for(master_id)[source]

Get the replay records for a specific master row.

get_strats_for(master_id=0)[source]

Get the strat records for a specific master row.

get_strat_for(master_id, strat_id=- 1)[source]

Get a specific strat record for a specific master row.

get_config_for(master_id)[source]

Get the strat records for a specific master row.

get_raw_for(master_id)[source]

Get the raw data for a specific master row.

get_all_params_for(master_id)[source]

Get the parameters for all the iterations of a specific experiment.

get_param_for(master_id, iteration_id)[source]

Get the parameters for a specific iteration of a specific experiment.

get_all_outcomes_for(master_id)[source]

Get the outcomes for all the iterations of a specific experiment.

get_outcome_for(master_id, iteration_id)[source]

Get the outcomes for a specific iteration of a specific experiment.

record_setup(description, name, extra_metadata=None, id=None, request=None, participant_id=None)[source]
Return type:

str

record_message(master_table, type, request)[source]
Return type:

None

record_raw(master_table, model_data, timestamp=None)[source]
record_param(raw_table, param_name, param_value)[source]
Return type:

None

record_outcome(raw_table, outcome_name, outcome_value)[source]
Return type:

None

record_strat(master_table, strat)[source]
record_config(master_table, config)[source]
list_master_records()[source]

aepsych.database.tables module

class aepsych.database.tables.Base(**kwargs)

Bases: object

The base class of the class hierarchy.

When called, it accepts no arguments and returns a new featureless instance that has no instance attributes and cannot be given any.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

metadata = MetaData()
registry = <sqlalchemy.orm.decl_api.registry object>
class aepsych.database.tables.DBMasterTable(**kwargs)[source]

Bases: Base

Master table to keep track of all experiments and unique keys associated with the experiment

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

unique_id
experiment_name
experiment_description
experiment_id
participant_id
extra_metadata
children_replay
children_strat
children_config
children_raw
classmethod from_sqlite(row)[source]
static update(engine)[source]
static requires_update(engine)[source]
class aepsych.database.tables.DbReplayTable(**kwargs)[source]

Bases: Base

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

use_extra_info = False
unique_id
timestamp
message_type
message_contents
extra_info
master_table_id
parent
classmethod from_sqlite(row)[source]
static update(engine)[source]
static requires_update(engine)[source]
class aepsych.database.tables.DbStratTable(**kwargs)[source]

Bases: Base

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

unique_id
timestamp
strat
master_table_id
parent
classmethod from_sqlite(row)[source]
static update(engine)[source]
static requires_update(engine)[source]
class aepsych.database.tables.DbConfigTable(**kwargs)[source]

Bases: Base

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

unique_id
timestamp
config
master_table_id
parent
classmethod from_sqlite(row)[source]
static update(engine)[source]
static requires_update(engine)[source]
class aepsych.database.tables.DbRawTable(**kwargs)[source]

Bases: Base

Fact table to store the raw data of each iteration of an experiment.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

unique_id
timestamp
model_data
master_table_id
parent
children_param
children_outcome
classmethod from_sqlite(row)[source]
static update(db, engine)[source]
static requires_update(engine)[source]

Check if the raw table is empty, and data already exists.

class aepsych.database.tables.DbParamTable(**kwargs)[source]

Bases: Base

Dimension table to store the parameters of each iteration of an experiment. Supports multiple parameters per iteration, and multiple stimuli per parameter.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

unique_id
param_name
param_value
iteration_id
parent
classmethod from_sqlite(row)[source]
static update(engine)[source]
static requires_update(engine)[source]
class aepsych.database.tables.DbOutcomeTable(**kwargs)[source]

Bases: Base

Dimension table to store the outcomes of each iteration of an experiment. Supports multiple outcomes per iteration.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

unique_id
outcome_name
outcome_value
iteration_id
parent
classmethod from_sqlite(row)[source]
static update(engine)[source]
static requires_update(engine)[source]

Module contents