feat: Bump version to 0.11.0 and update dependencies

- Updated ONNX Runtime to 1.24.4 and replaced OpenCV with PyAV 17.0.0 in the installation environment.
- Enhanced model downloading logic to prioritize Hugging Face and fallback to OmooLab R2, with improved error handling and status reporting.
- Introduced a new environment revision file for shared metadata.
- Refactored video frame extraction to utilize the PyAV library instead of OpenCV.
- Improved installation process to handle retries across specified PyPI indexes.
- Added tests for download progress reporting and model downloading behavior.
This commit is contained in:
2026-08-14 14:47:40 +08:00
parent 2ad30bf4a3
commit 5255eb4e96
12 changed files with 561 additions and 304 deletions

View File

@@ -521,7 +521,59 @@ class InstallEnvTest(unittest.TestCase):
self.assertEqual(first.kwargs["stages"], 8)
self.assertEqual(first.kwargs["stage_label"], "pytorch deps")
def test_run_install_retries_once_with_mirror(self):
def test_run_install_heartbeat_reports_package_count(self):
bootstrap = load_install_env()
class SlowLines:
def __iter__(self):
yield "Resolved 3 packages in 1.0s\n"
time.sleep(0.6)
class FakeProcess:
def __init__(self, lines):
self.stdout = lines
def wait(self):
return 0
clock_state = {"now": 0.0}
def fake_clock():
clock_state["now"] += 6.0
return clock_state["now"]
fake_process = FakeProcess(SlowLines())
with patch.object(
bootstrap.subprocess,
"Popen",
return_value=fake_process,
), patch.object(bootstrap, "write_status") as mocked_write:
bootstrap._run_install_once(
"status.json",
2,
2,
"ONNX Runtime",
["uv", "pip", "install", "onnxruntime"],
None,
0.10,
0.85,
fake_clock,
)
heartbeats = [
call
for call in mocked_write.call_args_list
if call.args[2].startswith("Downloading")
]
self.assertTrue(heartbeats)
self.assertTrue(
any("3 packages" in call.args[2] for call in heartbeats)
)
for call in heartbeats:
self.assertNotIn("elapsed", call.args[2])
self.assertNotIn("eta_seconds", call.kwargs)
def test_run_install_retries_across_indexes(self):
bootstrap = load_install_env()
previous = bootstrap._resolved_pypi_index
bootstrap._resolved_pypi_index = None
@@ -546,32 +598,44 @@ class InstallEnvTest(unittest.TestCase):
self.assertEqual(installed, ["numpy==1.26.4"])
self.assertEqual(mocked_install.call_count, 2)
# 未指定源时默认国内镜像优先,第一个镜像失败后切到第二个镜像。
self.assertEqual(
mocked_install.call_args_list[0].args[5],
{"UV_INDEX_URL": bootstrap.PYPI_MIRRORS[0]},
)
self.assertEqual(
mocked_install.call_args_list[1].args[5],
{"PIP_INDEX_URL": bootstrap.PYPI_MIRRORS[0]},
{"UV_INDEX_URL": bootstrap.PYPI_MIRRORS[1]},
)
def test_formats_elapsed_time(self):
def test_run_install_uses_only_configured_index(self):
bootstrap = load_install_env()
self.assertEqual(bootstrap.format_elapsed(12), "12s")
self.assertEqual(bootstrap.format_elapsed(83), "1m 23s")
def test_onnx_runtime_estimate_decreases_with_progress(self):
bootstrap = load_install_env()
first = bootstrap.estimated_remaining(
"ONNX Runtime",
bootstrap.AI_COMPONENTS_SLICE[0],
)
second = bootstrap.estimated_remaining(
"ONNX Runtime",
sum(bootstrap.AI_COMPONENTS_SLICE) / 2,
previous = bootstrap._resolved_pypi_index
bootstrap._resolved_pypi_index = (
"https://pypi.tuna.tsinghua.edu.cn/simple"
)
try:
with patch.object(
bootstrap,
"_run_install_once",
return_value=["numpy==1.26.4"],
) as mocked_install:
installed = bootstrap.run_install(
"status.json",
3,
8,
"ai deps",
["uv", "pip", "install", "x"],
)
finally:
bootstrap._resolved_pypi_index = previous
self.assertEqual(first, bootstrap.INSTALL_ESTIMATES["ONNX Runtime"])
self.assertGreater(second, 0)
self.assertLess(second, first)
self.assertEqual(installed, ["numpy==1.26.4"])
self.assertEqual(mocked_install.call_count, 1)
self.assertEqual(
mocked_install.call_args.args[5],
{"UV_INDEX_URL": "https://pypi.tuna.tsinghua.edu.cn/simple"},
)
def test_resolve_indexes_uses_configured_pypi_index(self):
bootstrap = load_install_env()
@@ -584,6 +648,18 @@ class InstallEnvTest(unittest.TestCase):
)
def test_resolve_indexes_uses_environment_override(self):
bootstrap = load_install_env()
with patch.dict(
os.environ,
{"UV_INDEX_URL": "https://pypi.example/simple"},
):
bootstrap.resolve_indexes(SimpleNamespace(pypi_index=None))
self.assertEqual(
bootstrap._resolved_pypi_index,
"https://pypi.example/simple",
)
def test_resolve_indexes_falls_back_to_pip_index_url(self):
bootstrap = load_install_env()
with patch.dict(
os.environ,
@@ -607,7 +683,7 @@ class InstallEnvTest(unittest.TestCase):
bootstrap._resolved_pypi_index = previous_pypi
self.assertEqual(
env["PIP_INDEX_URL"],
env["UV_INDEX_URL"],
"https://pypi.tuna.tsinghua.edu.cn/simple",
)
self.assertEqual(