devctrl.task.base.Task#
- class Task[source]#
Bases:
ABC,SettingsClassBase class for all tasks. Task classes should use the @taskclass decorator.
Methods
Convenience wrapper for dataclasses.asdict(self)
Recursively construct a SettingsClass from a dictionary.
Get formatted task name with settings
Return relevant settings as a formatted string for GUI display
Return the human-readable name of the task.
- __abstractmethods__ = frozenset({})#
- __annotations__ = {'_children': typing.Dict[str, typing.Type[ForwardRef('Task')]]}#
- __dataclass_fields__ = {}#
- __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False,match_args=True,kw_only=False,slots=False,weakref_slot=False)#
- __dict__ = mappingproxy({'__module__': 'devctrl.task.base', '__firstlineno__': 17, '__annotations__': {'_children': typing.Dict[str, typing.Type[ForwardRef('Task')]]}, '__doc__': '\nBase class for all tasks.\nTask classes should use the @taskclass decorator.\n', '_children': {'DebugTask': <class 'devctrl.task.tasks.DebugTask'>, 'WaitTask': <class 'devctrl.task.tasks.WaitTask'>, 'UserConfirmTask': <class 'devctrl.task.tasks.UserConfirmTask'>, 'MeasurementTask': <class 'prsctrl_gui.task.measurement.MeasurementTask'>}, 'get_type_name': <classmethod(<function Task.get_type_name>)>, 'get_settings_name': <function Task.get_settings_name>, 'get_name': <function Task.get_name>, '__repr__': <function Task.__repr__>, 'estimate_runtime_s': <function Task.estimate_runtime_s>, '__static_attributes__': (), '__dict__': <attribute '__dict__' of 'Task' objects>, '__weakref__': <attribute '__weakref__' of 'Task' objects>, '__abstractmethods__': frozenset(), '_abc_impl': <_abc._abc_data object>})#
- __eq__(other)#
Return self==value.
- __firstlineno__ = 17#
- __hash__ = None#
- __init__() None#
- __match_args__ = ()#
- __module__ = 'devctrl.task.base'#
- __or__(other)#
Merge with another settings class or a dictionary.
- __replace__(**changes)#
- __repr__() str[source]#
Get formatted task name with settings
- Returns:
Formatted string as ‘typename (settings_name)’
- __slots__ = ()#
- __static_attributes__ = ()#
- __weakref__#
list of weak references to the object
- _abc_impl = <_abc._abc_data object>#
- _children: Dict[str, Type[Task]] = {'DebugTask': <class 'devctrl.task.tasks.DebugTask'>, 'MeasurementTask': <class 'prsctrl_gui.task.measurement.MeasurementTask'>, 'UserConfirmTask': <class 'devctrl.task.tasks.UserConfirmTask'>, 'WaitTask': <class 'devctrl.task.tasks.WaitTask'>}#
- as_dict() dict#
Convenience wrapper for dataclasses.asdict(self)
- classmethod from_dict(data: dict)#
Recursively construct a SettingsClass from a dictionary. If the value of a field is another SettingsClass, from_dict will be called for that field as well. Handled are: - SettingsClass - list[SettingsClass] - dict[<any>, SettingsClass] - all of the above as Optional
- Raises:
ValueError – If data contains a value that has the wrong type for the field of cls (ONLY if the type is a subclass of SettingsClass! Other types are not enforced)
KeyError – If data contains a key that is not a field name of cls
- get_name()[source]#
Get formatted task name with settings
- Returns:
Formatted task name including settings
- get_settings_name() str[source]#
Return relevant settings as a formatted string for GUI display
Iterates through task fields and returns a string representation of non-default values that can be used for displaying the task in the GUI.
- Returns:
Formatted string of settings, or empty string if no settings differ from defaults
- classmethod load_yaml(yaml_path: str, loader=<class 'yaml.loader.Loader'>)#
- save_yaml(yaml_path: str)#