manifest.py 965 B

123456789101112131415161718192021222324252627
  1. from typing import Any, Dict, Literal, final
  2. from wandb._pydantic import field_validator, to_camel
  3. from wandb.sdk.artifacts.artifact_manifest_entry import ArtifactManifestEntry
  4. from .base_model import ArtifactsBase
  5. from .storage import StoragePolicyConfig
  6. @final
  7. class ArtifactManifestV1Data(ArtifactsBase, alias_generator=to_camel):
  8. """Data model for the v1 artifact manifest."""
  9. version: Literal[1]
  10. contents: Dict[str, ArtifactManifestEntry]
  11. storage_policy: str
  12. storage_policy_config: StoragePolicyConfig
  13. @field_validator("contents", mode="before")
  14. def _validate_entries(cls, v: Any) -> Any:
  15. # The dict keys should be the `entry.path` values, but they've
  16. # historically been dropped from the JSON objects. This restores
  17. # them on instantiation.
  18. # Pydantic will handle converting dicts -> ArtifactManifestEntries.
  19. return {path: {**dict(entry), "path": path} for path, entry in v.items()}