Skip to content

telemetry_config

orchard.core.config.telemetry_config

Telemetry & Filesystem Configuration.

Declarative schema for filesystem orchestration and logging policy. Resolves paths, configures logging cadence and verbosity, and exports environment-agnostic manifests.

TelemetryConfig

Bases: BaseModel

Declarative manifest for telemetry, logging, and filesystem strategy.

Manages experiment artifacts location, logging behavior, and path portability across environments. Frozen after creation for immutability.

Attributes:

Name Type Description
output_dir ValidatedPath

Validated absolute path to outputs directory.

log_interval LogFrequency

Epoch logging cadence (default: 10).

log_level LogLevel

Logging verbosity (DEBUG, INFO, WARNING, ERROR, CRITICAL).

handle_empty_config(data) classmethod

Handle empty YAML section by returning default dict.

When YAML contains 'telemetry:' with no values, Pydantic receives None. This validator converts None to empty dict, allowing field defaults to apply correctly.

Parameters:

Name Type Description Default
data Any

Raw input data from YAML or dict.

required

Returns:

Type Description
Any

Empty dict if data is None, otherwise the original data.

Source code in orchard/core/config/telemetry_config.py
@model_validator(mode="before")
@classmethod
def handle_empty_config(cls, data: Any) -> Any:
    """
    Handle empty YAML section by returning default dict.

    When YAML contains 'telemetry:' with no values, Pydantic receives None.
    This validator converts None to empty dict, allowing field defaults
    to apply correctly.

    Args:
        data: Raw input data from YAML or dict.

    Returns:
        Empty dict if data is None, otherwise the original data.
    """
    if data is None:
        return {}
    return data

to_portable_dict()

Convert to portable dictionary with environment-agnostic paths.

Transforms absolute paths to project-relative paths (e.g., '/home/user/project/dataset' -> './dataset') to prevent host-specific filesystem leakage in exported configs.

Returns:

Type Description
dict[str, Any]

Dictionary with all paths converted to relative strings.

Source code in orchard/core/config/telemetry_config.py
def to_portable_dict(self) -> dict[str, Any]:
    """
    Convert to portable dictionary with environment-agnostic paths.

    Transforms absolute paths to project-relative paths (e.g.,
    '/home/user/project/dataset' -> './dataset') to prevent
    host-specific filesystem leakage in exported configs.

    Returns:
        Dictionary with all paths converted to relative strings.
    """
    data = self.model_dump()

    for field in ("output_dir",):
        full_path = Path(data[field])
        if full_path.is_relative_to(PROJECT_ROOT):
            relative_path = full_path.relative_to(PROJECT_ROOT)
            data[field] = f"./{relative_path}"
        else:
            data[field] = str(full_path)

    return data