out: move restore_fields logic into Output

This commit is contained in:
Peter Rowlands
2022-11-21 19:18:41 +09:00
committed by Peter Rowlands (변기호)
parent 77ae4aa92e
commit 014d149512
2 changed files with 10 additions and 5 deletions
+6
View File
@@ -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,
+4 -5
View File
@@ -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):