Skip to content

Commit 1530d72

Browse files
committed
dvcfs: add basic fsid
Implements fsspec's fsid fsspec/filesystem_spec#1122 Required for #9904
1 parent aa9636e commit 1530d72

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

dvc/fs/dvc.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,15 @@ def _getcwd():
162162
if hasattr(repo, "dvc_dir"):
163163
self._datafss[key] = DataFileSystem(index=repo.index.data["repo"])
164164

165+
@functools.cached_property
166+
def fsid(self) -> str:
167+
from fsspec.utils import tokenize
168+
169+
return "dvcfs_" + tokenize(
170+
self.repo.url or self.repo.root_dir,
171+
self.repo.get_rev() if self.repo.scm else None,
172+
)
173+
165174
def _get_key(self, path: "StrPath") -> Key:
166175
path = os.fspath(path)
167176
parts = self.repo.fs.path.relparts(path, self.repo.root_dir)
@@ -413,6 +422,10 @@ def _prepare_credentials(self, **config) -> Dict[str, Any]:
413422
def fs(self) -> "_DVCFileSystem":
414423
return _DVCFileSystem(**self.fs_args)
415424

425+
@property
426+
def fsid(self) -> str:
427+
return self.fs.fsid
428+
416429
def isdvc(self, path, **kwargs) -> bool:
417430
return self.fs.isdvc(path, **kwargs)
418431

0 commit comments

Comments
 (0)