Update SnapForm to version 0.10.10 and add technical documentation

- Bump SnapForm version in uv.lock from 0.9.30 to 0.10.10.
- Introduce comprehensive technical documentation for SnapForm, detailing features, usage instructions, and development guidelines.
This commit is contained in:
2026-08-08 19:05:42 +08:00
parent d08d0e9c1a
commit aee460fe7f
22 changed files with 3905 additions and 1472 deletions

View File

@@ -1,5 +1,4 @@
import importlib.util
import inspect
import sys
import tempfile
import unittest
@@ -112,21 +111,6 @@ class HostTest(unittest.TestCase):
self.assertEqual(loads, ["model"])
self.assertEqual(cache.status()["da3"], "da3_model")
def test_http_host_has_health_jobs_auth_and_single_task_guard(self):
source = inspect.getsource(self.host.create_app)
self.assertIn('@app.get("/health")', source)
self.assertIn('@app.post("/jobs", status_code=202)', source)
self.assertIn("x_snapform_token", source)
self.assertIn("hmac.compare_digest", source)
self.assertIn("parameters[\"status\"]", source)
self.assertIn('@app.post("/clients", status_code=201)', source)
self.assertIn('@app.post("/clients/{client_id}/heartbeat")', source)
self.assertIn('@app.delete("/jobs/{job_id}", status_code=202)', source)
self.assertIn('@app.post("/models/clear")', source)
self.assertIn('@app.post("/shutdown", status_code=202)', source)
self.assertNotIn("os._exit", source)
def test_host_tracks_clients_and_rejects_shared_shutdown(self):
fake_models = SimpleNamespace(
status=lambda: {"ben2": "", "da3": ""},
@@ -218,6 +202,51 @@ class HostTest(unittest.TestCase):
self.host.remove_discovery(path, "owner")
self.assertFalse(path.exists())
def test_host_dispatches_frame_extraction_without_models(self):
fake_models = SimpleNamespace(
status=lambda: {"ben2": "", "da3": ""},
close=lambda: None,
)
with patch.object(self.host, "ModelCache", return_value=fake_models):
state = self.host.HostState("token", "instance")
state.register_client("client", "Blender")
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
input_directory = root / "frames"
input_directory.mkdir()
(input_directory / "frame-0001.jpg").touch()
(input_directory / "frame-0002.jpg").touch()
result_directory = root / "result"
status_path = root / "status.json"
state.reserve(
"job",
"client",
"extract-frames",
str(status_path),
)
state.run_job(
{
"job_id": "job",
"command": "extract-frames",
"parameters": {
"input": str(input_directory),
"output_dir": str(result_directory),
"status": str(status_path),
"video_frames": 16,
"start_frame": 1,
},
}
)
status = self.host.json.loads(
status_path.read_text(encoding="utf-8")
)
self.assertTrue(
(result_directory / "frame.0001.jpg").is_file()
)
self.assertEqual(status["state"], "succeeded")
if __name__ == "__main__":
unittest.main()