Skip to content

laboneq.workflow.opts

OptionBuilder(base)

A class to build options for a workflow.

base: WorkflowOptions property

Return the base options.

TaskOptions

Base class for task options.

WorkflowOptions

Base options for a workflow.

Attributes:

Name Type Description
logstore list[LogbookStore] | LogbookStore | None

The logstore to use for the particular workflow. If left as None, uses the currently activated logstores. The field accepts either a single logstore or a list of logstores. Empty list results to no logging at all.

This field is not serialized/deserialized.

_task_options dict[str, BaseOptions]

A mapping of sub-task and sub-workflow options. A task can have only one unique set of options per workflow.

logstore: list[LogbookStore] | LogbookStore | None = option_field(None, description='The logstores to use.', exclude=True, repr=False, converter=_logstore_converter) class-attribute instance-attribute

get_and_validate_param_type(fn, type_check, parameter='options')

Get the type of the parameter for a function-like object.

The function-like object must have an parameter with a type hint, following any of the following patterns:

* `Union[type, None]`
* `type | None`
* `Optional[type]`.

Returns:

Type Description
type[T] | None

Type of the parameter if it exists and satisfies the above

type[T] | None

conditions, otherwise None.

Raises:

Type Description
ValueError

When the type hint contains a subclass of type_check, but does not follow any of the specific patterns.

option_field(default=attr.NOTHING, *, factory=None, validators=None, description=None, exclude=False, eq=False, alias=None, converter=None, repr=True)

Create a field for an options class.

Attributes:

Name Type Description
default

The default value of the field.

factory

The factory to use for the field.

validators

The validators to use for the field. When provided, only the custom validators are used. When not provided or None, a basic validator is used that performs type checking for the following types: - Non-generic types: int, str, float, etc. - Union, Optional - Generic types: List, Dict, Tuple, Set, Callable, etc. Only the origin is checked. - User-defined classes

description

The description of the field.

exclude

Whether to exclude the field from serialization.

eq

Whether to include the field in the equality check.

alias

The alias of the field.

converter

The converter to use for the field.

repr

Whether to include the field in the representation.

options(cls=None, *, base_class=BaseOptions)

Decorator to register a class as an options class.

Parameters:

Name Type Description Default
cls Type | None

The class to decorate or None if using keyword arguments.

None
base_class Type[BaseOptions]

The base_class for the decorated class. Default is BaseOptions. Must be a subclass of BaseOptions.

BaseOptions

show_fields(opt)

Print the overview of the option fields.

task_options(cls=None, *, base_class=TaskOptions)

Decorator to make a class a task options class.

cls

The class to decorate

base_class: The base class for the decorated class, default is WorkflowOptions. Must be a subclass of TaskOptions.

workflow_options(cls=None, *, base_class=WorkflowOptions)

Decorator to make a class a workflow options class.

Parameters:

Name Type Description Default
cls Type | None

The class to decorate

None
base_class Type[WorkflowOptions]

The base class for the decorated class, default is WorkflowOptions. Must be a subclass of WorkflowOptions.

WorkflowOptions