anon.py 939 B

1234567891011121314151617181920212223242526272829
  1. from typing_extensions import Self
  2. from wandb.docker import is_docker_installed
  3. from wandb.sdk.launch.utils import docker_image_exists
  4. from .abstract import AbstractRegistry
  5. class AnonynmousRegistry(AbstractRegistry):
  6. def __init__(self, uri: str) -> None:
  7. """Initialize the registry."""
  8. self.uri = uri
  9. async def get_username_password(self) -> tuple[str, str]:
  10. """Get the username and password for the registry."""
  11. raise NotImplementedError("Anonymous registry does not require authentication")
  12. async def get_repo_uri(self) -> str:
  13. return self.uri
  14. async def check_image_exists(self, image_uri: str) -> bool:
  15. """Check if an image exists in the registry."""
  16. if not is_docker_installed():
  17. return False
  18. return docker_image_exists(image_uri)
  19. @classmethod
  20. def from_config(cls, config: dict) -> Self:
  21. return cls(uri=config["uri"])