Refactor AI Host to Backend Service and update related components
- Renamed references from "AI Host" to "Backend Service" throughout the codebase for consistency. - Updated the registration and unregistration of context menus to include the Outliner. - Changed the job protocol versioning and related constants for clarity. - Modified the runtime installation messages and error handling to reflect the new terminology. - Adjusted the user interface labels and messages in panels and operators to align with the new Backend Service terminology. - Updated tests to ensure they reflect the changes in naming and functionality. - Changed default value for background depth in geometry nodes asset to -1.0 for better handling of depth planes.
This commit is contained in:
@@ -43,10 +43,15 @@ class AddonTest(unittest.TestCase):
|
||||
append=lambda draw: cls.context_menu_draws.append(draw),
|
||||
remove=lambda draw: cls.context_menu_draws.remove(draw),
|
||||
),
|
||||
OUTLINER_MT_object=SimpleNamespace(
|
||||
append=lambda draw: cls.outliner_menu_draws.append(draw),
|
||||
remove=lambda draw: cls.outliner_menu_draws.remove(draw),
|
||||
),
|
||||
)
|
||||
cls.registered = []
|
||||
cls.status_bar_draws = []
|
||||
cls.context_menu_draws = []
|
||||
cls.outliner_menu_draws = []
|
||||
fake_bpy.utils = SimpleNamespace(
|
||||
register_class=cls.registered.append,
|
||||
unregister_class=cls.registered.remove,
|
||||
@@ -80,6 +85,7 @@ class AddonTest(unittest.TestCase):
|
||||
self.registered.clear()
|
||||
self.status_bar_draws.clear()
|
||||
self.context_menu_draws.clear()
|
||||
self.outliner_menu_draws.clear()
|
||||
self.addon.operators._active_job = None
|
||||
self.addon.image_depth._last_depth_plane_model = "BASE"
|
||||
self.addon.image_mesh._last_mesh_model = "BASE"
|
||||
@@ -107,6 +113,10 @@ class AddonTest(unittest.TestCase):
|
||||
self.context_menu_draws,
|
||||
[self.addon.draw_image_context_menu],
|
||||
)
|
||||
self.assertEqual(
|
||||
self.outliner_menu_draws,
|
||||
[self.addon.draw_image_context_menu],
|
||||
)
|
||||
|
||||
self.addon.unregister()
|
||||
|
||||
@@ -116,6 +126,7 @@ class AddonTest(unittest.TestCase):
|
||||
)
|
||||
self.assertEqual(self.status_bar_draws, [])
|
||||
self.assertEqual(self.context_menu_draws, [])
|
||||
self.assertEqual(self.outliner_menu_draws, [])
|
||||
|
||||
def test_registers_depth_plane_operator_without_cache_rebuild(self):
|
||||
self.assertIn(
|
||||
@@ -149,7 +160,8 @@ class AddonTest(unittest.TestCase):
|
||||
|
||||
menu = self.addon.SnapFormImageMenu()
|
||||
menu.layout = Layout()
|
||||
menu.draw(None)
|
||||
with patch.object(self.addon.runtime, "runtime_ready", return_value=True):
|
||||
menu.draw(None)
|
||||
|
||||
self.assertEqual(
|
||||
calls,
|
||||
@@ -161,6 +173,34 @@ class AddonTest(unittest.TestCase):
|
||||
],
|
||||
)
|
||||
|
||||
def test_image_context_menu_only_installs_backend_when_missing(self):
|
||||
calls = []
|
||||
|
||||
class Operator:
|
||||
job_type = None
|
||||
|
||||
class Layout:
|
||||
operator_context = None
|
||||
|
||||
def operator(self, identifier, **options):
|
||||
operator = Operator()
|
||||
calls.append((identifier, options, operator))
|
||||
return operator
|
||||
|
||||
def separator(self):
|
||||
calls.append("separator")
|
||||
|
||||
menu = self.addon.SnapFormImageMenu()
|
||||
menu.layout = Layout()
|
||||
with patch.object(self.addon.runtime, "runtime_ready", return_value=False):
|
||||
menu.draw(None)
|
||||
|
||||
self.assertEqual(len(calls), 1)
|
||||
identifier, options, operator = calls[0]
|
||||
self.assertEqual(identifier, "snapform.run_job")
|
||||
self.assertEqual(options["text"], "Install Backend")
|
||||
self.assertEqual(operator.job_type, "INSTALL_RUNTIME")
|
||||
|
||||
def test_image_mesh_reference_plane_matches_image_empty_bounds(self):
|
||||
source_object = SimpleNamespace(
|
||||
data=SimpleNamespace(size=(401, 201)),
|
||||
@@ -1945,13 +1985,13 @@ class AddonTest(unittest.TestCase):
|
||||
def test_host_panel_exposes_shared_host_state_and_controls(self):
|
||||
self.assertIn(self.addon.HostPanel, self.addon.CLASSES)
|
||||
self.assertIn(self.addon.ControlHost, self.addon.CLASSES)
|
||||
self.assertEqual(self.addon.HostPanel.bl_label, "Host")
|
||||
self.assertEqual(self.addon.HostPanel.bl_label, "AI Backend")
|
||||
|
||||
def test_ai_operation_restarts_a_manually_stopped_host(self):
|
||||
runtime = self.addon.runtime
|
||||
connection = runtime.HostConnection(51234, "token", 42, "host")
|
||||
health = {
|
||||
"host_schema": runtime.HOST_SCHEMA,
|
||||
"job_protocol_version": runtime.JOB_PROTOCOL_VERSION,
|
||||
"instance_id": "host",
|
||||
"busy": False,
|
||||
"clients": 1,
|
||||
|
||||
@@ -689,7 +689,7 @@ class BootstrapRuntimeTest(unittest.TestCase):
|
||||
bootstrap.install(args)
|
||||
|
||||
ready = json.loads(
|
||||
(runtime_dir / "snapform_ready.json").read_text(
|
||||
(runtime_dir / "environment_manifest.json").read_text(
|
||||
encoding="utf-8"
|
||||
)
|
||||
)
|
||||
@@ -730,7 +730,9 @@ class BootstrapRuntimeTest(unittest.TestCase):
|
||||
bootstrap.install(args)
|
||||
|
||||
self.assertFalse((runtime_dir / "partial-python.exe").exists())
|
||||
self.assertTrue((runtime_dir / "snapform_ready.json").is_file())
|
||||
self.assertTrue(
|
||||
(runtime_dir / "environment_manifest.json").is_file()
|
||||
)
|
||||
|
||||
def test_ready_runtime_is_not_cleaned(self):
|
||||
bootstrap = load_bootstrap_runtime()
|
||||
@@ -741,8 +743,14 @@ class BootstrapRuntimeTest(unittest.TestCase):
|
||||
self.create_bundled_vendor(root)
|
||||
(runtime_dir / "Scripts").mkdir()
|
||||
(runtime_dir / "Scripts" / "python.exe").write_text("python")
|
||||
(runtime_dir / "snapform_ready.json").write_text(
|
||||
json.dumps({"runtime_schema": bootstrap.RUNTIME_SCHEMA}),
|
||||
(runtime_dir / "environment_manifest.json").write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"environment_manifest_revision": (
|
||||
bootstrap.ENVIRONMENT_MANIFEST_REVISION
|
||||
)
|
||||
}
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
(runtime_dir / "marker.txt").write_text("keep")
|
||||
@@ -804,12 +812,14 @@ class BootstrapRuntimeTest(unittest.TestCase):
|
||||
):
|
||||
bootstrap.install(args)
|
||||
|
||||
self.assertTrue((runtime_dir / "snapform_ready.json").is_file())
|
||||
self.assertTrue(
|
||||
(runtime_dir / "environment_manifest.json").is_file()
|
||||
)
|
||||
status = json.loads(
|
||||
(root / "status.json").read_text(encoding="utf-8")
|
||||
)
|
||||
self.assertEqual(status["progress"], 1.0)
|
||||
self.assertIn("Runtime is ready", status["message"])
|
||||
self.assertIn("Backend Environment is ready", status["message"])
|
||||
self.assertTrue(
|
||||
any(
|
||||
"PramaLLC/BEN2" in map(str, command)
|
||||
@@ -1208,7 +1218,10 @@ class BootstrapRuntimeTest(unittest.TestCase):
|
||||
|
||||
messages = [call.args[2] for call in mocked_write.call_args_list]
|
||||
self.assertTrue(
|
||||
any("Checking Runtime" in message for message in messages)
|
||||
any(
|
||||
"Checking Backend Environment" in message
|
||||
for message in messages
|
||||
)
|
||||
)
|
||||
self.assertEqual(report, {})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user