from zenml.enums import StackComponentType
from zenml.stack import StackComponent
PathType = Union[bytes, str]
class BaseArtifactStore(StackComponent):
"""Base class for all ZenML artifact stores."""
# --- Instance configuration ---
path: str # The root path of the artifact store.
# --- Class variables ---
TYPE: ClassVar[StackComponentType] = StackComponentType.ARTIFACT_STORE
SUPPORTED_SCHEMES: ClassVar[Set[str]]
def open(self, name: PathType, mode: str = "r") -> Any:
"""Open a file at the given path."""
self, src: PathType, dst: PathType, overwrite: bool = False
"""Copy a file from the source to the destination."""
def exists(self, path: PathType) -> bool:
"""Returns `True` if the given path exists."""
def glob(self, pattern: PathType) -> List[PathType]:
"""Return the paths that match a glob pattern."""
def isdir(self, path: PathType) -> bool:
"""Returns whether the given path points to a directory."""
def listdir(self, path: PathType) -> List[PathType]:
"""Returns a list of files under a given directory in the filesystem."""
def makedirs(self, path: PathType) -> None:
"""Make a directory at the given path, recursively creating parents."""
def mkdir(self, path: PathType) -> None:
"""Make a directory at the given path; parent directory must exist."""
def remove(self, path: PathType) -> None:
"""Remove the file at the given path. Dangerous operation."""
self, src: PathType, dst: PathType, overwrite: bool = False
"""Rename source file to destination file."""
def rmtree(self, path: PathType) -> None:
"""Deletes dir recursively. Dangerous operation."""
def stat(self, path: PathType) -> Any:
"""Return the stat descriptor for a given file path."""
onerror: Optional[Callable[..., None]] = None,
) -> Iterable[Tuple[PathType, List[PathType], List[PathType]]]:
"""Return an iterator that walks the contents of the given directory."""