From b3aa698cd496a8736d49bbf94c1de72d2c18568b Mon Sep 17 00:00:00 2001 From: skshetry <18718008+skshetry@users.noreply.github.com> Date: Wed, 25 Jan 2023 18:52:15 +0545 Subject: [PATCH] dumpd: serialize files at the end in .dvc files (#8879) --- dvc/output.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/dvc/output.py b/dvc/output.py index e202627e5..de75c4c0d 100644 --- a/dvc/output.py +++ b/dvc/output.py @@ -781,19 +781,13 @@ class Output: def dumpd(self, **kwargs): # noqa: C901 ret: Dict[str, Any] = {} - if ( + with_files = ( (not self.IS_DEPENDENCY or self.stage.is_import) and self.hash_info.isdir and (kwargs.get("with_files") or self.files is not None) - ): - obj = self.obj or self.get_obj() - if obj: - obj = cast("Tree", obj) - ret[self.PARAM_FILES] = [ - split_file_meta_from_cloud(f) - for f in obj.as_list(with_meta=True) - ] - else: + ) + + if not with_files: meta_d = self.meta.to_dict() meta_d.pop("isdir", None) ret.update(self.hash_info.to_dict()) @@ -838,6 +832,14 @@ class Output: if not self.can_push: ret[self.PARAM_PUSH] = self.can_push + if with_files: + obj = self.obj or self.get_obj() + if obj: + obj = cast("Tree", obj) + ret[self.PARAM_FILES] = [ + split_file_meta_from_cloud(f) + for f in obj.as_list(with_meta=True) + ] return ret def verify_metric(self):