diff --git a/openhcs/core/debug/debug_runtime.py b/openhcs/core/debug/debug_runtime.py index b935e02f5..657687aef 100644 --- a/openhcs/core/debug/debug_runtime.py +++ b/openhcs/core/debug/debug_runtime.py @@ -132,33 +132,39 @@ class DebugBoundary(ABC, metaclass=AutoRegisterMeta): name: ClassVar[str | None] = None progress_status: ClassVar[type[ProgressStatus]] + + @classmethod def reported_output_refs( - self, output_artifacts: DebugArtifactRefProjection, + cls, output_artifacts: DebugArtifactRefProjection, ) -> tuple[DebugArtifactRef, ...]: return () + @classmethod def event_artifact_projection( - self, + cls, output_artifacts: DebugArtifactRefProjection, input_artifacts: DebugArtifactRefProjection, ) -> DebugArtifactRefProjection: return input_artifacts - def validate_exception(self, exception: BaseException | None) -> None: + @classmethod + def validate_exception(cls, exception: BaseException | None) -> None: if exception is not None: - raise ValueError(f"{self.name!r} debug events cannot carry an exception.") + raise ValueError(f"{cls.name!r} debug events cannot carry an exception.") class ReportsOutputArtifactsDebugBoundary: """Trait for boundaries that report the artifacts the invocation produced.""" + @classmethod def reported_output_refs( - self, output_artifacts: DebugArtifactRefProjection, + cls, output_artifacts: DebugArtifactRefProjection, ) -> tuple[DebugArtifactRef, ...]: return output_artifacts.refs + @classmethod def event_artifact_projection( - self, + cls, output_artifacts: DebugArtifactRefProjection, input_artifacts: DebugArtifactRefProjection, ) -> DebugArtifactRefProjection: @@ -179,9 +185,10 @@ class ExceptionDebugBoundary(ReportsOutputArtifactsDebugBoundary, DebugBoundary) name = "exception" progress_status = ErrorProgressStatus - def validate_exception(self, exception: BaseException | None) -> None: + @classmethod + def validate_exception(cls, exception: BaseException | None) -> None: if exception is None: - raise ValueError(f"{self.name!r} debug events require an exception.") + raise ValueError(f"{cls.name!r} debug events require an exception.") class DebugWorkerState(ABC, metaclass=AutoRegisterMeta): diff --git a/openhcs/processing/backends/assemblers/blending.py b/openhcs/processing/backends/assemblers/blending.py index d0154da1e..bc4a5776e 100644 --- a/openhcs/processing/backends/assemblers/blending.py +++ b/openhcs/processing/backends/assemblers/blending.py @@ -54,7 +54,7 @@ def weighted_samples(self, tile, mask, affine_sampler: Callable) -> tuple: fy, fx = self.fractional_yx if fy == 0 and fx == 0: return tile * mask, mask - array_module = MemoryType(detect_memory_type(tile)).import_module() + array_module = MemoryType(detect_memory_type(tile)).library.module identity_matrix = array_module.ones(2, dtype=array_module.float64) kwargs = { "offset": (-fy, -fx), diff --git a/tests/unit/test_debug_runtime.py b/tests/unit/test_debug_runtime.py index 2ced2b70b..59fb5a6c8 100644 --- a/tests/unit/test_debug_runtime.py +++ b/tests/unit/test_debug_runtime.py @@ -21,7 +21,9 @@ UngroupedScope, ) from openhcs.core.execution.compiled_step_plan import CompiledStepPlan +from openhcs.core.debug.debug_views import runtime_inspection_view from openhcs.core.debug.debug_runtime import ( + ReportsOutputArtifactsDebugBoundary, NoOpDebugExecutionPolicy, DebugArtifactRef, DebugArtifactRefProjection, @@ -404,11 +406,11 @@ def sink_install_request( def test_debug_boundaries_own_progress_status_and_artifact_policy(): assert BeforeInvocationDebugBoundary.progress_status is StartedProgressStatus - assert not BeforeInvocationDebugBoundary.reports_output_artifacts + assert not issubclass(BeforeInvocationDebugBoundary, ReportsOutputArtifactsDebugBoundary) assert AfterInvocationDebugBoundary.progress_status is SuccessProgressStatus - assert AfterInvocationDebugBoundary.reports_output_artifacts + assert issubclass(AfterInvocationDebugBoundary, ReportsOutputArtifactsDebugBoundary) assert ExceptionDebugBoundary.progress_status is ErrorProgressStatus - assert ExceptionDebugBoundary.reports_output_artifacts + assert issubclass(ExceptionDebugBoundary, ReportsOutputArtifactsDebugBoundary) class DebugSnapshotFileManagerStub: @@ -559,7 +561,7 @@ def test_debug_artifact_boundary_has_no_name_key_reconstruction(): repository_root = Path(__file__).resolve().parents[2] targets = ( ( - repository_root / "openhcs/core/debug.py", + repository_root / "openhcs/core/debug/debug_runtime.py", "DebugArtifactRefProjection", {"from_artifact_plans"}, ), @@ -1089,7 +1091,7 @@ def test_projection_exception_contains_complete_invocation_context_without_debug assert "module='CorrectIlluminationCalculate'" in message assert "callable='correct_illumination_calculate'" in message assert "kwarg_names=('runtime_adapter', 'threshold')" in message - assert "openhcs.core.runtime_image_values.ImageMetadataPayload" in message + assert "openhcs.core.payload.runtime_image_values.ImageMetadataPayload" in message assert "plane_axis='runtime_slice'" in message assert "declared_plane_axis='runtime_slice'" in message assert "plane_index=preserved" in message @@ -1560,7 +1562,7 @@ def test_paused_worker_runtime_inspection_projects_runtime_value_store(): controller.bind_context(context) controller.apply_command(ChooseSourceGroupDebugCommand) - view_model = controller.runtime_inspection_view() + view_model = runtime_inspection_view(controller) table = view_model.sections[0].table assert table is not None @@ -1593,7 +1595,7 @@ def test_runtime_inspection_control_payload_round_trips_view_model(): controller.bind_context(context) controller.apply_command(ChooseSourceGroupDebugCommand) response = DebugRuntimeInspectionResponse( - view_model=controller.runtime_inspection_view() + view_model=runtime_inspection_view(controller) ) restored_response = DebugRuntimeInspectionResponse.from_control_response( diff --git a/tests/unit/test_primary_object_diagnostics.py b/tests/unit/test_primary_object_diagnostics.py index cc026a506..8abfa321d 100644 --- a/tests/unit/test_primary_object_diagnostics.py +++ b/tests/unit/test_primary_object_diagnostics.py @@ -412,7 +412,20 @@ def visit_Call(self, node): node.keywords = kept return node - before = DeclaredLabelVariants().visit(PayloadAttributes().visit(before)) + class MovedModule(ast.NodeTransformer): + """The morphology backend moved into its family package.""" + + MOVED = { + "openhcs.processing.backends.cellprofiler.morphology": + "openhcs.processing.backends.cellprofiler.morphology_family.morphology", + } + + def visit_ImportFrom(self, node): + node.module = self.MOVED.get(node.module, node.module) + return node + + before = MovedModule().visit( + DeclaredLabelVariants().visit(PayloadAttributes().visit(before))) # Compare the original algorithm, not docstring, signature or output ABI. assert ast.dump(ast.Module(body=before.body[1:-1], type_ignores=[])) == ast.dump( ast.Module(body=after.body[1:-1], type_ignores=[]))