Skip to content

session_with_datetime.py

activate(schema_name, create_schema=True, create_tables=True, linking_module=None)

Activate this schema.

Parameters:

Name Type Description Default
schema_name str

schema name on the database server

required
create_schema bool

when True (default), create schema in the database if it does not yet exist.

True
create_tables str

when True (default), create schema tables in the database if they do not yet exist.

True
linking_module str

a module (or name) containing the required dependencies.

None

Dependencies: Upstream tables: Subject: the subject with which an experimental session is associated Project: the project with which experimental sessions are associated Experimenter: the experimenter(s) participating in a given session To supply from element-lab add Experimenter = lab.User to your workflow/pipeline.py before session.activate()

Source code in element_session/session_with_datetime.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
def activate(
    schema_name,
    create_schema: bool = True,
    create_tables: bool = True,
    linking_module: str = None,
):
    """Activate this schema.

    Args:
        schema_name (str): schema name on the database server
        create_schema (bool): when True (default), create schema in the database if it
                            does not yet exist.
        create_tables (str): when True (default), create schema tables in the database
                             if they do not yet exist.
        linking_module (str): a module (or name) containing the required dependencies.

    Dependencies:
    Upstream tables:
        Subject: the subject with which an experimental session is associated
        Project: the project with which experimental sessions are associated
        Experimenter: the experimenter(s) participating in a given session
                      To supply from element-lab add `Experimenter = lab.User`
                      to your `workflow/pipeline.py` before `session.activate()`
    """
    if isinstance(linking_module, str):
        linking_module = importlib.import_module(linking_module)
    assert inspect.ismodule(
        linking_module
    ), "The argument 'dependency' must be a module's name or a module"

    global _linking_module
    _linking_module = linking_module

    schema.activate(
        schema_name,
        create_schema=create_schema,
        create_tables=create_tables,
        add_objects=linking_module.__dict__,
    )

Session

Bases: Manual

Central Session table

Attributes:

Name Type Description
Subject foreign key

Key for Subject table

session_datetime datetime

date and time of the session

Source code in element_session/session_with_datetime.py
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
@schema
class Session(dj.Manual):
    """Central Session table

    Attributes:
        Subject (foreign key): Key for Subject table
        session_datetime (datetime): date and time of the session
    """

    definition = """
    -> Subject
    session_datetime: datetime
    """

    class Attribute(dj.Part):
        """Additional feature of interest for a session.

        Attributes:
            Session (foreign key): Key for Session table
            attribute_name ( varchar(32) ): Name shared across instances of attribute
            attribute_value ( varchar(2000), optional ):  Attribute value
            attribute_blob (longblob, optional): Optional data store field
        """

        definition = """
        -> master
        attribute_name: varchar(32)
        ---
        attribute_value='': varchar(2000)
        attribute_blob=null: longblob
        """

Attribute

Bases: Part

Additional feature of interest for a session.

Attributes:

Name Type Description
Session foreign key

Key for Session table

attribute_name varchar(32)

Name shared across instances of attribute

attribute_value varchar(2000), optional

Attribute value

attribute_blob longblob

Optional data store field

Source code in element_session/session_with_datetime.py
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
class Attribute(dj.Part):
    """Additional feature of interest for a session.

    Attributes:
        Session (foreign key): Key for Session table
        attribute_name ( varchar(32) ): Name shared across instances of attribute
        attribute_value ( varchar(2000), optional ):  Attribute value
        attribute_blob (longblob, optional): Optional data store field
    """

    definition = """
    -> master
    attribute_name: varchar(32)
    ---
    attribute_value='': varchar(2000)
    attribute_blob=null: longblob
    """

SessionDirectory

Bases: Manual

Relative path information for files related to a given session.

Attributes:

Name Type Description
Session foreign key

Key for Session table

session_dir varchar(256)

Path to the data directory for a session

Source code in element_session/session_with_datetime.py
84
85
86
87
88
89
90
91
92
93
94
95
96
97
@schema
class SessionDirectory(dj.Manual):
    """Relative path information for files related to a given session.

    Attributes:
        Session (foreign key): Key for Session table
        session_dir ( varchar(256) ): Path to the data directory for a session
    """

    definition = """
    -> Session
    ---
    session_dir: varchar(256) # Path to the data directory for a session
    """

SessionExperimenter

Bases: Manual

Individual(s) conducting the session

Attributes:

Name Type Description
Session foreign key

Key for Session table

Experimenter foreign key

Key for Experimenter table

Source code in element_session/session_with_datetime.py
100
101
102
103
104
105
106
107
108
109
110
111
112
113
@schema
class SessionExperimenter(dj.Manual):
    """Individual(s) conducting the session

    Attributes:
        Session (foreign key): Key for Session table
        Experimenter (foreign key): Key for Experimenter table
    """

    definition = """
    # Individual(s) conducting the session
    -> Session
    -> Experimenter
    """

SessionNote

Bases: Manual

Additional notes related to a given session

Attributes:

Name Type Description
Session foreign key

Key for Session table

session_note varchar(1024)

Additional notes

Source code in element_session/session_with_datetime.py
116
117
118
119
120
121
122
123
124
125
126
127
128
129
@schema
class SessionNote(dj.Manual):
    """Additional notes related to a given session

    Attributes:
        Session (foreign key): Key for Session table
        session_note ( varchar(1024) ): Additional notes
    """

    definition = """
    -> Session
    ---
    session_note: varchar(1024)
    """

ProjectSession

Bases: Manual

Table linking upstream Projects with Session

Attributes:

Name Type Description
Project foreign key

Key for Project table

Session foreign key

Key for Session table

Source code in element_session/session_with_datetime.py
132
133
134
135
136
137
138
139
140
141
142
143
144
@schema
class ProjectSession(dj.Manual):
    """Table linking upstream Projects with Session

    Attributes:
        Project (foreign key): Key for Project table
        Session (foreign key): Key for Session table
    """

    definition = """
    -> Project
    -> Session
    """