Skip to content

pixano_inference.ray.config_loader

Configuration loader for Ray Serve deployments.

ConfigLoader(config_path=None)

Loader for model deployment configurations.

Python config files define a models list of ModelConfig:

.. code-block:: python

from pixano_inference.configs import ModelConfig, Sam2ImageParams

models = [
    ModelConfig(
        name="sam2-image",
        model_class="Sam2ImageModel",
        model_params=Sam2ImageParams(path="facebook/sam2-hiera-base-plus"),
    ),
]

Parameters:

Name Type Description Default
config_path str | Path | None

Path to the configuration file (.py).

None
Source code in pixano_inference/ray/config_loader.py
def __init__(self, config_path: str | Path | None = None) -> None:
    """Initialize the config loader.

    Args:
        config_path: Path to the configuration file (.py).
    """
    self._config_path = Path(config_path) if config_path is not None else None

load()

Load model deployment configurations from the config file.

Dispatches to the appropriate loader based on file extension.

Returns:

Type Description
list[ModelDeploymentConfig]

List of model deployment configurations.

Raises:

Type Description
FileNotFoundError

If the config file does not exist.

ValueError

If the config is invalid or has an unsupported extension.

Source code in pixano_inference/ray/config_loader.py
def load(self) -> list[ModelDeploymentConfig]:
    """Load model deployment configurations from the config file.

    Dispatches to the appropriate loader based on file extension.

    Returns:
        List of model deployment configurations.

    Raises:
        FileNotFoundError: If the config file does not exist.
        ValueError: If the config is invalid or has an unsupported extension.
    """
    config_path = self._config_path
    if config_path is None:
        return []

    if not config_path.exists():
        raise FileNotFoundError(f"Config file not found: {config_path}")

    suffix = config_path.suffix.lower()
    if suffix not in _PYTHON_EXTENSIONS:
        raise ValueError(
            f"Unsupported config file extension '{suffix}'. Only Python (.py) config files are supported."
        )
    return self._load_python(config_path)