fix: remove slow system git build dependency

This commit is contained in:
CoolBoy
2026-08-15 19:47:24 +08:00
parent 467eaccd59
commit 85f6cb5157
8 changed files with 85 additions and 127 deletions

View File

@@ -40,6 +40,12 @@ class HostedAgentEntrypointTests(unittest.TestCase):
self.assertFalse(readiness["ready"])
self.assertEqual("state_sync_unhealthy", readiness["reason"])
def test_runtime_image_uses_python_git_client_without_apt_layer(self) -> None:
dockerfile = (ROOT_DIR / "Dockerfile").read_text(encoding="utf-8")
requirements = (ROOT_DIR / "requirements.txt").read_text(encoding="utf-8")
self.assertNotIn("apt-get", dockerfile)
self.assertIn("dulwich", requirements.casefold())
if __name__ == "__main__":
unittest.main()

View File

@@ -1,6 +1,5 @@
from __future__ import annotations
import subprocess
import tempfile
import unittest
from datetime import datetime, timezone
@@ -9,6 +8,8 @@ from unittest.mock import patch
import sys
from dulwich import porcelain
ROOT = Path(__file__).resolve().parents[1]
MODULE_ROOT = ROOT / "modelhub_submmit_api"
if str(MODULE_ROOT) not in sys.path:
@@ -20,7 +21,6 @@ from hf_discovery import HuggingFaceDiscovery, parse_model_card_front_matter #
from official_capabilities import OfficialCapabilityRegistry # noqa: E402
from routing_engine import SuccessFirstRoutingEngine # noqa: E402
from state_sync import StateGitSync # noqa: E402
from state_sync import StateSyncError # noqa: E402
class OfficialClient:
@@ -139,7 +139,7 @@ class SuperAgentTests(unittest.TestCase):
restored_project = root / "restored"
project.mkdir()
restored_project.mkdir()
subprocess.run(["git", "init", "--bare", str(remote)], check=True, stdout=subprocess.DEVNULL)
porcelain.init(remote, bare=True)
write_json(project / ".modelhub_state" / "account_capacity.json", {"version": 1})
credentials = {"username": "tester", "email": "tester@example.com", "password": "secret-value"}
manager = StateGitSync(
@@ -208,19 +208,6 @@ class SuperAgentTests(unittest.TestCase):
)
)
def test_missing_git_has_actionable_state_sync_error(self) -> None:
with tempfile.TemporaryDirectory() as temporary_dir:
manager = StateGitSync(
project_root=Path(temporary_dir),
credentials={"username": "u", "email": "e@example.com", "password": "p"},
remote="unused",
log_fn=lambda _: None,
)
with patch("state_sync.subprocess.run", side_effect=FileNotFoundError("git")):
with self.assertRaisesRegex(StateSyncError, "rebuild the service image"):
manager._git("version")
manager.close()
def test_config_patch_requires_repeated_cross_model_success(self) -> None:
with tempfile.TemporaryDirectory() as temporary_dir:
root = Path(temporary_dir)