session¶
SessionBuilder ¶
SessionBuilder(
launcher: Launcher,
*,
experimenter_validator: Callable[[str], str | None]
| None = validate_username,
use_cache: bool = True,
)
Assembles a :class:Session by asking the user who is running and on which animal.
This is the one genuinely interactive job with no database behind it, which
is why it is not a store. It holds no state between calls, so a recovery
flow can construct a session directly and narrow a store with
store.scoped(subject=...) instead.
Example
session = SessionBuilder(launcher).build()
store = store.scoped(subject=session.subject)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
launcher
|
Launcher
|
Supplies the repository state and hardware-validation settings stamped onto the session. |
required |
experimenter_validator
|
Callable[[str], str | None] | None
|
Validates each experimenter name, returning the canonical name to store
or None to reject it. If |
validate_username
|
use_cache
|
bool
|
Whether to seed the prompts with previously entered values. |
True
|
Source code in src/clabe/session.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
build ¶
build() -> Session
Prompts for experimenter, subject and notes, and stamps the launcher's repository state.
Returns:
| Type | Description |
|---|---|
Session
|
The assembled session. |
Source code in src/clabe/session.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
choose_subject ¶
choose_subject() -> str
Prompts for a subject, offering previously used ones for autocompletion.
Returns:
| Type | Description |
|---|---|
str
|
The selected or entered subject name. |
Source code in src/clabe/session.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
prompt_experimenter ¶
Prompts for the experimenter name(s), separated by commas or spaces.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strict
|
bool
|
Whether to reject empty input. |
True
|
Returns:
| Type | Description |
|---|---|
list[str]
|
The validated experimenter names. |
Source code in src/clabe/session.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |