brancher: add trace when switching filesystem (#9022)

brancher: add trace info when switching filesystem
This commit is contained in:
skshetry
2023-02-14 15:27:18 +05:45
committed by GitHub
parent e73d662686
commit eff775c760
2 changed files with 10 additions and 7 deletions
+3 -6
View File
@@ -583,17 +583,14 @@ class Repo:
if self._data_index is not None:
self._data_index.close()
def _reset_cached_indecies(self):
def _reset(self):
self.scm._reset() # pylint: disable=protected-access
self.state.close()
self.__dict__.pop("index", None)
self.__dict__.pop("dvcignore", None)
self.__dict__.pop("dvcfs", None)
self.__dict__.pop("datafs", None)
def _reset(self):
self.state.close()
self.scm._reset() # pylint: disable=protected-access
self._reset_cached_indecies()
def __enter__(self):
return self
+7 -1
View File
@@ -1,7 +1,10 @@
import logging
from typing import Optional
from dvc.scm import iter_revs
logger = logging.getLogger(__name__)
def brancher( # noqa: E302
self,
@@ -60,6 +63,7 @@ def brancher( # noqa: E302
scm = self.scm
logger.trace("switching fs to workspace") # type: ignore[attr-defined]
self.fs = LocalFileSystem(url=self.root_dir)
yield "workspace"
@@ -82,7 +86,9 @@ def brancher( # noqa: E302
from dvc.fs import GitFileSystem
for sha, names in found_revs.items():
self._reset_cached_indecies() # pylint: disable=W0212
logger.trace( # type: ignore[attr-defined]
"switching fs to revision %s [%s]", sha[:7], ", ".join(names)
)
self.fs = GitFileSystem(scm=scm, rev=sha)
self.root_dir = self.fs.path.join("/", *repo_root_parts)