From 29cb39cc0551cb8a133cc9f3c17bda211618b670 Mon Sep 17 00:00:00 2001 From: PozzettiAndrea Date: Tue, 16 Jun 2026 15:47:27 +0200 Subject: [PATCH] Load Mesh Batch: ComfyUI progress bar during loading Lazy-imported comfy.utils.ProgressBar, advanced per mesh in both the process-pool and serial paths. Co-Authored-By: Claude Opus 4.8 --- nodes/io/load_mesh_batch.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/nodes/io/load_mesh_batch.py b/nodes/io/load_mesh_batch.py index 4e7d340c..d4d2da23 100644 --- a/nodes/io/load_mesh_batch.py +++ b/nodes/io/load_mesh_batch.py @@ -172,24 +172,38 @@ class LoadMeshBatch(io.ComfyNode): else: log.warning("[%d/%d] Failed to load %s", i, total, filename) + # ComfyUI UI progress bar (lazy import so it never breaks the metadata scan) + def _mk_pbar(): + try: + from comfy.utils import ProgressBar + return ProgressBar(total) + except Exception: + return None + loaded_meshes = [] used_parallel = False if use_multithreading and total > 1: from concurrent.futures import ProcessPoolExecutor workers = min(total, (os.cpu_count() or 4)) log.info("Loading %d meshes across %d processes", total, workers) + pbar = _mk_pbar() try: with ProcessPoolExecutor(max_workers=workers) as ex: for i, m in enumerate(ex.map(_load_mesh_worker, paths), 1): _record(i, mesh_files[i - 1], m, loaded_meshes) + if pbar is not None: + pbar.update(1) used_parallel = True except Exception as e: log.warning("Parallel load failed (%s); falling back to serial", e) loaded_meshes = [] if not used_parallel: + pbar = _mk_pbar() for i, (filename, path) in enumerate(zip(mesh_files, paths), 1): _record(i, filename, _load_mesh_worker(path), loaded_meshes) + if pbar is not None: + pbar.update(1) if len(loaded_meshes) == 0: raise ValueError(f"Failed to load any meshes from folder: {full_folder_path}")