Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.
The long waits while an install runs are split into visible steps with real counts
Bowen Xue930ccc9fbefa
diff --git a/freevideo_engine/bootstrap.py b/freevideo_engine/bootstrap.pyindex ba7395c..e36988f 100644--- a/freevideo_engine/bootstrap.py+++ b/freevideo_engine/bootstrap.py@@ -998,6 +998,8 @@ def setup_task(label):routes = {'official': 'official source', 'nju': 'Nanjing University mirror','tuna': 'Tsinghua mirror', 'ghfast': 'GitHub mirror','user-python': 'your Python mirror', 'user': 'your configured source'}+ # Python route retries append the route after the source.+ label = re.sub(r'-(?:direct|proxy)$', '', label)source = next((name for name in routes if label.endswith('-' + name)), None)key = label[:-(len(source) + 1)] if source else labelfor prefix in ('unified-', 'engine-', 'encoder-'):@@ -1098,7 +1100,8 @@ class Installer:from .runtime_libraries import damagedif ui is not None:prepare_step(ui, 'Checking the environment')- self.damaged_before = damaged(self.pythons['engine'])+ self.damaged_before = damaged(self.pythons['engine'], progress=(+ lambda done, total: prepare_step(ui, 'Checking the environment', done, total)) if ui is not None else None)# Moving a working installation to int8 checks the int8 kernels first# (execute), so a GPU that fails them keeps its configuration as it was.# With changed files that check cannot run; the one after installing still does.@@ -1304,6 +1307,7 @@ class Installer:raise RuntimeError(self.state.get('resource_guard', 'Installation cancelled.'))from .triton_compat import temporary_environmentenv = temporary_environment(self.root, env or self.env)+ env = dict(env, FREEVIDEO_INSTALL_PROGRESS='1')args, cwd = uv_file_arguments(args, cwd)with self.state_lock:index = len(self.state['steps'])@@ -1316,6 +1320,10 @@ class Installer:if label == 'models' and self.plan.get('local_models'):title, detail = 'Reuse models / download missing files', 'Import verified local models; source files stay in place'self.ui.begin(key, title, detail=str(log) if self.ui.verbose else detail)+ initial = ('Python downloading' if title == 'Install Python' else+ 'Environment creating' if title == 'Create Python environment' else '')+ if initial:+ self.ui.update(key, activity='note', name=initial, detail=initial)progress = LogProgress(log)parallel_tasks = set()models_step = label == 'models'@@ -1445,11 +1453,13 @@ class Installer:constraints=['-c', constraints_file(label, self.system)], check=check):returnfrom .runtime_libraries import damaged, reinstall_arguments- fresh = damaged(executable)+ fresh = self.check_runtime_libraries(executable, label)result = self.packages(label + '-torch', [*argv[:5], *reinstall_arguments(fresh), *argv[5:]], group)# Files linked from a changed uv cache arrive with a new environment.- if not fresh and damaged(executable):- result = self.packages(label + '-torch', [*argv[:5], *reinstall_arguments(damaged(executable)), *argv[5:]], group)+ if not fresh:+ changed = self.check_runtime_libraries(executable, label)+ if changed:+ result = self.packages(label + '-torch', [*argv[:5], *reinstall_arguments(changed), *argv[5:]], group)return resulttask(name + '-torch', torch_packages,(name + '-venv',), writer)@@ -1502,6 +1512,18 @@ class Installer:tasks['models']['after'] = ('package-cache',)return tasks, pythons, comfy+ def check_runtime_libraries(self, python, role):+ from .runtime_libraries import damaged+ key = role + '-runtime-libraries'+ self.ui.begin(key, 'Runtime libraries verifying')+ def progress(done, total):+ self.ui.update(key, activity='count', name='Runtime libraries verifying',+ detail='Runtime libraries verifying', done=done, total=total, unit='items')+ try:+ return damaged(python, progress=progress)+ finally:+ self.ui.end(key)+def release_package_cache(self, uv):cache = self.root / 'downloads' / 'uv-cache'if cache.is_symlink() or not cache.resolve().is_relative_to(self.root.resolve()):@@ -1851,6 +1873,7 @@ class Installer:def execute(self):if self.int8_check_first:+ prepare_end(self.ui) # The GPU precheck is already execution work.# The installed environment runs this source's probes (PYTHONPATH);# the receipt is reused by the check after installation.self.ui.phase('Verify installation on your GPU', 0, 8)diff --git a/freevideo_engine/doctor.py b/freevideo_engine/doctor.pyindex ccd492b..ef3c0b6 100644--- a/freevideo_engine/doctor.py+++ b/freevideo_engine/doctor.py@@ -11,7 +11,12 @@ from .monitoring import savefrom . import processes, subprocess_output-def doctor(*, probe=False, hardware=None, backends=None):+def doctor(*, probe=False, hardware=None, backends=None, progress=None):+ if progress is None and os.environ.get('FREEVIDEO_INSTALL_PROGRESS') == '1':+ from .install_activity import step+ progress = step+ if progress:+ progress('GPU information reading')from .triton_compat import own_temporary_environmentown_temporary_environment()versions = package_versions()@@ -28,7 +33,10 @@ def doctor(*, probe=False, hardware=None, backends=None):with runtime_lock() as descriptor:env = dict(os.environ, **{LOCK_ENV: str(descriptor)})linear = ['linear'] + (['linear-int8'] if hardware.system in ('Windows', 'Linux') else [])- for backend in [*sorted(backends), *linear]:+ probes = [*sorted(backends), *linear]+ for index, backend in enumerate(probes):+ if progress:+ progress('GPU tests running', index, len(probes))command = [sys.executable, '-m', 'freevideo_engine.probe', backend]try:child = subprocess_output.run_python(command, capture_output=True, timeout=180, env=env,@@ -52,6 +60,8 @@ def doctor(*, probe=False, hardware=None, backends=None):except OSError as error:row = {'backend': backend, 'status': 'error', 'error': 'Could not start kernel probe: ' + str(error)}result['kernel_probes'].append(row)+ if progress:+ progress('GPU tests running', index + 1, len(probes))result.update(readiness(result['kernel_probes']), identity=identity(hardware, versions),view_root=view_root())if temp_root():@@ -59,4 +69,6 @@ def doctor(*, probe=False, hardware=None, backends=None):result['receipt'] = str(receipt_path())result['validation'] = 'Small kernels executed on the listed GPU; this does not validate full-video speed, quality or capacity.'save(receipt_path(), result)+ if progress:+ progress('GPU tests finished', len(probes), len(probes))return resultdiff --git a/freevideo_engine/encode_worker.py b/freevideo_engine/encode_worker.pyindex 5744ba3..464453c 100644--- a/freevideo_engine/encode_worker.py+++ b/freevideo_engine/encode_worker.py@@ -236,6 +236,12 @@ def _encode(args, request, resident, trace):loading = trace.datadef phase(name, **metrics):trace.stage(name, **metrics)+ if args.check_library:+ from .install_activity import step+ labels = {'encoder_torch_import': 'Runtime libraries importing',+ 'encoder_options': 'Encoder configuring', 'encoder_native_import': 'Encoder importing'}+ if name in labels:+ step(labels[name])if name in ('encoder_oom', 'encoder_retry'):print(json.dumps(dict(event=name, attempt=len(loading.get('encoder_attempts', [])))), flush=True)if name == 'encoder_oom' and request.get('metrics') and request.get('diagnostic_output'):@@ -306,6 +312,8 @@ def _encode(args, request, resident, trace):raise RuntimeError('Unexpected application modules: ' + repr(forbidden))print(json.dumps({'native_encoder_library_import': True, 'application_modules_loaded': [],'torch': str(torch.__version__), 'source': str(args.comfy_root)}), flush=True)+ from .install_activity import step+ step('Encoder ready')returnphase('encoder_media_prepare')keyframes = request.get('keyframes')diff --git a/freevideo_engine/install_activity.py b/freevideo_engine/install_activity.pynew file mode 100644index 0000000..d8e3f81--- /dev/null+++ b/freevideo_engine/install_activity.py@@ -0,0 +1,29 @@+"""Small installation worker events: actual work, never elapsed-time counters."""+import json+import sys+import time+++def emit(event, **row):+ sys.stdout.write(json.dumps(dict(event=event, **row)) + '\n')+ sys.stdout.flush()+++def step(name, done=0, total=0):+ emit('installation_step', name=name, done=done, total=total)+++def byte_progress(event, file, *, name='Model files', report=None):+ """Report bounded reads/writes, including both endpoints, at most twice/s."""+ last = None+ def progress(done, total):+ nonlocal last+ now = time.monotonic()+ if last is None or done == total or now - last >= .5:+ row = dict(file=str(file), name=name, done_bytes=done, total_bytes=total)+ if report is None:+ emit(event, **row)+ else:+ report(**row)+ last = now+ return progressdiff --git a/freevideo_engine/launcher_copy.py b/freevideo_engine/launcher_copy.pyindex fd1009c..3cccaa0 100644--- a/freevideo_engine/launcher_copy.py+++ b/freevideo_engine/launcher_copy.py@@ -120,6 +120,23 @@ ZH = dict([('Hugging Face · Video', 'Hugging Face · 视频'), ('Hugging Face · Audio', 'Hugging Face · 音频'),])ZH.update(NAMES.values())+ZH.update([+ ('Completed ', '已完成 '), ('Verifying ', '正在校验'), ('Assembling ', '正在合并'),+ ('Copying ', '正在复制'), ('Model files', '模型文件'),+ ('Packages resolving', '正在检查组件'), ('Packages installing', '正在安装组件'), ('Packages ready', '组件已就绪'),+ ('Environment creating', '正在创建运行环境'), ('Base packages installing', '正在安装基础组件'),+ ('Python ready', 'Python 已就绪'), ('Python downloading', '正在下载 Python'),+ ('GPU acceleration building', '正在准备显卡加速'),+ ('Runtime libraries verifying', '正在校验运行组件'), ('Runtime libraries importing', '正在载入运行组件'),+ ('Encoder configuring', '正在准备文本编码器'), ('Encoder importing', '正在载入文本编码器'),+ ('Encoder ready', '文本编码器已就绪'),+ ('GPU information reading', '正在读取显卡信息'), ('GPU tests running', '正在检查显卡'),+ ('GPU tests finished', '显卡检查已完成'),+ ('Packages preparing', '正在准备组件'), ('Packages removing', '正在移除旧组件'),+ ('Model files verifying', '正在校验模型文件'), ('Model files preparing', '正在准备模型文件'),+ ('Model files assembling', '正在合并模型文件'),+ ('Package files', '离线包文件'),+])# Card lines for steps that only report counts (the terminal keeps the counts).ZH.update([('Downloading components', '正在下载组件'), ('Preparing components', '正在准备组件'),('Downloading runtime packages', '正在下载运行组件'), ('Finding existing models', '正在查找已有模型')])diff --git a/freevideo_engine/launcher_session.py b/freevideo_engine/launcher_session.pyindex 3ca99ac..16b3bd6 100644--- a/freevideo_engine/launcher_session.py+++ b/freevideo_engine/launcher_session.py@@ -1632,6 +1632,10 @@ class Session:done=min(group['download_bytes'], group.get('downloaded_bytes') or 0),rate=group.get('bytes_per_second') or progress.get('rate'))file_text = progress_text(current, zh, decimal_sizes=sys.platform == 'darwin')+ if self.importer.busy and self.importer.state.get('activity'):+ imported = self.importer.state+ file_text = progress_text(dict(activity=imported['activity'], unit='bytes',+ name=display('Package files', zh), done=imported.get('activity_done'), total=imported.get('activity_total')), zh)# The time row's estimate: only while downloading, from what is left at the current speed.from .setup_progress import numberleft, rate = (current.get('total') or 0) - (current.get('done') or 0), current.get('rate')diff --git a/freevideo_engine/model_transfer.py b/freevideo_engine/model_transfer.pyindex d1a9ff3..328e519 100644--- a/freevideo_engine/model_transfer.py+++ b/freevideo_engine/model_transfer.py@@ -135,10 +135,11 @@ class Progress:self.last = now-def verify(path, row):+def verify(path, row, progress=None):if path.stat().st_size != row['bytes']:raise ValueError('Downloaded size differs from the pinned manifest')- return network.hash_file(path, 'sha256' if row.get('sha256') else 'sha1', not row.get('sha256'), discard_cache=True) == (row.get('sha256') or row['git_blob'])+ return network.hash_file(path, 'sha256' if row.get('sha256') else 'sha1', not row.get('sha256'),+ discard_cache=True, progress=progress) == (row.get('sha256') or row['git_blob'])def checked_range_response(response, requested, total, progress):@@ -187,10 +188,13 @@ def sdk_worker(request):progress = Progress(row['bytes'])backend = []started = time.monotonic()+ from .install_activity import byte_progress+ verifying = byte_progress('verify_progress', target,+ report=lambda **row: emit(phase='verify', **row))try:if target.is_file():- emit(phase='verify')- if verify(target, row):+ emit(phase='verify', done_bytes=0, total_bytes=row['bytes'])+ if verify(target, row, progress=verifying):emit(phase='ready', backend='verified-stage', seconds=time.monotonic()-started, fingerprint=fingerprint(target))return 0network.retain_partial(target, 'hash-rejected')@@ -213,7 +217,14 @@ def sdk_worker(request):def update(self, amount):progress.update(0)def end(self):- emit(phase='reconstruct', done_bytes=row['bytes'], total_bytes=row['bytes'])+ emit(phase='reconstruct', done_bytes=0, total_bytes=row['bytes'])+ def merge_progress(self, done, total):+ merging(done, total)+ def verify_progress(self, done, total):+ verifying(done, total)++ merging = byte_progress('assemble_progress', target,+ report=lambda **row: emit(phase='reconstruct', **row))original_get, original_parallel = _download.requests.get, getattr(_download, '_parallel_download', None)@@ -318,8 +329,8 @@ def sdk_worker(request):# count alone does not prove that the file descriptor is closed.emit(phase='transfer_complete', done_bytes=row['bytes'], total_bytes=row['bytes'])downloaded = time.monotonic()- emit(phase='verify')- if not verify(target, row):+ emit(phase='verify', done_bytes=0, total_bytes=row['bytes'])+ if not verify(target, row, progress=verifying):raise ValueError('Downloaded hash differs from the pinned manifest')emit(phase='ready', backend=backend[-1] if backend else 'hf-cache',download_seconds=downloaded-started, verification_seconds=time.monotonic()-downloaded,@@ -524,6 +535,12 @@ def run_sdk(source, row, path, plan, progress_callback, networking, transfer_comnetwork_bytes_per_second=current.get('transfer_bytes', 0) /max(.001, current.get('elapsed_seconds', time.monotonic()-started)),method=current.get('backend'))+ if current['phase'] in ('verify', 'reconstruct') and current.get('total_bytes'):+ from .model_status import NAMES, family+ sys.stdout.write(json.dumps(dict(event='verify_progress' if current['phase'] == 'verify' else 'assemble_progress',+ file=str(path), name=NAMES[family(row)][0], done_bytes=current.get('done_bytes', 0),+ total_bytes=current['total_bytes'])) + '\n')+ sys.stdout.flush()prior_phase = current['phase']last_emit = time.monotonic()# The SDK reports the transfer complete before it starts its finaldiff --git a/freevideo_engine/network.py b/freevideo_engine/network.pyindex 3805852..452dbb3 100644--- a/freevideo_engine/network.py+++ b/freevideo_engine/network.py@@ -772,8 +772,16 @@ def download(candidates, path, expected, progress=None, *, network=None, env=Nonreturn Falseevent(network, category=category, source=source, file=path.name, action='verifying', algorithm=algorithm)check = network.get('resource_check') if keep_partial else None+ from .install_activity import byte_progress+ report = byte_progress('verify_progress', path.name, report=lambda **row:+ event(network, category=category, source=source, action='verify-progress', **row))+ def verification(done, total):+ if check:+ check()+ if model:+ report(done, total)return hash_file(candidate, algorithm, git_blob, discard_cache=category in ('models', 'vdn-models'),- progress=(lambda done, total: check()) if check else None) == expected+ progress=verification if model or check else None) == expectedif path.is_file():if matches(path):returndiff --git a/freevideo_engine/offline_packages.py b/freevideo_engine/offline_packages.pyindex e02e93e..d304b65 100644--- a/freevideo_engine/offline_packages.py+++ b/freevideo_engine/offline_packages.py@@ -220,7 +220,7 @@ def stamp(path):return [info.st_size, info.st_mtime_ns]-def unchanged(path, row, known, current=None):+def unchanged(path, row, known, current=None, progress=None):"""Still the file its import checked: the size matches, and the recorded time too.Only a file whose record says it was rewritten since is hashed. `current`@@ -235,7 +235,24 @@ def unchanged(path, row, known, current=None):if known.get(row['path']) in (None, current):return Truefrom .network import hash_file- return hash_file(path) == row['sha256']+ return hash_file(path, **({'progress': progress} if progress else {})) == row['sha256']+++def file_progress(progress, activity, total):+ from .install_activity import byte_progress+ return byte_progress('', '', report=lambda **row:+ progress(activity=activity, activity_done=row['done_bytes'], activity_total=row['total_bytes']))+++def copy_progress(source, target, progress):+ """The existing cross-disk copy, with a bounded buffer and actual bytes."""+ total, done = source.stat().st_size, 0+ progress(0, total)+ with source.open('rb') as input_file, target.open('wb') as output:+ for chunk in iter(lambda: input_file.read(4 * 2**20), b''):+ output.write(chunk)+ done += len(chunk)+ progress(done, total)def import_archive(path, destination, progress=lambda **kw: None, cancelled=lambda: False):@@ -265,18 +282,19 @@ def import_archive(path, destination, progress=lambda **kw: None, cancelled=lambcurrent = present.get(row['path'])if current is None:continue- if current[0] != row['bytes'] or not unchanged(root / row['path'], row, known, current):+ if current[0] != row['bytes'] or not unchanged(root / row['path'], row, known, current,+ progress=file_progress(progress, 'verify', row['bytes'])):raise ValueError('已有导入文件已改变,未覆盖:' + plain(root / row['path']))verified[row['path']] = currentmarker = root / value['marker']if not missing and marker.is_file() and marker.read_bytes() == value['raw']:# Imported before and complete: nothing to read again.save(root / VERIFIED, verified)- progress(done=total, total=total, detail=path.name)+ progress(done=total, total=total, detail=path.name, activity='')return dict(root=plain(root), kind=value['kind'], variant=value['variant'], name=path.name, **origin)done = sum(r['bytes'] for r in value['files'] if r['path'] in verified)root.mkdir(parents=True, exist_ok=True)- progress(done=done, total=total, detail=path.name)+ progress(done=done, total=total, detail=path.name, activity='')with zipfile.ZipFile(path) as archive:for row in value['files']:if cancelled():@@ -374,7 +392,8 @@ def assemble(runtime, models, source, progress=lambda **kw: None):def source_for(row):for root in models:current = walks[root].get(row['path'])- if current and unchanged(io_path(root) / row['path'], row, known[root], current):+ if current and unchanged(io_path(root) / row['path'], row, known[root], current,+ progress=file_progress(progress, 'verify', row['bytes'])):return io_path(root) / row['path']return None@@ -383,19 +402,20 @@ def assemble(runtime, models, source, progress=lambda **kw: None):try:os.link(src, target)except OSError:- shutil.copyfile(src, target)+ copy_progress(src, target, file_progress(progress, 'copy_bytes', src.stat().st_size))for row in model['files']:target, src = runtime / row['path'], source_for(row)if src is None:raise ValueError('还需导入「%s」包,缺少文件:%s' % (pack_name(row['path']), row['path']))if row['path'] in here:- if not os.path.samefile(target, src) and hash_file(target) != row['sha256']:+ if not os.path.samefile(target, src) and hash_file(target,+ progress=file_progress(progress, 'verify', row['bytes'])) != row['sha256']:raise ValueError('离线安装已有不同模型,未覆盖:' + plain(target))else:place(src, target)done += row['bytes']- progress(done=done, total=total, detail='检查配套包')+ progress(done=done, total=total, detail='检查配套包', activity='')listed = {row['path'] for row in model['files']}for root in models:package = io_path(root) / 'offline-package.json'@@ -405,10 +425,12 @@ def assemble(runtime, models, source, progress=lambda **kw: None):if row['path'] in listed or not row['path'].startswith(OPTIONAL_PREFIX) or row['path'] in here:continuecurrent = walks[root].get(row['path'])- if not current or not unchanged(io_path(root) / row['path'], row, known[root], current):+ if not current or not unchanged(io_path(root) / row['path'], row, known[root], current,+ progress=file_progress(progress, 'verify', row['bytes'])):continue # The engine fetches a table it cannot find when a request needs it.place(io_path(root) / row['path'], runtime / row['path'])listed.add(row['path'])+ progress(done=done, total=total, detail='检查配套包', activity='')return finish(runtime, config, model, source, here)diff --git a/freevideo_engine/provider_resume.py b/freevideo_engine/provider_resume.pyindex c8ed27d..4c5a6f2 100644--- a/freevideo_engine/provider_resume.py+++ b/freevideo_engine/provider_resume.py@@ -46,6 +46,11 @@ def ms_parallel(module, url, target, file_size, headers, cookies, progress_callboffset = merged.stat().st_size if merged.exists() else 0if offset > file_size:raise ValueError('Retained merge exceeds the pinned model size')+ def verifying(done, total):+ for callback in callbacks:+ report = getattr(callback, 'verify_progress', None)+ if report:+ report(done, total)if offset % module.DOWNLOAD_PART_SIZE:# A switched HTTP download may end in the middle of an SDK part.# Seed that part so its first Range starts after the retained prefix.@@ -59,11 +64,14 @@ def ms_parallel(module, url, target, file_size, headers, cookies, progress_callbwith merged.open('rb') as prefix, part.open('a+b') as output:prefix.seek(start); output.seek(0)remaining=min(existing,offset-start)+ total = remaining+ verifying(0, total)while remaining:count=min(BLOCK,remaining)if prefix.read(count)!=output.read(count):raise ValueError('Retained part differs from switched prefix')remaining-=count+ verifying(total-remaining, total)if existing<offset-start:prefix.seek(start+existing); output.seek(0,2)remaining=offset-start-existing@@ -83,11 +91,13 @@ def ms_parallel(module, url, target, file_size, headers, cookies, progress_callbraise ValueError('Unexpected size of a retained merged part')with merged.open('rb') as prefix, part.open('rb') as stream:prefix.seek(start)+ verifying(0, end-start)for block in iter(lambda: stream.read(BLOCK), b''):if block != prefix.read(len(block)):raise ValueError('Retained part differs from merged prefix')discard_read_cache(prefix.fileno(), prefix.tell()-len(block), len(block))discard_read_cache(stream.fileno(), stream.tell()-len(block), len(block))+ verifying(stream.tell(), end-start)part.unlink()tasks = [(str(target), callbacks, start, min(file_size, start+module.DOWNLOAD_PART_SIZE)-1,url, target.name, headers, cookies)@@ -97,12 +107,21 @@ def ms_parallel(module, url, target, file_size, headers, cookies, progress_callblist(pool.map(module._download_part_with_retry, tasks))for callback in callbacks:callback.end()+ def merging(done):+ for callback in callbacks:+ report = getattr(callback, 'merge_progress', None)+ if report:+ report(done, file_size)+ merging(0)digest = hashlib.sha256()if offset:+ read = 0with merged.open('rb') as prefix:for block in iter(lambda: prefix.read(BLOCK), b''):digest.update(block)discard_read_cache(prefix.fileno(), prefix.tell()-len(block), len(block))+ read += len(block)+ merging(read)with merged.open('ab') as output:for task in tasks:start, end = task[2:4]@@ -115,6 +134,7 @@ def ms_parallel(module, url, target, file_size, headers, cookies, progress_callboutput.write(block)digest.update(block)discard_read_cache(stream.fileno(), stream.tell()-len(block), len(block))+ merging(output.tell())output.flush()os.fsync(output.fileno())offset = end+1@@ -124,6 +144,7 @@ def ms_parallel(module, url, target, file_size, headers, cookies, progress_callbif merged.stat().st_size != file_size:raise ValueError('Merged model has an unexpected size')publish(merged, target)+ merging(file_size)return digest.hexdigest()diff --git a/freevideo_engine/provision.py b/freevideo_engine/provision.pyindex e0e8f61..583b17b 100644--- a/freevideo_engine/provision.py+++ b/freevideo_engine/provision.py@@ -15,6 +15,7 @@ from . import networkfrom .storage import record_download, compact_sources, fingerprintfrom . import model_transferfrom . import model_repair+from .install_activity import byte_progress, stepdef model_headers(source):@@ -215,7 +216,8 @@ def models(plan):# ownership of, replace, or download over that newly present file.if path.exists() or path.is_symlink():prior = {}- if not verified(path, row, prior, mode=mode, hf_directory=hf_directory):+ if not verified(path, row, prior, mode=mode, hf_directory=hf_directory,+ progress=byte_progress('verify_progress', path, name=NAMES[family(row)][0])):raise ValueError('Model destination appeared with unexpected content: ' + str(path))complete(row, path, prior[str(path)], 'verify')return@@ -409,22 +411,30 @@ def verify_cache(plan, cache):raise ValueError('Prepared cache is not complete; original model files retained')ledger = Path(plan['root']) / 'verified-cache.json'stamps = json.loads(ledger.read_text(encoding='utf-8')) if ledger.is_file() else {}- for row in groups:+ assets = list(validate_catalog(manifest, count))+ total = len(groups) + len(assets)+ step('Model files verifying', 0, total)+ for index, row in enumerate(groups, 1):if row['file'] != row['group'] + '.safetensors':raise ValueError('Unexpected FP8 group path; original files retained')if not verified(cache / row['file'], row, stamps, mode=plan.get('verification', 'auto'),- producer_receipt=cache / 'manifest.json'):+ producer_receipt=cache / 'manifest.json',+ progress=byte_progress('verify_progress', cache / row['file'])):raise ValueError('Existing FP8 cache failed integrity check: ' + row['file'] + '. Rerun setup with --rebuild-cache; failed files are retained.')- for row, identity in validate_catalog(manifest, count):+ step('Model files verifying', index, total)+ for index, (row, identity) in enumerate(assets, len(groups) + 1):path = asset_path(cache, row['file'])- if not verified(path, row, stamps, mode=plan.get('verification', 'auto')):+ if not verified(path, row, stamps, mode=plan.get('verification', 'auto'),+ progress=byte_progress('verify_progress', path)):raise ValueError('AdaLN model asset failed integrity check: ' + row['file'])check_table(path, row, identity, verify_hash=False)+ step('Model files verifying', index, total)save(ledger, stamps)return manifestdef prepare(plan, out):+ step('Model files preparing')root = Path(plan['root'])prepared = plan.get('prepared_model')cache_format = dict(capability=plan.get('inventory', {}).get('hardware', {}).get('capability'),@@ -513,7 +523,13 @@ def main():if args.cleanup:record = json.loads((Path(plan['root']) / 'prepared-cache.json').read_text(encoding='utf-8'))verify_cache(plan, record['cache'])- result = compact_sources(plan, json.loads((PACKAGE / 'model_files.json').read_text(encoding='utf-8')), args.out)+ reporters = {}+ def cleanup_progress(path, done, total):+ if path not in reporters:+ reporters[path] = byte_progress('verify_progress', path)+ reporters[path](done, total)+ result = compact_sources(plan, json.loads((PACKAGE / 'model_files.json').read_text(encoding='utf-8')), args.out,+ progress=cleanup_progress)print(json.dumps({'event': 'storage_compacted', **result}), flush=True)elif args.prepare:prepare(plan, args.out)diff --git a/freevideo_engine/runtime_libraries.py b/freevideo_engine/runtime_libraries.pyindex 1cd0e7d..19571ea 100644--- a/freevideo_engine/runtime_libraries.py+++ b/freevideo_engine/runtime_libraries.py@@ -69,7 +69,7 @@ def _canonical(path):return os.path.normcase(plain(text))-def check(site):+def check(site, progress=None):"""Compare every recorded cuDNN file under ``site`` with its RECORD hash.A file is changed only when it matches none of the hashes recorded for its@@ -100,6 +100,8 @@ def check(site):if name not in result['owners']:result['owners'].append(name)directories = set()+ if progress:+ progress(0, len(expected))for path, records in expected.values():owners = sorted({name for name, _, _ in records})entry = dict(name=os.path.basename(path), owner=owners[0], owners=owners)@@ -125,6 +127,9 @@ def check(site):expected_size=sizes[0] if len(sizes) == 1 else sizes or None))except OSError as error:result['unreadable'].append(dict(entry, error=type(error).__name__))+ finally:+ if progress:+ progress(result['checked'], len(expected))recorded = {_canonical(path) for path, _ in expected.values()}for directory in sorted(directories):try:@@ -301,7 +306,7 @@ def dependency_closure(python, requirements, additional=()):return set(seen)-def damaged(python):+def damaged(python, progress=None):"""Distributions whose recorded cuDNN files differ in this Python's environment.Sizes are compared first and only files of the recorded size are hashed,@@ -310,7 +315,7 @@ def damaged(python):"""try:site = site_for(python)- found = check(site) if site is not None else {'changed': []}+ found = check(site, **({'progress': progress} if progress else {})) if site is not None else {'changed': []}except Exception:return []return sorted({owner for row in found['changed'] for owner in row['owners']})diff --git a/freevideo_engine/setup_progress.py b/freevideo_engine/setup_progress.pyindex 44dc6d4..e1c38d2 100644--- a/freevideo_engine/setup_progress.py+++ b/freevideo_engine/setup_progress.py@@ -100,6 +100,20 @@ def progress_text(event, zh=False, *, decimal_sizes=False):"""One activity line for the launcher; step counts and ETAs remain in worker events/logs."""t = lambda en, cn: cn if zh else enactivity, name = event.get('activity'), event.get('name') or ''+ if activity == 'count':+ done, total = event.get('done'), event.get('total')+ if number(done) and number(total) and total > 0 and done <= total:+ return name + t(' · Completed ', ' · 已完成 ') + '%d / %d' % (done, total)+ return name+ if activity in ('verify', 'assemble', 'copy_bytes'):+ verb = {'verify': ('Verifying ', '正在校验'), 'assemble': ('Assembling ', '正在合并'),+ 'copy_bytes': ('Copying ', '正在复制')}[activity]+ # MiB rather than tenths of GiB: even slow disks change the visible text.+ parts = [t(*verb) + name]+ done, total = event.get('done'), event.get('total')+ if event.get('unit') == 'bytes' and number(done) and number(total) and total > 0 and done <= total:+ parts.append('%d / %d %s' % (done // 2**20, total // 2**20, 'MiB'))+ return ' · '.join(parts)if activity == 'resume':return t('The connection dropped; resuming the download and keeping what was already downloaded','连接中断,正在继续下载,已下载的部分会保留')diff --git a/freevideo_engine/storage.py b/freevideo_engine/storage.pyindex 9d58d05..3b878c8 100644--- a/freevideo_engine/storage.py+++ b/freevideo_engine/storage.py@@ -83,7 +83,7 @@ def record_download(root, path, row, *, origin='download'):save(ledger, {'root': plain(resolved(root)), 'files': files})-def compact_sources(plan, rows, report):+def compact_sources(plan, rows, report, progress=None):"""Caller must first verify the complete FP8 cache and pass GPU setup probes.Deletion uses an allowlist of pinned conversion-only filenames and a matching@@ -138,9 +138,11 @@ def compact_sources(plan, rows, report):# Destructive cleanup cannot trust a metadata cache hit. Equal-size# edits may share a filesystem timestamp tick with the receipt.if row.get('sha256'):- matches = hash_file(path, discard_cache=True) == row['sha256']+ matches = hash_file(path, discard_cache=True, progress=(+ lambda done, total: progress(path, done, total)) if progress else None) == row['sha256']elif row.get('git_blob'):- matches = hash_file(path, 'sha1', git_blob=True, discard_cache=True) == row['git_blob']+ matches = hash_file(path, 'sha1', git_blob=True, discard_cache=True, progress=(+ lambda done, total: progress(path, done, total)) if progress else None) == row['git_blob']else:raise OSError('No pinned content hash; source retained')if not matches:diff --git a/freevideo_engine/terminal_ui.py b/freevideo_engine/terminal_ui.pyindex 593c414..730e16f 100644--- a/freevideo_engine/terminal_ui.py+++ b/freevideo_engine/terminal_ui.py@@ -322,6 +322,7 @@ class LogProgress:def __init__(self, path):self.path, self.offset, self.pending = Path(path), 0, ''self.packages = {}+ self.downloaded_packages = set()self.installing_packages = Falseself.model_source = ''self.model_backend = ''@@ -382,23 +383,48 @@ class LogProgress:self.packages[name] = float(size) * {'KiB': 2**10, 'MiB': 2**20, 'GiB': 2**30}[unit]amount = sum(self.packages.values()) / 2**30size_text = '%.1f GiB' % amount if amount >= 1 else '%.0f MiB' % (amount * 1024)- update(done=0, total=0, scope='package-download', activity='note', name='Downloading runtime packages',+ update(done=len(self.downloaded_packages), total=len(self.packages), unit='items',+ scope='package-download', activity='count', name='Downloading runtime packages',detail='Downloading packages · about %s across %d files' % (size_text, len(self.packages)))+ elif re.fullmatch(r'Downloaded [\w.+-]+', text):+ name = text.split(' ', 1)[1]+ if name in self.packages:+ self.downloaded_packages.add(name)+ update(done=len(self.downloaded_packages), total=len(self.packages), unit='items',+ scope='package-download', activity='count', name='Downloading runtime packages',+ detail='Downloading runtime packages')elif re.match(r'Resolved \d+ packages? in ', text):self.packages.clear()+ self.downloaded_packages.clear()self.installing_packages = False- update(done=0, total=0, scope='package-resolve', detail='Dependencies resolved · preparing downloads')+ update(done=0, total=0, scope='package-resolve', activity='note', name='Packages resolving',+ detail='Dependencies resolved · preparing downloads')elif re.match(r'Prepared \d+ packages? in ', text):self.installing_packages = True- update(done=0, total=0, scope='package-install', detail='Downloads ready · installing packages')+ update(done=0, total=0, scope='package-install', activity='note', name='Packages installing',+ detail='Downloads ready · installing packages')elif re.match(r'Installed \d+ packages? in ', text):- update(done=0, total=0, scope='package-finish', detail='Packages installed · finishing checks')+ update(done=0, total=0, scope='package-finish', activity='note', name='Packages ready',+ detail='Packages installed · finishing checks')+ elif re.match(r'Uninstalled \d+ packages? in ', text):+ update(done=0, total=0, scope='package-remove', activity='note', name='Packages installing',+ detail='Packages installing')+ elif text.startswith('Creating virtual environment'):+ update(done=0, total=0, scope='venv-create', activity='note', name='Environment creating', detail='Environment creating')+ elif text.startswith('Installing seed packages'):+ update(done=0, total=0, scope='venv-seed', activity='note', name='Base packages installing', detail='Base packages installing')+ elif text.startswith('Installed Python '):+ update(done=0, total=0, scope='python-ready', activity='note', name='Python ready', detail='Python ready')match = re.search(r'\[(\d+)/(\d+)\]', line)if match:self.installing_packages |= 'Installing wheels' in text+ package_phase = ('remove', 'Packages removing') if 'Uninstalling' in text else (+ ('prepare', 'Packages preparing') if 'Preparing packages' in text else (+ ('install', 'Packages installing') if self.installing_packages else ('compile', 'GPU acceleration building')))update(done=int(match[1]), total=int(match[2]),+ activity='count', name=package_phase[1],detail='Installing packages' if self.installing_packages else 'Compiling CUDA kernels',- scope='package-install' if self.installing_packages else 'compile', unit='items')+ scope='package-' + package_phase[0], unit='items')try:event = json.loads(line)except (ValueError, TypeError):@@ -406,7 +432,23 @@ class LogProgress:if not isinstance(event, dict):continuekind = event.get('event')- if kind == 'model_groups':+ if kind == 'installation_step':+ update(done=event.get('done', 0), total=event.get('total', 0), unit='items',+ activity='count' if event.get('total') else 'note', name=event['name'],+ detail=event['name'], scope='install-' + event['name'])+ elif kind == 'freevideo_ui' and event.get('kind') in ('task', 'progress'):+ # A nested Comfy environment has its own phases. Forward work,+ # never its percentage into the outer installation's one bar.+ update(done=event.get('done', 0), total=event.get('total', 0), unit=event.get('unit'),+ activity=event.get('activity') or 'note', name=event.get('name') or event.get('label', ''),+ detail=event.get('detail', ''), scope='comfy-' + str(event.get('key', '')))+ elif kind in ('verify_progress', 'assemble_progress') or (kind == 'network' and event.get('action') == 'verify-progress'):+ update(done=event['done_bytes'], total=event['total_bytes'], unit='bytes',+ activity='assemble' if kind == 'assemble_progress' else 'verify',+ name=event.get('name') or model_download_name(event['file']).split(' · ')[0],+ detail='Model files verifying' if kind != 'assemble_progress' else 'Model files assembling',+ scope=kind + '-' + event['file'])+ elif kind == 'model_groups':self.model_groups = event['groups']continueif kind in ('loaded', 'sampling_start', 'sampling_progress', 'step', 'sample_finalize'):@@ -441,9 +483,11 @@ class LogProgress:elif kind == 'prepare_fp8_phase':work = 'Verify cached weights' if event['phase'] == 'verify_cache' else 'Read and convert source weights'update(done=max(0, event['index'] - 1), total=event['total'],+ activity='count', name='Model files verifying' if event['phase'] == 'verify_cache' else 'Model files preparing',detail=work + ' · ' + event['group'], scope='prepare-fp8-' + event['phase'], unit='items')elif kind == 'prepared_fp8_group':update(done=event.get('index', 0), total=event.get('total', 0),+ activity='count', name='Model files preparing',detail=('Reuse verified FP8 ' if event.get('reused') else 'Prepare FP8 ') + event['group'], scope='prepare-fp8', unit='items')elif kind == 'storage_compacted':update(done=0, total=0, activity='', name='',@@ -513,7 +557,7 @@ class LogProgress:state = event.get('state', 'running')active = state == 'running'self.parallel_tasks['verify-models'] = dict(label='Verify / reuse local models', state=state,- activity='check' if active else '',+ activity='verify' if active else '',name=(event.get('name') or model_download_name(event.get('file', '')).split(' · ')[0]) if active else '',done=event.get('done_bytes', 0) if active else event.get('files_done', 0),total=event.get('total_bytes', 0) if active else event.get('files_total', 0),@@ -540,7 +584,7 @@ class LogProgress:speed = event.get('network_bytes_per_second')shown_speed = speed if speed is not None else event['bytes_per_second']update(done=done, total=total, scope=description + self.model_source, rate=event['bytes_per_second'], unit='bytes',- activity='download', name=event.get('name') or ('PyTorch' if description == 'torch'+ activity='download', name=event.get('name') or ('Python' if description.startswith('cpython-') else 'PyTorch' if description == 'torch'else model_download_name(description).split(' · ')[0]),detail='%s%s%.1f MiB/s · %.1f / %.1f MiB · %s' %(source + ' · ' if source else '',