OpenFactory Applications Schemas#
OpenFactory Application Schemas
This module defines Pydantic models and utility functions to parse, validate, and enrich application configuration files in OpenFactory. Application definitions include Docker image info, environment variables, and optional UNS metadata.
Key Components:#
OpenFactoryApp: Defines a single application including its UUID, Docker image, optional environment variables, and UNS metadata.
OpenFactoryAppsConfig: Validates a dictionary of application entries and ensures correct schema structure.
get_apps_from_config_file: Loads, validates, and enriches applications from a YAML file with UNS metadata.
Features:#
Supports UNS (Unified Namespace) enrichment through the AttachUNSMixin.
Restricts configuration fields with extra=”forbid” to ensure strict schema conformance.
- Supports storage backends, including:
LocalBackend: Bind-mount a local host directory into containers (for development).
NFSBackend: Mount an NFS share into containers with configurable mount options.
Provides utilities to load application configs from YAML with user-friendly error handling and notifications.
Ensures validated and enriched applications are returned as plain dictionaries.
YAML Example:#
apps:
scheduler:
uuid: "app-scheduler"
image: ghcr.io/openfactoryio/scheduler:v1.0.0
environment:
- ENV=production
uns:
location: building-a
workcenter: scheduler
storage:
type: nfs
server: deskfab.openfactory.com
remote_path: /nfs/deskfab
mount_point: /mnt
mount_options:
- ro
Usage:#
Use get_apps_from_config_file(path, uns_schema) to load and validate an application configuration YAML file, with automatic UNS enrichment.
This module is used by OpenFactory deployment tools and runtime components to ensure application configurations are consistent, valid, and semantically enriched.
- class openfactory.schemas.apps.OpenFactoryAppSchema(**data)[source]#
Bases:
AttachUNSMixin,BaseModelOpenFactory Application Schema.
- model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
storage:
Optional[Annotated[Union[NFSBackendConfig,LocalBackendConfig]]]#
- class openfactory.schemas.apps.OpenFactoryAppsConfig(**data)[source]#
Bases:
BaseModelSchema for OpenFactory application configurations loaded from YAML files.
This schema validates the structure of application configuration data.
- Example usage:
apps_config = OpenFactoryAppsConfig(apps=yaml_data['apps']) # or apps_config = OpenFactoryAppsConfig(**yaml_data)
- Parameters:
apps (dict) – Dictionary containing application configurations.
- Raises:
pydantic.ValidationError – If the input data does not conform to the expected schema.
-
apps:
Dict[str,OpenFactoryAppSchema]#
- property apps_dict#
Dictionary with all configured OpenFactory applications.
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- openfactory.schemas.apps.get_apps_from_config_file(apps_yaml_config_file, uns_schema)[source]#
Load, validate, and enrich OpenFactory application configurations from a YAML file using UNS metadata.
This function reads a YAML file containing OpenFactory application definitions, validates its content using the
OpenFactoryAppsConfigPydantic model, and augments each validated application entry with Unified Namespace (UNS) metadata derived from the provided schema.- Return type:
- Parameters:
- Returns:
Optional[Dict[str, OpenFactoryApp]] – A dictionary of validated and enriched application configurations, or None if validation fails.
Note
In case of validation errors, user notifications will be triggered and None will be returned.