OpenFactory Devices Schemas#
Pydantic schemas for validating OpenFactory OpenFactory Adapter, Agent, Supervisor and Device definitions.
- class openfactory.schemas.devices.Adapter(**data)[source]#
Bases:
BaseModelOpenFactory Adapter Schema.
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod validate_adapter(values)[source]#
Validates the adapter configuration.
- Return type:
- Parameters:
values (Dict) – Dictionary of values to validate.
- Returns:
Dict – Validated values.
- Raises:
ValueError – If ‘ip’ or ‘image’ is missing or incorrectly defined.
- class openfactory.schemas.devices.Agent(**data)[source]#
Bases:
BaseModelOpenFactory Agent Schema.
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod validate_agent(values)[source]#
Validates the agent configuration.
- Return type:
- Parameters:
values (Dict) – Dictionary of values to validate.
- Returns:
Dict – Validated values.
- Raises:
ValueError – If ‘device_xml’ or ‘adapter’ is missing or incorrectly defined.
- class openfactory.schemas.devices.Deploy(**data)[source]#
Bases:
BaseModelDeploy Schema.
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class openfactory.schemas.devices.Device(**data)[source]#
Bases:
BaseModelOpenFactory Device Schema.
- __init__(**data)[source]#
Initialize the Device model.
- Parameters:
**data (Dict) – Keyword arguments to initialize the model.
- model_config: ClassVar[ConfigDict] = {'extra': 'ignore'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
supervisor:
Optional[Supervisor]#
- class openfactory.schemas.devices.DevicesConfig(**data)[source]#
Bases:
BaseModelSchema for OpenFactory device configurations loaded from YAML files.
This schema validates the structure of device configurations.
- Example usage:
devices = DevicesConfig(devices=yaml_data['devices']) # or devices = DevicesConfig(**yaml_data)
- Parameters:
devices (dict) – Dictionary of device configurations.
- Raises:
pydantic.ValidationError – If the input data does not conform to the expected schema.
- property devices_dict#
Dictionary with all configured devices.
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- validate_devices()[source]#
Validates the devices configuration.
- Return type:
- Raises:
ValueError – If the devices configuration is invalid.
- class openfactory.schemas.devices.InfluxDB(**kwargs)[source]#
Bases:
BaseModelInfluxDB configuration.
- __init__(**kwargs)[source]#
Initialize the InfluxDB model.
- Parameters:
**kwargs (Dict) – Keyword arguments to initialize the model.
- Raises:
ValueError – If ‘url’ or ‘token’ is not provided and not defined in the configuration.
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class openfactory.schemas.devices.Placement(**data)[source]#
Bases:
BaseModelPlacement Schema.
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class openfactory.schemas.devices.Resources(**data)[source]#
Bases:
BaseModelResources Schema.
-
limits:
ResourcesDefinition#
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
reservations:
ResourcesDefinition#
-
limits:
- class openfactory.schemas.devices.ResourcesDefinition(**data)[source]#
Bases:
BaseModelResources Definition Schema.
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class openfactory.schemas.devices.Supervisor(**data)[source]#
Bases:
BaseModelOpenFactory Supervisor Schema.
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- openfactory.schemas.devices.get_devices_from_config_file(devices_yaml_config_file, uns_schema)[source]#
Load, validate, and enrich device configurations from a YAML file using UNS metadata.
This function reads a YAML file containing device definitions, validates its content using the
DevicesConfigPydantic model, and augments each validated device entry with Unified Namespace (UNS) metadata derived from the provided schema.- Return type:
- Parameters:
- Returns:
Optional[Dict[str, Device]] –
- A dictionary of validated and enriched device configurations,
or None if validation fails.
Note
In case of validation errors, user notifications will be triggered and None will be returned.