ui.picker¶
PickerBase ¶
PickerBase(
*, ui_helper: Optional[_UiHelperBase] = None, **kwargs
)
Bases: ABC
, Generic[_L, _R, _S, _T]
Abstract base class for pickers that handle the selection of rigs, sessions, and task logic.
This class defines the interface for picker implementations that manage the selection and configuration of experiment components including rigs, sessions, and task logic.
Example
class MyPicker(PickerBase):
def pick_rig(self, launcher: _L) -> _R:
# Implementation specific rig picking logic
return launcher.get_rig_model()()
def pick_session(self, launcher: _L) -> _S:
# Implementation specific session picking logic
return launcher.get_session_model()()
def pick_task_logic(self, launcher: _L) -> _T:
# Implementation specific task logic picking logic
return launcher.get_task_logic_model()()
picker = MyPicker()
# Assuming 'launcher' is an instance of Launcher
rig = picker.pick_rig(launcher)
session = picker.pick_session(launcher)
task_logic = picker.pick_task_logic(launcher)
Initializes the picker with an optional UI helper.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ui_helper
|
Optional[_UiHelperBase]
|
The UI helper instance |
None
|
Example
# Create picker without dependencies
picker = MyPicker()
# Create picker with launcher and UI helper
launcher = MyLauncher(...)
ui_helper = DefaultUIHelper()
picker = MyPicker(launcher=launcher, ui_helper=ui_helper)
Source code in src/clabe/ui/picker.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
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: _UiHelperBase
Retrieves the registered UI helper.
Returns:
Name | Type | Description |
---|---|---|
_UiHelperBase |
_UiHelperBase
|
The registered UI helper |
Raises:
Type | Description |
---|---|
ValueError
|
If no UI helper is registered |
register_ui_helper ¶
register_ui_helper(ui_helper: _UiHelperBase) -> 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
|
_UiHelperBase
|
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/ui/picker.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
pick_rig
abstractmethod
¶
pick_rig(launcher: _L) -> _R
Abstract method to pick a rig.
Subclasses must implement this method to provide rig selection functionality.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
launcher
|
_L
|
The launcher instance |
required |
Returns:
Name | Type | Description |
---|---|---|
_R |
_R
|
The selected rig |
Source code in src/clabe/ui/picker.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
|
pick_session
abstractmethod
¶
pick_session(launcher: _L) -> _S
Abstract method to pick a session.
Subclasses must implement this method to provide session selection/creation functionality.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
launcher
|
_L
|
The launcher instance |
required |
Returns:
Name | Type | Description |
---|---|---|
_S |
_S
|
The selected session |
Source code in src/clabe/ui/picker.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|
pick_task_logic
abstractmethod
¶
pick_task_logic(launcher: _L) -> _T
Abstract method to pick task logic.
Subclasses must implement this method to provide task logic selection functionality.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
launcher
|
_L
|
The launcher instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
_T |
_T
|
The selected task logic |
Source code in src/clabe/ui/picker.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
|