diff --git a/dvc/dependency/param.py b/dvc/dependency/param.py index eb4faf176..f5ce0a5fb 100644 --- a/dvc/dependency/param.py +++ b/dvc/dependency/param.py @@ -39,12 +39,13 @@ class ParamsDependency(Dependency): def __init__(self, stage, path, params=None, repo=None): self.params = list(params) if params else [] - info = ( - {self.PARAM_PARAMS: params} if isinstance(params, dict) else None - ) + hash_info = HashInfo() + if isinstance(params, dict): + hash_info = HashInfo(self.PARAM_PARAMS, params) repo = repo or stage.repo path = path or os.path.join(repo.root_dir, self.DEFAULT_PARAMS_FILE) - super().__init__(stage, path, info=info, repo=repo) + super().__init__(stage, path, repo=repo) + self.hash_info = hash_info def dumpd(self): ret = super().dumpd() diff --git a/dvc/fs/git.py b/dvc/fs/git.py index a80e3ced1..f1fc6ddc2 100644 --- a/dvc/fs/git.py +++ b/dvc/fs/git.py @@ -15,6 +15,7 @@ class GitFileSystem(FileSystem): # pylint:disable=abstract-method """Proxies the repo file access methods to Git objects""" protocol = "local" + PARAM_CHECKSUM = "md5" def __init__( self, diff --git a/dvc/output.py b/dvc/output.py index f90e11b27..def18eb2d 100644 --- a/dvc/output.py +++ b/dvc/output.py @@ -330,7 +330,6 @@ class Output: # should be absolute and don't contain remote:// refs. self.stage = stage self.meta = meta - self.hash_info = HashInfo.from_dict(info) self.use_cache = False if self.IS_DEPENDENCY else cache self.metric = False if self.IS_DEPENDENCY else metric self.plot = False if self.IS_DEPENDENCY else plot @@ -350,6 +349,16 @@ class Output: ) self.meta.version_id = version_id + if self.is_in_repo: + self.hash_name = "md5" + else: + self.hash_name = self.fs.PARAM_CHECKSUM + + self.hash_info = HashInfo( + name=self.hash_name, + value=getattr(self.meta, self.hash_name, None), + ) + def _parse_path(self, fs, fs_path): parsed = urlparse(self.def_path) if ( @@ -440,15 +449,13 @@ class Output: def _get_hash_meta(self): if self.use_cache: odb = self.odb - name = self.odb.fs.PARAM_CHECKSUM else: odb = self.repo.odb.local - name = self.fs.PARAM_CHECKSUM _, meta, obj = build( odb, self.fs_path, self.fs, - name, + self.hash_name, ignore=self.dvcignore, dry_run=not self.use_cache, ) @@ -579,7 +586,7 @@ class Output: self.repo.odb.local, self.fs_path, self.fs, - self.fs.PARAM_CHECKSUM, + self.hash_name, ignore=self.dvcignore, dry_run=True, ) @@ -596,7 +603,7 @@ class Output: self.odb, self.fs_path, self.fs, - self.odb.fs.PARAM_CHECKSUM, + self.hash_name, ignore=self.dvcignore, ) self.hash_info = self.obj.hash_info @@ -638,7 +645,7 @@ class Output: self.odb, filter_info or self.fs_path, self.fs, - self.odb.fs.PARAM_CHECKSUM, + self.hash_name, ignore=self.dvcignore, ) otransfer( @@ -667,7 +674,7 @@ class Output: self.odb, self.fs_path, self.fs, - self.odb.fs.PARAM_CHECKSUM, + self.hash_name, ignore=self.dvcignore, ) save_obj = save_obj.filter(prefix) @@ -1048,7 +1055,7 @@ class Output: other = out.dumpd() ignored = [ - self.fs.PARAM_CHECKSUM, + self.hash_name, Meta.PARAM_SIZE, Meta.PARAM_NFILES, ] diff --git a/dvc/stage/loader.py b/dvc/stage/loader.py index 8d498e471..ca9a62038 100644 --- a/dvc/stage/loader.py +++ b/dvc/stage/loader.py @@ -69,7 +69,8 @@ class StageLoader(Mapping): info = info.copy() info.pop("path", None) item.meta = Meta.from_dict(info) - item.hash_info = HashInfo.from_dict(info) + hash_value = getattr(item.meta, item.hash_name, None) + item.hash_info = HashInfo(item.hash_name, hash_value) @classmethod def load_stage(cls, dvcfile, name, stage_data, lock_data=None): diff --git a/setup.cfg b/setup.cfg index 6d6f1248b..2d2af511f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -66,7 +66,7 @@ install_requires = dvc-render==0.0.10 dvc-task==0.1.2 dvclive>=0.10.0 - dvc-data==0.6.1 + dvc-data==0.6.3 dvc-http==2.19.1 hydra-core>=1.1.0 diff --git a/tests/func/test_import_url.py b/tests/func/test_import_url.py index 8c6cd09c7..50dcf881c 100644 --- a/tests/func/test_import_url.py +++ b/tests/func/test_import_url.py @@ -281,8 +281,7 @@ def test_import_url_no_download(tmp_dir, dvc, local_workspace): assert not dst.exists() out = stage.outs[0] - assert out.hash_info.value is None - assert out.hash_info.name is None + assert not out.hash_info assert out.meta.size is None status = dvc.status() diff --git a/tests/unit/output/test_output.py b/tests/unit/output/test_output.py index fb728124e..bcf821098 100644 --- a/tests/unit/output/test_output.py +++ b/tests/unit/output/test_output.py @@ -91,6 +91,7 @@ def test_get_used_objs(exists, expected_message, mocker, caplog): stage.repo.dvcignore, "check_ignore", return_value=_no_match("path") ) stage.repo.fs.version_aware = False + stage.repo.fs.PARAM_CHECKSUM = "md5" output = Output(stage, "path")