artifact_instance_cache.py 602 B

123456789101112131415161718
  1. """Recent Artifact storage.
  2. Artifacts are registered in the cache to ensure they won't be immediately garbage
  3. collected and can be retrieved by their ID.
  4. """
  5. from __future__ import annotations
  6. from typing import TYPE_CHECKING
  7. from wandb.sdk.lib.capped_dict import CappedDict
  8. if TYPE_CHECKING:
  9. from wandb.sdk.artifacts.artifact import Artifact
  10. # There is nothing special about the artifact cache, it's just a global capped dict.
  11. artifact_instance_cache: dict[str, Artifact] = CappedDict(100) # Cached by artifact ID
  12. artifact_instance_cache_by_client_id: dict[str, Artifact] = CappedDict(100)