Skip to content

Transform your 3D texturing workflow with the power of generative AI, directly within Blender!

show installer downloads under a gigabyte in MB

sakalond0051755b9289
diff --git a/stablegen/setup/jobs.py b/stablegen/setup/jobs.py
index 0d514cc..82ac19b 100644
--- a/stablegen/setup/jobs.py
+++ b/stablegen/setup/jobs.py
@@ -172,13 +172,20 @@ class InstallerJob:
elapsed = max(time.monotonic(), self._samples[-1][0]) - start_time
return (self._samples[-1][1] - start_bytes) / elapsed if elapsed > 0.5 else None
+ @staticmethod
+ def bytes_text(done, total) -> str:
+ """'5.1 of 14.3 GB', or in MB below a gigabyte (uv, Git): not '0.0 of 0.0 GB'."""
+ if total >= 1024**3:
+ return f"{done / 1024**3:.1f} of {total / 1024**3:.1f} GB"
+ return f"{done / 1024**2:.0f} of {total / 1024**2:.0f} MB"
+
def total_mb(self) -> float:
return sum(i.get("size_mb", 0) for i in self.items.values() if not i.get("present"))
def size_text(self) -> str:
"""'5.1 of 14.3 GB' over the whole run, or 'Preparing…' before its plan arrives."""
total = self.total_mb()
- return f"{self.progress() * total / 1024:.1f} of {total / 1024:.1f} GB" if total else "Preparing…"
+ return self.bytes_text(self.progress() * total * 1024**2, total * 1024**2) if total else "Preparing…"
def rate_text(self) -> str:
"""'42 MB/s · 4 min left' while downloading, else ''."""
@@ -205,5 +212,5 @@ class InstallerJob:
if not item:
return "Preparing…"
if item.get("total"):
- return f"{item['name']}: {item['done'] / 1024**3:.1f} of {item['total'] / 1024**3:.1f} GB"
+ return f"{item['name']}: {self.bytes_text(item['done'], item['total'])}"
return f"{item['name']}…"
diff --git a/stablegen/ui/studio_setup.py b/stablegen/ui/studio_setup.py
index e70f26f..15bdfb8 100644
--- a/stablegen/ui/studio_setup.py
+++ b/stablegen/ui/studio_setup.py
@@ -11,6 +11,7 @@ from . import studio_tips as tips
from .studio_text import wrap
from .studio_widgets import CONTROL_GAP, CONTROL_HEIGHT, FONT_SIZE, font_size
from ..setup import installer, packages, prefs_ui, runtime
+from ..setup.jobs import InstallerJob
OPENED = 'setup_page_opened' # the page opens by itself once, on the first run
MODES = (
@@ -283,7 +284,7 @@ def _own_progress(session, p, job, x, y, width):
p.text(item["name"], x + 20, y, FONT_SIZE, 'secondary' if done else 'text' if current else 'muted',
width - 110)
if current and item.get("total"):
- size = f"{item['done'] / 1024**3:.1f} of {item['total'] / 1024**3:.1f} GB"
+ size = InstallerJob.bytes_text(item['done'], item['total'])
else:
size = packages.size_text(item.get("size_mb", 0)) if item.get("size_mb") else ""
p.text(size, x + width - p.measure(size, 10), y + 1, 10, 'muted')