napistu.gcs.assets

Pydantic models for GCS assets configuration.

Classes

GCSAsset(*, file[, subassets, versions])

Pydantic model for a single GCS asset configuration.

GCSAssets(*, project, bucket, assets)

Pydantic model for GCS assets configuration.

class napistu.gcs.assets.GCSAsset(*, file: str, subassets: dict[str, str] | None = None, public_url: str, versions: dict[str, str] | None = None)

Bases: BaseModel

Pydantic model for a single GCS asset configuration.

classmethod validate_public_url(v: str) str

Validate that public_url is a valid URL.

classmethod validate_versions(v: dict[str, str] | None) dict[str, str] | None

Validate that all version URLs are valid.

_abc_impl = <_abc._abc_data object>
file: str
model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

public_url: str
subassets: dict[str, str] | None
versions: dict[str, str] | None
class napistu.gcs.assets.GCSAssets(*, project: str, bucket: str, assets: dict[str, GCSAsset])

Bases: BaseModel

Pydantic model for GCS assets configuration.

classmethod from_dict(assets_dict: dict | SimpleNamespace) GCSAssets

Create a GCSAssets instance from a dictionary or SimpleNamespace.

Parameters:

assets_dict (dict | SimpleNamespace) – Dictionary or SimpleNamespace containing ‘PROJECT’/’project’, ‘BUCKET’/’bucket’, and ‘ASSETS’/’assets’ keys/attributes. The ‘ASSETS’ key should map to a dictionary of asset names to asset configurations.

Returns:

A validated GCSAssets instance.

Return type:

GCSAssets

Examples

>>> from napistu.gcs.constants import GCS_ASSETS
>>> gcs_assets = GCSAssets.from_dict(GCS_ASSETS)
classmethod validate_assets(v: dict[str, GCSAsset]) dict[str, GCSAsset]

Validate that assets dictionary is not empty.

_abc_impl = <_abc._abc_data object>
assets: dict[str, GCSAsset]
bucket: str
model_config = {'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

project: str