diff --git a/dvc/output.py b/dvc/output.py index 031edc31b..37f763fe6 100644 --- a/dvc/output.py +++ b/dvc/output.py @@ -1197,6 +1197,12 @@ class Output: def is_plot(self) -> bool: return bool(self.plot) + def restore_fields(self, other: "Output"): + """Restore attributes that need to be preserved when serialized.""" + self.annot = other.annot + self.remote = other.remote + self.can_push = other.can_push + META_SCHEMA = { Meta.PARAM_SIZE: int, diff --git a/dvc/stage/__init__.py b/dvc/stage/__init__.py index 26346ea08..1d47840e5 100644 --- a/dvc/stage/__init__.py +++ b/dvc/stage/__init__.py @@ -113,12 +113,11 @@ def restore_fields(stage): stage.meta = old.meta stage.desc = old.desc - old_fields = { - out.def_path: (out.annot, out.remote, out.can_push) for out in old.outs - } + old_outs = {out.def_path: out for out in old.outs} for out in stage.outs: - if out_fields := old_fields.get(out.def_path, None): - out.annot, out.remote, out.can_push = out_fields + old_out = old_outs.get(out.def_path, None) + if old_out is not None: + out.restore_fields(old_out) class Stage(params.StageParams):