joeygambino commited on
Commit
7cb131d
·
verified ·
1 Parent(s): 11e0767

AutoFinish preview_master: node waits for the worker (cas/hires routes) and shows the REAL master as its canvas preview; rtx mode auto-skips (deadlock guard)

Browse files
Files changed (1) hide show
  1. joyecho_autofinish.py +51 -1
joyecho_autofinish.py CHANGED
@@ -73,6 +73,17 @@ class JoyEcho_AutoFinish:
73
  "detail per frame. Ignored when the run produced "
74
  "shot_hires masters (those are used directly).",
75
  }),
 
 
 
 
 
 
 
 
 
 
 
76
  },
77
  }
78
 
@@ -84,7 +95,7 @@ class JoyEcho_AutoFinish:
84
 
85
  def run(self, images, enabled, master_name, scale_factor, quality,
86
  batch_size, shots_subdir="joyecho",
87
- upscale_mode="bicubic+cas (deterministic)"):
88
  if not enabled:
89
  return (images,)
90
  out_root = (folder_paths.get_output_directory()
@@ -114,6 +125,45 @@ class JoyEcho_AutoFinish:
114
  f"(scale {scale_factor}); upscale jobs will queue after this "
115
  f"item. Progress: {shots_dir}\\_autofinish_<stamp>.log",
116
  flush=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  return (images,)
118
 
119
 
 
73
  "detail per frame. Ignored when the run produced "
74
  "shot_hires masters (those are used directly).",
75
  }),
76
+ "preview_master": ("BOOLEAN", {
77
+ "default": True,
78
+ "tooltip": "Wait for the background worker and show the REAL "
79
+ "finished MASTER as this node's canvas preview "
80
+ "(the in-graph SaveVideo preview is a bit-starved "
81
+ "re-encode and lies about quality). Adds ~30-90s "
82
+ "after the render while the master is assembled. "
83
+ "Auto-disabled in rtx mode - the RTX job queues "
84
+ "behind this graph item, so waiting would "
85
+ "deadlock the queue.",
86
+ }),
87
  },
88
  }
89
 
 
95
 
96
  def run(self, images, enabled, master_name, scale_factor, quality,
97
  batch_size, shots_subdir="joyecho",
98
+ upscale_mode="bicubic+cas (deterministic)", preview_master=True):
99
  if not enabled:
100
  return (images,)
101
  out_root = (folder_paths.get_output_directory()
 
125
  f"(scale {scale_factor}); upscale jobs will queue after this "
126
  f"item. Progress: {shots_dir}\\_autofinish_<stamp>.log",
127
  flush=True)
128
+
129
+ # Optionally wait for the worker and preview the REAL master in-canvas.
130
+ # Never in rtx mode: the worker's RTX job queues behind THIS graph item,
131
+ # so blocking here would deadlock the queue. cas/hires routes are
132
+ # self-contained (ffmpeg only) and finish in seconds-to-minutes.
133
+ is_rtx = str(upscale_mode).lower().startswith("rtx")
134
+ if preview_master and not is_rtx:
135
+ import glob as _glob
136
+ import time as _time
137
+ t_spawn = _time.time()
138
+ deadline = t_spawn + 900
139
+ master, stable_size = None, -1
140
+ print("[JoyEcho] AutoFinish: waiting for the master to preview it "
141
+ "in-canvas (preview_master=True, up to 15 min)...", flush=True)
142
+ while _time.time() < deadline:
143
+ cands = [p for p in _glob.glob(os.path.join(shots_dir, "*_MASTER.mp4"))
144
+ if os.path.getmtime(p) >= t_spawn - 2]
145
+ if cands:
146
+ p = max(cands, key=os.path.getmtime)
147
+ sz = os.path.getsize(p)
148
+ if sz > 0 and sz == stable_size:
149
+ master = p
150
+ break
151
+ stable_size = sz
152
+ _time.sleep(2)
153
+ if master:
154
+ print(f"[JoyEcho] AutoFinish: master ready -> {master}", flush=True)
155
+ return {"ui": {"images": [{"filename": os.path.basename(master),
156
+ "subfolder": shots_subdir,
157
+ "type": "output"}],
158
+ "animated": (True,)},
159
+ "result": (images,)}
160
+ print("[JoyEcho] AutoFinish: master did not appear within the wait "
161
+ "window - check the _autofinish log; continuing without the "
162
+ "in-canvas preview.", flush=True)
163
+ elif preview_master and is_rtx:
164
+ print("[JoyEcho] AutoFinish: preview_master skipped in rtx mode "
165
+ "(the RTX job runs after this graph item; waiting would "
166
+ "deadlock the queue).", flush=True)
167
  return (images,)
168
 
169