Bump version to 0.10.11 and update installation instructions; enhance progress reporting and estimated time features

This commit is contained in:
2026-08-09 10:23:14 +08:00
parent 9c896213a5
commit 97a720051f
12 changed files with 382 additions and 150 deletions

View File

@@ -49,6 +49,7 @@ def write_status(
stage=None,
stages=None,
stage_label=None,
eta_seconds=None,
):
payload = {"progress": progress, "message": message}
if error:
@@ -57,6 +58,8 @@ def write_status(
payload["stage"] = stage
payload["stages"] = stages
payload["stage_label"] = stage_label
if eta_seconds is not None:
payload["eta_seconds"] = max(int(eta_seconds), 0)
if state is None:
if error:
state = "failed"
@@ -229,6 +232,7 @@ class DownloadProgressReporter:
self.label = label
self.progress = start
self.last_write_time = 0.0
self.started_at = self.clock()
def report(self, current, total, rate=None):
if not total or current <= 0:
@@ -244,14 +248,25 @@ class DownloadProgressReporter:
return
self.progress = progress
self.last_write_time = now
speed = format_rate(rate) if rate else ""
effective_rate = rate
elapsed = now - self.started_at
if not effective_rate and elapsed > 0:
effective_rate = current / elapsed
speed = format_rate(effective_rate) if effective_rate else ""
eta_seconds = None
if effective_rate and effective_rate > 0:
eta_seconds = max(total - current, 0) / effective_rate
if self.stage is not None:
message = f"downloading {speed}" if speed else "downloading"
message = (
f"Downloading packages | {speed}"
if speed
else "Downloading packages"
)
else:
prefix = self.label or self.repository
message = f"downloading {prefix}"
message = f"Downloading {prefix}"
if speed:
message = f"{message} {speed}"
message = f"{message} | {speed}"
write_status(
self.status_path,
progress,
@@ -259,6 +274,7 @@ class DownloadProgressReporter:
stage=self.stage,
stages=self.stages,
stage_label=self.stage_label,
eta_seconds=eta_seconds,
)
@@ -356,7 +372,7 @@ def download_model(args):
failures.append((endpoint, "endpoint unreachable"))
continue
os.environ["HF_ENDPOINT"] = endpoint
message = f"downloading {label}"
message = f"Downloading {label}"
if endpoint != HF_ENDPOINT:
message = f"{message} (mirror)"
write_status(args.status, start, message, **stage_kwargs)
@@ -375,7 +391,7 @@ def download_model(args):
write_status(
args.status,
start + span,
"model ready",
f"{label} ready",
**stage_kwargs,
)
return
@@ -384,7 +400,7 @@ def download_model(args):
write_status(
args.status,
start,
f"downloading {label} (mirror: modelscope.cn)",
f"Downloading {label} | ModelScope mirror",
**stage_kwargs,
)
download_from_modelscope(
@@ -402,7 +418,7 @@ def download_model(args):
write_status(
args.status,
start + span,
"model ready",
f"{label} ready",
**stage_kwargs,
)
return