Skip to content

ui.picker

PickerBase

PickerBase(
    launcher: Optional[_L] = None,
    *,
    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.

Type Parameters

_L: Type of the launcher _R: Type of the rig model _S: Type of the session model _T: Type of the task logic model

Example
class MyPicker(PickerBase):
    def pick_rig(self):
        return MyRigModel(name="test_rig")

    def pick_session(self):
        return MySessionModel(subject="test_subject")

    def pick_task_logic(self):
        return MyTaskLogicModel(name="test_task")

    def initialize(self):
        pass

    def finalize(self):
        pass

picker = MyPicker()
picker.register_launcher(launcher)
picker.initialize()
rig = picker.pick_rig()

Initializes the picker with an optional launcher and UI helper.

Parameters:

Name Type Description Default
launcher Optional[_L]

The launcher instance

None
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
def __init__(self, launcher: Optional[_L] = None, *, ui_helper: Optional[_UiHelperBase] = None, **kwargs) -> None:
    """
    Initializes the picker with an optional launcher and UI helper.

    Args:
        launcher: The launcher instance
        ui_helper: The UI helper instance

    Example:
        ```python
        # 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)
        ```
    """
    self._launcher = launcher
    self._ui_helper = ui_helper

has_launcher property

has_launcher: bool

Checks if a launcher is registered.

Returns:

Name Type Description
bool bool

True if a launcher is registered, False otherwise

Example
picker = MyPicker()
print(picker.has_launcher)  # False

picker.register_launcher(launcher)
print(picker.has_launcher)  # True

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

launcher property

launcher: _L

Retrieves the registered launcher.

Returns:

Name Type Description
_L _L

The registered launcher

Raises:

Type Description
ValueError

If no launcher is registered

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_launcher

register_launcher(launcher: _L) -> Self

Registers a launcher with the picker.

Associates a launcher instance with this picker for accessing experiment configuration and state.

Parameters:

Name Type Description Default
launcher _L

The launcher to register

required

Returns:

Name Type Description
Self Self

The picker instance for method chaining

Raises:

Type Description
ValueError

If a launcher is already registered

Example
picker = MyPicker()
launcher = MyLauncher()

picker.register_launcher(launcher)
# Now picker can access launcher settings
settings = picker.launcher.settings
Source code in src/clabe/ui/picker.py
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
def register_launcher(self, launcher: _L) -> Self:
    """
    Registers a launcher with the picker.

    Associates a launcher instance with this picker for accessing experiment
    configuration and state.

    Args:
        launcher: The launcher to register

    Returns:
        Self: The picker instance for method chaining

    Raises:
        ValueError: If a launcher is already registered

    Example:
        ```python
        picker = MyPicker()
        launcher = MyLauncher()

        picker.register_launcher(launcher)
        # Now picker can access launcher settings
        settings = picker.launcher.settings
        ```
    """
    if self._launcher is None:
        self._launcher = launcher
    else:
        raise ValueError("Launcher is already registered")
    return self

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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
def register_ui_helper(self, ui_helper: _UiHelperBase) -> Self:
    """
    Registers a UI helper with the picker.

    Associates a UI helper instance with this picker for user interactions.

    Args:
        ui_helper: The UI helper to register

    Returns:
        Self: The picker instance for method chaining

    Raises:
        ValueError: If a UI helper is already registered
    """
    if self._ui_helper is None:
        self._ui_helper = ui_helper
    else:
        raise ValueError("UI Helper is already registered")
    return self

pick_rig abstractmethod

pick_rig() -> _R

Abstract method to pick a rig.

Subclasses must implement this method to provide rig selection functionality.

Returns:

Name Type Description
_R _R

The selected rig

Source code in src/clabe/ui/picker.py
193
194
195
196
197
198
199
200
201
202
203
@abc.abstractmethod
def pick_rig(self) -> _R:
    """
    Abstract method to pick a rig.

    Subclasses must implement this method to provide rig selection functionality.

    Returns:
        _R: The selected rig
    """
    ...

pick_session abstractmethod

pick_session() -> _S

Abstract method to pick a session.

Subclasses must implement this method to provide session selection/creation functionality.

Returns:

Name Type Description
_S _S

The selected session

Source code in src/clabe/ui/picker.py
205
206
207
208
209
210
211
212
213
214
215
@abc.abstractmethod
def pick_session(self) -> _S:
    """
    Abstract method to pick a session.

    Subclasses must implement this method to provide session selection/creation functionality.

    Returns:
        _S: The selected session
    """
    ...

pick_task_logic abstractmethod

pick_task_logic() -> _T

Abstract method to pick task logic.

Subclasses must implement this method to provide task logic selection functionality.

Returns:

Name Type Description
_T _T

The selected task logic

Source code in src/clabe/ui/picker.py
217
218
219
220
221
222
223
224
225
226
227
@abc.abstractmethod
def pick_task_logic(self) -> _T:
    """
    Abstract method to pick task logic.

    Subclasses must implement this method to provide task logic selection functionality.

    Returns:
        _T: The selected task logic
    """
    ...

initialize abstractmethod

initialize() -> None

Abstract method to initialize the picker.

Subclasses should implement this method to perform any necessary setup operations.

Source code in src/clabe/ui/picker.py
229
230
231
232
233
234
235
236
@abc.abstractmethod
def initialize(self) -> None:
    """
    Abstract method to initialize the picker.

    Subclasses should implement this method to perform any necessary setup operations.
    """
    ...

finalize abstractmethod

finalize() -> None

Abstract method to finalize the picker.

Subclasses should implement this method to perform any necessary cleanup operations.

Source code in src/clabe/ui/picker.py
238
239
240
241
242
243
244
245
@abc.abstractmethod
def finalize(self) -> None:
    """
    Abstract method to finalize the picker.

    Subclasses should implement this method to perform any necessary cleanup operations.
    """
    ...

DefaultPicker

DefaultPicker(
    launcher: Optional[_L] = None,
    *,
    ui_helper: Optional[_UiHelperBase] = None,
    **kwargs,
)

Bases: PickerBase[_L, _R, _S, _T]

Default implementation of the picker. This serves as a placeholder implementation.

This class provides a basic implementation that raises NotImplementedError for all picker methods, serving as a template for actual picker implementations.

Initializes the picker with an optional launcher and UI helper.

Parameters:

Name Type Description Default
launcher Optional[_L]

The launcher instance

None
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
def __init__(self, launcher: Optional[_L] = None, *, ui_helper: Optional[_UiHelperBase] = None, **kwargs) -> None:
    """
    Initializes the picker with an optional launcher and UI helper.

    Args:
        launcher: The launcher instance
        ui_helper: The UI helper instance

    Example:
        ```python
        # 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)
        ```
    """
    self._launcher = launcher
    self._ui_helper = ui_helper

has_launcher property

has_launcher: bool

Checks if a launcher is registered.

Returns:

Name Type Description
bool bool

True if a launcher is registered, False otherwise

Example
picker = MyPicker()
print(picker.has_launcher)  # False

picker.register_launcher(launcher)
print(picker.has_launcher)  # True

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

launcher property

launcher: _L

Retrieves the registered launcher.

Returns:

Name Type Description
_L _L

The registered launcher

Raises:

Type Description
ValueError

If no launcher is registered

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

pick_rig

pick_rig() -> _R

Raises NotImplementedError as this method is not implemented.

Raises:

Type Description
NotImplementedError

Always, as this is a placeholder implementation

Source code in src/clabe/ui/picker.py
256
257
258
259
260
261
262
263
def pick_rig(self) -> _R:
    """
    Raises NotImplementedError as this method is not implemented.

    Raises:
        NotImplementedError: Always, as this is a placeholder implementation
    """
    raise NotImplementedError("pick_rig method is not implemented")

pick_session

pick_session() -> _S

Raises NotImplementedError as this method is not implemented.

Raises:

Type Description
NotImplementedError

Always, as this is a placeholder implementation

Source code in src/clabe/ui/picker.py
265
266
267
268
269
270
271
272
def pick_session(self) -> _S:
    """
    Raises NotImplementedError as this method is not implemented.

    Raises:
        NotImplementedError: Always, as this is a placeholder implementation
    """
    raise NotImplementedError("pick_session method is not implemented")

pick_task_logic

pick_task_logic() -> _T

Raises NotImplementedError as this method is not implemented.

Raises:

Type Description
NotImplementedError

Always, as this is a placeholder implementation

Source code in src/clabe/ui/picker.py
274
275
276
277
278
279
280
281
def pick_task_logic(self) -> _T:
    """
    Raises NotImplementedError as this method is not implemented.

    Raises:
        NotImplementedError: Always, as this is a placeholder implementation
    """
    raise NotImplementedError("pick_task_logic method is not implemented")

initialize

initialize() -> None

Placeholder implementation for initialization.

Does nothing in the default implementation.

Source code in src/clabe/ui/picker.py
283
284
285
286
287
288
289
def initialize(self) -> None:
    """
    Placeholder implementation for initialization.

    Does nothing in the default implementation.
    """
    return

finalize

finalize() -> None

Placeholder implementation for finalization.

Does nothing in the default implementation.

Source code in src/clabe/ui/picker.py
291
292
293
294
295
296
297
def finalize(self) -> None:
    """
    Placeholder implementation for finalization.

    Does nothing in the default implementation.
    """
    return

register_launcher

register_launcher(launcher: _L) -> Self

Registers a launcher with the picker.

Associates a launcher instance with this picker for accessing experiment configuration and state.

Parameters:

Name Type Description Default
launcher _L

The launcher to register

required

Returns:

Name Type Description
Self Self

The picker instance for method chaining

Raises:

Type Description
ValueError

If a launcher is already registered

Example
picker = MyPicker()
launcher = MyLauncher()

picker.register_launcher(launcher)
# Now picker can access launcher settings
settings = picker.launcher.settings
Source code in src/clabe/ui/picker.py
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
def register_launcher(self, launcher: _L) -> Self:
    """
    Registers a launcher with the picker.

    Associates a launcher instance with this picker for accessing experiment
    configuration and state.

    Args:
        launcher: The launcher to register

    Returns:
        Self: The picker instance for method chaining

    Raises:
        ValueError: If a launcher is already registered

    Example:
        ```python
        picker = MyPicker()
        launcher = MyLauncher()

        picker.register_launcher(launcher)
        # Now picker can access launcher settings
        settings = picker.launcher.settings
        ```
    """
    if self._launcher is None:
        self._launcher = launcher
    else:
        raise ValueError("Launcher is already registered")
    return self

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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
def register_ui_helper(self, ui_helper: _UiHelperBase) -> Self:
    """
    Registers a UI helper with the picker.

    Associates a UI helper instance with this picker for user interactions.

    Args:
        ui_helper: The UI helper to register

    Returns:
        Self: The picker instance for method chaining

    Raises:
        ValueError: If a UI helper is already registered
    """
    if self._ui_helper is None:
        self._ui_helper = ui_helper
    else:
        raise ValueError("UI Helper is already registered")
    return self