Bump version to 0.11.2 and update uv version to 0.11.3
- Updated version in pyproject.toml and blender_manifest.toml to 0.11.2. - Enhanced uv executable path documentation in client.py. - Added inference_mode parameter to reconstruct_request function in client.py. - Implemented uv download functionality in install_env.py with improved error handling and checksum verification. - Modified install_uv function to download and extract uv binary instead of using bundled version. - Updated job progress handling in operators.py to track progress stages. - Improved download progress reporting in worker.py and adjusted related tests. - Refactored tests to accommodate changes in status reporting and model downloading. - Removed vendor.lock.toml as part of the cleanup process.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import importlib.util
|
||||
import io
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import tarfile
|
||||
import tempfile
|
||||
@@ -129,8 +131,8 @@ class InstallEnvTest(unittest.TestCase):
|
||||
if value == "--allow-pattern"
|
||||
]
|
||||
self.assertEqual(patterns, ["onnx/model_fp16.onnx"])
|
||||
self.assertNotIn("--stage", ben2_download)
|
||||
self.assertNotIn("--stage-label", ben2_download)
|
||||
self.assertIn("--stage", ben2_download)
|
||||
self.assertIn("--stage-label", ben2_download)
|
||||
self.assertEqual(
|
||||
ben2_download[ben2_download.index("--label") + 1],
|
||||
"BEN2 Base",
|
||||
@@ -305,7 +307,7 @@ class InstallEnvTest(unittest.TestCase):
|
||||
)
|
||||
self.assertEqual(called_command[-1], "da3 small")
|
||||
|
||||
def test_install_allocates_contiguous_progress_slices(self):
|
||||
def test_install_resets_progress_for_each_stage(self):
|
||||
bootstrap = load_install_env()
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
@@ -358,21 +360,8 @@ class InstallEnvTest(unittest.TestCase):
|
||||
):
|
||||
bootstrap.install(args)
|
||||
|
||||
starts = [item[1] for item in stage_ranges]
|
||||
ends = [item[2] for item in stage_ranges]
|
||||
self.assertTrue(
|
||||
all(starts[i] < starts[i + 1] for i in range(len(starts) - 1))
|
||||
)
|
||||
self.assertEqual(ends[-1], 1.0)
|
||||
self.assertEqual(starts[0], bootstrap.ENVIRONMENT_SLICE[0])
|
||||
runtime_ranges = stage_ranges[:2]
|
||||
self.assertEqual(
|
||||
[item[0] for item in runtime_ranges],
|
||||
[1, 2],
|
||||
)
|
||||
self.assertTrue(
|
||||
all(item[0] is None for item in stage_ranges[4:])
|
||||
)
|
||||
self.assertEqual(stage_ranges[:2], [(1, 0.0, 0.05), (1, 0.05, 1.0)])
|
||||
self.assertEqual(stage_ranges[2:], [(2, 0.0, 1.0), (3, 0.0, 1.0)])
|
||||
status = json.loads(
|
||||
(root / "status.json").read_text(encoding="utf-8")
|
||||
)
|
||||
@@ -884,13 +873,12 @@ class InstallEnvTest(unittest.TestCase):
|
||||
)
|
||||
)
|
||||
|
||||
def test_install_fails_when_bundled_uv_missing(self):
|
||||
def test_install_fails_when_all_uv_sources_are_unavailable(self):
|
||||
bootstrap = load_install_env()
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
venv_dir = root / ".venv"
|
||||
venv_dir.mkdir()
|
||||
self.create_bundled_vendor(root)
|
||||
uv_path = root / "uv" / "uv.exe"
|
||||
args = SimpleNamespace(
|
||||
uv=str(uv_path),
|
||||
@@ -916,29 +904,23 @@ class InstallEnvTest(unittest.TestCase):
|
||||
"rmtree",
|
||||
), patch.object(
|
||||
bootstrap,
|
||||
"bundled_uv_archive",
|
||||
return_value=None,
|
||||
"download_uv_archive",
|
||||
side_effect=RuntimeError("all sources unavailable"),
|
||||
):
|
||||
with self.assertRaisesRegex(
|
||||
RuntimeError,
|
||||
"Bundled uv is missing",
|
||||
"all sources unavailable",
|
||||
):
|
||||
bootstrap.install(args)
|
||||
|
||||
def test_install_uses_bundled_vendor_and_uv_without_network(self):
|
||||
def test_install_downloads_and_extracts_uv(self):
|
||||
bootstrap = load_install_env()
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
venv_dir = root / ".venv"
|
||||
venv_dir.mkdir()
|
||||
bundled = root / "bundled"
|
||||
bundled.mkdir()
|
||||
(bundled / "depth-anything-3.tar.gz").write_bytes(b"da3")
|
||||
(bundled / "ben2.tar.gz").write_bytes(b"ben2")
|
||||
(bundled / "utils3d.tar.gz").write_bytes(b"utils3d")
|
||||
(bundled / "moge.tar.gz").write_bytes(b"moge")
|
||||
target, archive_name = bootstrap.uv_download_target()
|
||||
archive = bundled / f"uv-{target}.{archive_name}"
|
||||
archive = root / f"uv-{target}.{archive_name}"
|
||||
if archive_name.endswith("zip"):
|
||||
with zipfile.ZipFile(archive, "w") as bundle:
|
||||
bundle.writestr("uv/uv.exe", b"uv-binary")
|
||||
@@ -978,14 +960,18 @@ class InstallEnvTest(unittest.TestCase):
|
||||
install_commands.append(command)
|
||||
return []
|
||||
|
||||
def fake_download(destination, *_args):
|
||||
shutil.copy2(archive, destination)
|
||||
return destination
|
||||
|
||||
with patch.object(
|
||||
bootstrap,
|
||||
"bundled_vendor_directory",
|
||||
return_value=bundled,
|
||||
), patch.object(
|
||||
bootstrap,
|
||||
"resolve_indexes",
|
||||
return_value=None,
|
||||
), patch.object(
|
||||
bootstrap,
|
||||
"download_uv_archive",
|
||||
side_effect=fake_download,
|
||||
), patch.object(
|
||||
bootstrap,
|
||||
"run",
|
||||
@@ -1003,13 +989,6 @@ class InstallEnvTest(unittest.TestCase):
|
||||
|
||||
self.assertEqual(uv_path.read_bytes(), b"uv-binary")
|
||||
all_commands = run_commands + install_commands
|
||||
self.assertFalse(
|
||||
any(
|
||||
"github.com" in str(value)
|
||||
for command in all_commands
|
||||
for value in command
|
||||
)
|
||||
)
|
||||
runtime_command = next(
|
||||
command
|
||||
for command in install_commands
|
||||
@@ -1017,6 +996,9 @@ class InstallEnvTest(unittest.TestCase):
|
||||
)
|
||||
self.assertFalse(any(" @ file:" in str(value) for value in runtime_command))
|
||||
self.assertFalse(any("torch" in str(value) for value in runtime_command))
|
||||
status = json.loads(Path(args.status).read_text(encoding="utf-8"))
|
||||
self.assertEqual(status["stage"], 4)
|
||||
self.assertEqual(status["stages"], 4)
|
||||
|
||||
def test_install_reuses_existing_uv(self):
|
||||
bootstrap = load_install_env()
|
||||
@@ -1062,6 +1044,78 @@ class InstallEnvTest(unittest.TestCase):
|
||||
|
||||
self.assertEqual(uv_path.read_bytes(), b"binary")
|
||||
|
||||
def test_uv_download_falls_back_to_omoolab_and_verifies_checksum(self):
|
||||
bootstrap = load_install_env()
|
||||
content = io.BytesIO()
|
||||
with zipfile.ZipFile(content, "w") as archive:
|
||||
archive.writestr("uv/uv.exe", b"uv-binary")
|
||||
payload = content.getvalue()
|
||||
|
||||
class Response(io.BytesIO):
|
||||
headers = {"Content-Length": str(len(payload))}
|
||||
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
destination = root / "uv.tmp"
|
||||
status = root / "status.json"
|
||||
urls = []
|
||||
clock_state = {"now": 0.0}
|
||||
|
||||
def clock():
|
||||
clock_state["now"] += 0.25
|
||||
return clock_state["now"]
|
||||
|
||||
def open_url(request):
|
||||
urls.append(request.full_url)
|
||||
if len(urls) == 1:
|
||||
raise OSError("official unavailable")
|
||||
return Response(payload)
|
||||
|
||||
with patch.object(
|
||||
bootstrap,
|
||||
"uv_download_target",
|
||||
return_value=("test-target", "zip"),
|
||||
), patch.dict(
|
||||
bootstrap.UV_ARTIFACTS,
|
||||
{
|
||||
"test-target": (
|
||||
"uv-test.zip",
|
||||
hashlib.sha256(payload).hexdigest(),
|
||||
)
|
||||
},
|
||||
), patch.dict(
|
||||
bootstrap._uv_download_openers,
|
||||
{
|
||||
bootstrap.UV_OFFICIAL_BASE_URL: SimpleNamespace(
|
||||
open=open_url
|
||||
),
|
||||
bootstrap.UV_MIRROR_BASE_URL: SimpleNamespace(
|
||||
open=open_url
|
||||
),
|
||||
},
|
||||
), patch.object(
|
||||
bootstrap,
|
||||
"write_status",
|
||||
) as write_status:
|
||||
result = bootstrap.download_uv_archive(
|
||||
destination,
|
||||
status,
|
||||
0.0,
|
||||
1.0,
|
||||
{},
|
||||
clock=clock,
|
||||
)
|
||||
|
||||
self.assertEqual(result.read_bytes(), payload)
|
||||
self.assertTrue(urls[0].startswith(bootstrap.UV_OFFICIAL_BASE_URL))
|
||||
self.assertTrue(urls[1].startswith(bootstrap.UV_MIRROR_BASE_URL))
|
||||
self.assertEqual(bootstrap.UV_OFFICIAL_CONNECT_TIMEOUT, 3.0)
|
||||
self.assertEqual(bootstrap.UV_MIRROR_CONNECT_TIMEOUT, 15.0)
|
||||
messages = [call.args[2] for call in write_status.call_args_list]
|
||||
self.assertTrue(any("uv (mirror)" in value for value in messages))
|
||||
self.assertTrue(any("B/s" in value for value in messages))
|
||||
self.assertFalse(any("left" in value for value in messages))
|
||||
|
||||
def test_install_stages_use_only_runtime_packages(self):
|
||||
bootstrap = load_install_env()
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
@@ -1244,15 +1298,13 @@ class InstallEnvTest(unittest.TestCase):
|
||||
)
|
||||
self.assertEqual(report, {})
|
||||
|
||||
def test_install_uv_extracts_bundled_archive(self):
|
||||
def test_install_uv_extracts_downloaded_archive(self):
|
||||
bootstrap = load_install_env()
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
uv_path = root / "uv"
|
||||
bundled = root / "bundled"
|
||||
bundled.mkdir(parents=True)
|
||||
target, archive_name = bootstrap.uv_download_target()
|
||||
archive = bundled / f"uv-{target}.{archive_name}"
|
||||
archive = root / f"uv-{target}.{archive_name}"
|
||||
if archive_name.endswith("zip"):
|
||||
with zipfile.ZipFile(archive, "w") as bundle:
|
||||
bundle.writestr("uv/uv.exe", b"uv-binary")
|
||||
@@ -1262,30 +1314,32 @@ class InstallEnvTest(unittest.TestCase):
|
||||
info = tarfile.TarInfo("uv")
|
||||
info.size = len(content)
|
||||
tar.addfile(info, io.BytesIO(content))
|
||||
def fake_download(destination, *_args):
|
||||
shutil.copy2(archive, destination)
|
||||
return destination
|
||||
|
||||
with patch.object(
|
||||
bootstrap,
|
||||
"bundled_vendor_directory",
|
||||
return_value=bundled,
|
||||
"download_uv_archive",
|
||||
side_effect=fake_download,
|
||||
):
|
||||
bootstrap.install_uv(uv_path, str(root / "status.json"))
|
||||
|
||||
self.assertEqual(uv_path.read_bytes(), b"uv-binary")
|
||||
|
||||
def test_install_uv_raises_when_bundled_missing(self):
|
||||
def test_install_uv_raises_when_download_fails(self):
|
||||
bootstrap = load_install_env()
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
uv_path = root / "uv"
|
||||
bundled = root / "bundled"
|
||||
bundled.mkdir()
|
||||
with patch.object(
|
||||
bootstrap,
|
||||
"bundled_vendor_directory",
|
||||
return_value=bundled,
|
||||
"download_uv_archive",
|
||||
side_effect=RuntimeError("all uv sources failed"),
|
||||
):
|
||||
with self.assertRaisesRegex(
|
||||
RuntimeError,
|
||||
"Bundled uv is missing",
|
||||
"all uv sources failed",
|
||||
):
|
||||
bootstrap.install_uv(uv_path, str(root / "status.json"))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user