Option¶
- class momotor.options.option.OptionDefinition(name, type=None, doc=None, required=False, multiple=False, all=False, location=None, domain=None, default=<object object>, enable=True)¶
Definition of an option.
Options are provided by steps, recipes, configs and products. When resolving the option to a value, these are inspected based on the
locationattribute. Depending on the other settings likemultipleandrequiredone or more option values are returned when resolving the option.- resolve(providers, subdomains=None)¶
Resolve the value of this option by inspecting the options of the providers.
Sub-domains to look for can be specified for each provider. Options including a specified sub-domain take priority over options without the sub-domain.
If the subdomains option is not provided, a default is generated from the providers.task_id value if this is specified. To disable the default subdomains, set subdomains to False
- Parameters
providers (
Providers) – The providerssubdomains (
Union[Dict[Literal[‘step’, ‘recipe’, ‘config’, ‘product’],Union[str,Sequence[Optional[str]],None]],bool,None]) – For each provider, a sequence of subdomains to take into account when looking for options. Merged withdomain. Missing values and empty sequences are interpreted as containingNone. If not set orTrue, generates subdomains based onproviders.task_id. Set toFalseto disable generation of subdomains.
- Return type
- Returns
The resolved option value. A tuple of values if
multipleis True.
- all: bool = False¶
When
multipleis True,resolve()will match the first provider inlocationthat defines an option with the correctnameanddomain. Setallto True to resolve all matching options of all providers listed inlocation. Has no effect whenmultipleis False.
- default: Any = <object object>¶
The default value if the option is not provided by any provider.
- domain: Optional[str] = None¶
The domain of the option: Momotor defines the following values for
domain:checklet: (Default) These options are used by checklets.
step: Options used for executing and scheduling the step.
x-…: “Experimental”, or private use domains
Domain names starting with x- can be used for private use cases. All other domain names are reserved for use by Momotor in the future.
Cannot have a subdomain. Required (but can be provided through the name argument)
- enable: bool = True¶
If False this OptionDefinition will be disabled (i.e. ignored as if it was not listed)
- property fullname: momotor.options.option.OptionNameDomain¶
Full name, including domain
- Return type
- location: Optional[Union[str, Sequence[str]]] = None¶
The names and order of the providers
resolve()looks for the options. Can be provided as a comma separated string, or as a sequence of strings. Required. CheckletBaseMeta provides the default. When accessing, will always be a sequence
- multiple: bool = False¶
This option can be provided multiple times. If True,
resolve()will return a FilterableTuple of matched options. If False,resolve()will return a single value, or throw aValueErrorif multiple options match. Default:False
- name: Union[momotor.options.option.OptionNameDomain, str]¶
Name of the option. Required
- required: bool = False¶
This option is required. If the option is not defined by any of the providers,
resolve()will throw aValueErrorexception: Default:False
- type: Optional[Literal['str', 'bool', 'int', 'float']] = None¶
Expected type of the option. Optional. If not set, the type as given by the <option> node is used as-is. Allowed values:
str,bool,intandfloat