mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-19 15:28:28 +01:00
out: move restore_fields logic into Output
This commit is contained in:
committed by
Peter Rowlands (변기호)
parent
77ae4aa92e
commit
014d149512
@@ -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,
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user