pyrolab.configure.ServiceConfiguration

pyrolab.configure.ServiceConfiguration#

class ServiceConfiguration(_env_file: DotenvType | None = '<object object>', _env_file_encoding: str | None = None, _env_nested_delimiter: str | None = None, _secrets_dir: StrPath | None = None, *, module: str, classname: str, parameters: Dict[str, Any] = {}, description: str = '', instancemode: str = 'session', daemon: str = 'default', nameservers: List[str] = [])[source]#

Bases: BaseSettings, PyroConfigMixin, YAMLMixin

Groups together information about a PyroLab service.

Includes connection parameters for autoconnect(). Services defined in other modules or libaries can also be included here, so long as the module can be found by the Python environment.

Parameters:
modulestr

The PyroLab module the class belongs to, as a string.

classnamestr

The classname of the object to be registered, as a string.

parametersDict[str, Any]

A dictionary of parameters passed to the object’s connect() function when autoconnect() is invoked.

descriptionstr

Description string for providing more information about the device. Will be displayed in the nameserver.

instancemodestr, optional

The mode of the object to be created. See Service.set_behavior(). Default is session.

serverstr, optional

The name of the daemon configuration to register the service with. Default is default.

nameserversList[str], optional

A list of nameservers to register the service with. Default is [] (no registration).

Examples

The following is an example of a valid configuration file “services” section. Keys not defined assume the default values.

services:
    asgard.wolverine:
        module: pyrolab.drivers.motion.prm1z8
        classname: PRM1Z8
        parameters:
            - serialno: 27003366
        description: Rotational motion
        instancemode: single
        daemon: lockable
        nameservers:
            - production
    asgard.hulk:
        module: pyrolab.drivers.motion.z825b
        classname: Z825B
        parameters:
            - serialno: 27003497
        description: Longitudinal motion
        instancemode: single
        daemon: lockable
        nameservers:
            - production

Methods

construct([_fields_set])

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data.

copy(*[, include, exclude, update, deep])

Duplicate a model, optionally choose which fields to include, exclude and change.

dict(*[, include, exclude, by_alias, ...])

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

from_file(filename)

Loads a configuration from a YAML file.

from_yaml(yaml)

Loads a YAML representation of the configuration.

json(*[, include, exclude, by_alias, ...])

Generate a JSON representation of the model, include and exclude arguments as per dict().

update_forward_refs(**localns)

Try to update ForwardRefs on fields based on this Model, globalns and localns.

update_pyro_config([values])

Sets all key-value attributes that are Pyro5 configuration options.

yaml([sort_keys, default_flow_style, ...])

Returns a YAML representation of the configuration.

Config

from_orm

parse_file

parse_obj

parse_raw

schema

schema_json

validate