dvcfs: add basic fsid

Implements fsspec's fsid https://github.com/fsspec/filesystem_spec/pull/1122

Required for #9904
This commit is contained in:
Ruslan Kuprieiev
2023-09-07 04:13:56 +03:00
parent aa9636e2ae
commit 1710e379f5
+13
View File
@@ -162,6 +162,15 @@ class _DVCFileSystem(AbstractFileSystem): # pylint:disable=abstract-method
if hasattr(repo, "dvc_dir"):
self._datafss[key] = DataFileSystem(index=repo.index.data["repo"])
@functools.cached_property
def fsid(self) -> str:
from fsspec.utils import tokenize
return "dvcfs_" + tokenize(
self.repo.url or self.repo.root_dir,
self.repo.get_rev() if self.repo.scm else None,
)
def _get_key(self, path: "StrPath") -> Key:
path = os.fspath(path)
parts = self.repo.fs.path.relparts(path, self.repo.root_dir)
@@ -413,6 +422,10 @@ class DVCFileSystem(FileSystem):
def fs(self) -> "_DVCFileSystem":
return _DVCFileSystem(**self.fs_args)
@property
def fsid(self) -> str:
return self.fs.fsid
def isdvc(self, path, **kwargs) -> bool:
return self.fs.isdvc(path, **kwargs)