INNER CODE UNIT · Python

assert_environ_exists

operatorai/modelstore · modelstore/utils/cli.py:79

def assert_environ_exists(storage_type: str, keys: dict):
    """Checks that environment variables that are required to use the modelstore CLI
    are set. If not, logs the failure and exits."""
    missing_required_keys = [k for k in keys.get("required", []) if k not in os.environ]
    missing_optional_keys = [k for k in keys.get("optional", []) if k not in os.environ]
    if len(missing_required_keys) != 0:
        failure(
            f"❌ Failed to create {storage_type} modelstore.\nYour environment is missing:"
        )
        for k in missing_required_keys:
            failure(f"- {k} (required)")
        for k in missing_optional_keys:
            failure(f"- {k} (optional)")
        sys.exit(1)


def model_store_from_env() -> ModelStore:
    """Builds a modelstore instance from environment variables."""

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…