pickers.dataverse¶
DataverseSuggestion ¶
Bases: BaseModel
Internal representation of a suggestion entry in Dataverse.
validate_trainer_state
classmethod
¶
validate_trainer_state(value)
Validate and convert the trainer_state field from a JSON string to a TrainerState object.
Source code in src\clabe\pickers\dataverse.py
390 391 392 393 394 395 396 397 398 399 400 |
|
from_request_output
classmethod
¶
from_request_output(
subject: str, request_output: dict
) -> DataverseSuggestion
Create a _Suggestion instance from a dictionary of data.
Source code in src\clabe\pickers\dataverse.py
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 |
|
from_trainer_state
classmethod
¶
from_trainer_state(
subject: str, trainer_state: TrainerState
) -> DataverseSuggestion
Create a _Suggestion instance from a TrainerState object.
Source code in src\clabe\pickers\dataverse.py
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 |
|
DataversePicker ¶
DataversePicker(
*,
dataverse_client: Optional[_DataverseRestClient] = None,
settings: DefaultBehaviorPickerSettings,
ui_helper: Optional[UiHelper] = None,
experimenter_validator: Optional[
Callable[[str], bool]
] = validate_aind_username,
)
Bases: DefaultBehaviorPicker
, Generic[TRig, TSession, TTaskLogic]
Picker that integrates with Dataverse to fetch and push trainer state suggestions.
Initializes the DataversePicker.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataverse_client
|
Optional[_DataverseRestClient]
|
Optional Dataverse REST client for making API calls. If not provided, a new client will be created using settings from KeePass. |
None
|
settings
|
DefaultBehaviorPickerSettings
|
Settings containing configuration including config_library_dir |
required |
ui_helper
|
Optional[UiHelper]
|
Helper for user interface interactions |
None
|
experimenter_validator
|
Optional[Callable[[str], bool]]
|
Function to validate the experimenter's username. If None, no validation is performed |
validate_aind_username
|
Source code in src\clabe\pickers\dataverse.py
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 |
|
has_ui_helper
property
¶
has_ui_helper: bool
Checks if a UI helper is registered.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if a UI helper is registered, False otherwise |
ui_helper
property
¶
ui_helper: UiHelper
Retrieves the registered UI helper.
Returns:
Name | Type | Description |
---|---|---|
DefaultUIHelper |
UiHelper
|
The registered UI helper |
Raises:
Type | Description |
---|---|
ValueError
|
If no UI helper is registered |
trainer_state
property
¶
trainer_state: TrainerState
Returns the current trainer state.
Returns:
Name | Type | Description |
---|---|---|
TrainerState |
TrainerState
|
The current trainer state. |
Raises:
Type | Description |
---|---|
ValueError
|
If the trainer state is not set. |
config_library_dir
property
¶
config_library_dir: Path
Returns the path to the configuration library directory.
Returns:
Name | Type | Description |
---|---|---|
Path |
Path
|
The configuration library directory. |
rig_dir
property
¶
rig_dir: Path
Returns the path to the rig configuration directory.
Returns:
Name | Type | Description |
---|---|---|
Path |
Path
|
The rig configuration directory. |
subject_dir
property
¶
subject_dir: Path
Returns the path to the subject configuration directory.
Returns:
Name | Type | Description |
---|---|---|
Path |
Path
|
The subject configuration directory. |
task_logic_dir
property
¶
task_logic_dir: Path
Returns the path to the task logic configuration directory.
Returns:
Name | Type | Description |
---|---|---|
Path |
Path
|
The task logic configuration directory. |
pick_trainer_state ¶
pick_trainer_state(
launcher: Launcher[TRig, TSession, TTaskLogic],
) -> TrainerState
Prompts the user to select or create a trainer state configuration.
Attempts to load trainer state in the following order: 1. If task_logic already exists in launcher, will return an empty TrainerState 2. From subject-specific folder
It will launcher.set_task_logic if the deserialized TrainerState is valid.
Returns:
Name | Type | Description |
---|---|---|
TrainerState |
TrainerState
|
The deserialized TrainerState object. |
Raises:
Type | Description |
---|---|
ValueError
|
If no valid task logic file is found. |
Source code in src\clabe\pickers\dataverse.py
506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 |
|
push_new_suggestion ¶
push_new_suggestion(
launcher: Launcher[TRig, TSession, TTaskLogic],
trainer_state: TrainerState,
) -> None
Pushes a new suggestion to Dataverse for the current subject in the launcher. Args: launcher: The Launcher instance containing the current session and subject information. trainer_state: The TrainerState object to be pushed as a new suggestion.
Source code in src\clabe\pickers\dataverse.py
563 564 565 566 567 568 569 570 571 |
|
register_ui_helper ¶
register_ui_helper(ui_helper: UiHelper) -> Self
Registers a UI helper with the picker.
Associates a UI helper instance with this picker for user interactions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ui_helper
|
UiHelper
|
The UI helper to register |
required |
Returns:
Name | Type | Description |
---|---|---|
Self |
Self
|
The picker instance for method chaining |
Raises:
Type | Description |
---|---|
ValueError
|
If a UI helper is already registered |
Source code in src\clabe\pickers\default_behavior.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
initialize ¶
initialize(
launcher: Launcher[TRig, TSession, TTaskLogic],
) -> None
Initializes the picker by creating required directories if needed.
Source code in src\clabe\pickers\default_behavior.py
195 196 197 198 199 200 201 |
|
pick_rig ¶
pick_rig(
launcher: Launcher[TRig, TSession, TTaskLogic],
) -> TRig
Prompts the user to select a rig configuration file.
Searches for available rig configuration files and either automatically selects a single file or prompts the user to choose from multiple options.
Returns:
Name | Type | Description |
---|---|---|
TRig |
TRig
|
The selected rig configuration. |
Raises:
Type | Description |
---|---|
ValueError
|
If no rig configuration files are found or an invalid choice is made. |
Source code in src\clabe\pickers\default_behavior.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
|
pick_session ¶
pick_session(
launcher: Launcher[TRig, TSession, TTaskLogic],
) -> TSession
Prompts the user to select or create a session configuration.
Collects experimenter information, subject selection, and session notes to create a new session configuration with appropriate metadata.
Returns:
Name | Type | Description |
---|---|---|
TSession |
TSession
|
The created or selected session configuration. |
Source code in src\clabe\pickers\default_behavior.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
|
pick_task_logic ¶
pick_task_logic(
launcher: Launcher[TRig, TSession, TTaskLogic],
) -> TTaskLogic
Prompts the user to select or create a task logic configuration.
Attempts to load task logic in the following order: 1. From CLI if already set 2. From subject-specific folder 3. From user selection in task logic library
Returns:
Name | Type | Description |
---|---|---|
TTaskLogic |
TTaskLogic
|
The created or selected task logic configuration. |
Raises:
Type | Description |
---|---|
ValueError
|
If no valid task logic file is found. |
Source code in src\clabe\pickers\default_behavior.py
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
|
choose_subject ¶
Prompts the user to select or manually enter a subject name.
Allows the user to either type a new subject name or select from existing subject directories.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
directory
|
str | PathLike
|
Path to the directory containing subject folders |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The selected or entered subject name. |
Example
# Choose a subject from the subjects directory
subject = picker.choose_subject("Subjects")
Source code in src\clabe\pickers\default_behavior.py
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 |
|
prompt_experimenter ¶
Prompts the user to enter the experimenter's name(s).
Accepts multiple experimenter names separated by commas or spaces. Validates names using the configured validator function if provided.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
strict
|
bool
|
Whether to enforce non-empty input |
True
|
Returns:
Type | Description |
---|---|
Optional[List[str]]
|
Optional[List[str]]: List of experimenter names. |
Example
# Prompt for experimenter with validation
names = picker.prompt_experimenter(strict=True)
print("Experimenters:", names)
Source code in src\clabe\pickers\default_behavior.py
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 |
|
dump_model ¶
dump_model(
launcher: Launcher[TRig, TSession, TTaskLogic],
model: Union[
AindBehaviorRigModel,
AindBehaviorTaskLogicModel,
TrainerState,
],
) -> Optional[Path]
Saves the provided model to the appropriate configuration file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
launcher
|
Launcher[TRig, TSession, TTaskLogic]
|
The launcher instance managing the experiment. |
required |
model
|
Union[AindBehaviorRigModel, AindBehaviorTaskLogicModel, TrainerState]
|
The model instance to save. |
required |
Returns:
Type | Description |
---|---|
Optional[Path]
|
Optional[Path]: The path to the saved model file, or None if not saved. |
Source code in src\clabe\pickers\default_behavior.py
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 |
|