local_environment.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. """Dummy local environment implementation. This is the default environment."""
  2. from __future__ import annotations
  3. from typing import Any
  4. from wandb.sdk.launch.errors import LaunchError
  5. from .abstract import AbstractEnvironment
  6. class LocalEnvironment(AbstractEnvironment):
  7. """Local environment class."""
  8. def __init__(self) -> None:
  9. """Initialize a local environment by doing nothing."""
  10. @classmethod
  11. def from_config(cls, config: dict[str, dict[str, Any] | str]) -> LocalEnvironment:
  12. """Create a local environment from a config.
  13. Arguments:
  14. config (dict): The config. This is ignored.
  15. Returns:
  16. LocalEnvironment: The local environment.
  17. """
  18. return cls()
  19. async def verify(self) -> None:
  20. """Verify that the local environment is configured correctly."""
  21. raise LaunchError("Attempted to verify LocalEnvironment.")
  22. async def verify_storage_uri(self, uri: str) -> None:
  23. """Verify that the storage URI is configured correctly.
  24. Arguments:
  25. uri (str): The storage URI. This is ignored.
  26. """
  27. raise LaunchError("Attempted to verify storage uri for LocalEnvironment.")
  28. async def upload_file(self, source: str, destination: str) -> None:
  29. """Upload a file from the local filesystem to storage in the environment.
  30. Arguments:
  31. source (str): The source file. This is ignored.
  32. destination (str): The destination file. This is ignored.
  33. """
  34. raise LaunchError("Attempted to upload file for LocalEnvironment.")
  35. async def upload_dir(self, source: str, destination: str) -> None:
  36. """Upload the contents of a directory from the local filesystem to the environment.
  37. Arguments:
  38. source (str): The source directory. This is ignored.
  39. destination (str): The destination directory. This is ignored.
  40. """
  41. raise LaunchError("Attempted to upload directory for LocalEnvironment.")
  42. async def get_project(self) -> str:
  43. """Get the project of the local environment.
  44. Returns: An empty string.
  45. """
  46. raise LaunchError("Attempted to get project for LocalEnvironment.")