Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4a01f48
Point benchmark imports at the modules that declare them
claude Nov 17, 2026
5be330d
Restore AbstractStep's Lazy config defaults; import them
claude Nov 17, 2026
b31e551
Freeze the cell-count field base; call operations directly
claude Nov 17, 2026
ad22f41
Re-slot the concrete ImagePayload members; drop Session.view caller
claude Nov 17, 2026
4f96a69
Port the CellProfiler nuclei pipelines to MaterializationSpec
claude Nov 17, 2026
fd1456b
Give the threshold backends one shared primitive base, not a parent c…
claude Nov 17, 2026
8fb6dda
Same shared-base split for secondary propagation backends
claude Nov 17, 2026
9a7ce55
Put MethodKeyedStrategy before EnumKeyedStrategyMixin in every family
claude Nov 17, 2026
6e65855
Bare ndarrays get their spatial adapter again
claude Nov 17, 2026
b6dc772
Put adopt_compiled_execution's body back under its own def
claude Nov 17, 2026
5645383
Fix two runtime NameErrors: stale `request` local, missing `import zmq`
claude Nov 17, 2026
4af1247
Re-import the names projected dataclasses resolve at runtime
claude Nov 17, 2026
1bc9422
normalize_clause_value is a classmethod, like its sibling matches
claude Nov 17, 2026
adea3ed
Restore the dataclass-annotation imports that cannot close a cycle
claude Nov 17, 2026
eb5ce53
Port to the siblings' current mains: bundled copies moved forward, th…
claude Nov 22, 2026
a6ee961
Payloads, processors, constants and the device resolver speak arraybr…
claude Nov 22, 2026
0b13760
The global config is objectstate's one holder: set_global_config, liv…
claude Nov 22, 2026
4709e13
An array no plan placed goes to its library's first device, said once
claude Nov 22, 2026
eb25663
Tests speak the siblings' current names: libraries, devices, the stor…
claude Nov 22, 2026
7b28e03
Merge remote-tracking branch 'origin/claude/bold-gates-tp8mwn' into p…
claude Nov 22, 2026
ef407d9
Sibling floors say what the code was ported against; three leftovers …
claude Nov 22, 2026
db9e83b
An axis is written to JSON as its boundary name, as its family alread…
claude Nov 22, 2026
1bbc0c6
Open plain TIFF folders without Java; fix the run command's second ru…
claude Nov 22, 2026
efeb830
The run command says why a stage failed
claude Nov 22, 2026
1c92cab
The agent benchmark checks a task from the plate a run wrote
claude Nov 22, 2026
ec7755f
The agent benchmark writes one task a check can read
claude Nov 22, 2026
01e56e0
The agent benchmark builds a task by its id and has its own command
claude Nov 22, 2026
695fcfc
The projection task's planes are images, and its answer is one plane
claude Nov 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmark/adapters/cellprofiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
materialize_source_binding_workspace,
)
from openhcs.core.source.source_bindings import ImportedMetadataTable
from openhcs.core.config.pipeline_config.partition_filter import PartitionFilterProcessor
from openhcs.core.config.partition_filter import PartitionFilterProcessor
from benchmark.equivalence.runtime import RuntimeOutputSnapshot
from openhcs.interop.cellprofiler.parser import CPPipeParser
from openhcs.interop.cellprofiler.pipeline_import import (
Expand Down
12 changes: 2 additions & 10 deletions benchmark/adapters/openhcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,7 @@ def _run_converted_cppipe_pipeline(
request: OpenHCSRunRequest,
) -> BenchmarkResult:
"""Execute a converted CellProfiler pipeline through the OpenHCS orchestrator."""
from objectstate.lazy_factory import (
ensure_global_config_context,
rebuild_lazy_config_with_new_global_reference,
)
from objectstate import set_global_config

phase_timing = PhaseTimingTrace(
run_id=f"{request.dataset_id}:{request.pipeline_name}:openhcs",
Expand Down Expand Up @@ -431,12 +428,7 @@ def _run_converted_cppipe_pipeline(
output_suffix=output_suffix,
compilation_debug_config=compilation_debug_config,
)
ensure_global_config_context(GlobalPipelineConfig, global_config)
pipeline_config = rebuild_lazy_config_with_new_global_reference(
pipeline_config,
global_config,
GlobalPipelineConfig,
)
set_global_config(GlobalPipelineConfig, global_config)
observation_export_path = (
MeasuredPipelineRunArtifact.RUNTIME_OBSERVATION.path_in(request.output_dir)
)
Expand Down
22 changes: 22 additions & 0 deletions benchmark/agent_validation/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

import argparse
import json
from pathlib import Path

from benchmark.agent_validation.corpus import AgentValidationCorpus
Expand All @@ -28,6 +29,18 @@ def _parser() -> argparse.ArgumentParser:
help="Verify a pinned human-eval-bia checkout without executing it.",
)
verify.add_argument("checkout", type=Path)
one = subparsers.add_parser(
"build-task",
help="Write one blind task that `check` can read the result of.",
)
one.add_argument("task_root", type=Path)
one.add_argument("task_id", help="the task's id, as `list` prints it")
check = subparsers.add_parser(
"check",
help="Check the plate an OpenHCS run wrote beside one task's inputs against "
"the task's held-out cases.",
)
check.add_argument("task_root", type=Path)
return parser


Expand All @@ -45,6 +58,15 @@ def main(argv: list[str] | None = None) -> int:
probe_ids = AgentValidationCorpus.build_diagnostic_bundle(args.output_root)
print(f"Wrote {len(probe_ids)} diagnostic probes to {args.output_root}")
return 0
if args.command == "build-task":
print(AgentValidationCorpus.build_task(args.task_root, args.task_id).task_id)
return 0
if args.command == "check":
assertions = AgentValidationCorpus.check_output_plate(args.task_root)
for assertion in assertions:
print(json.dumps({"name": assertion.name, "passed": assertion.passed,
"detail": assertion.detail}, sort_keys=True))
return 0 if assertions and all(assertion.passed for assertion in assertions) else 1
results = verify_upstream_checkout(args.checkout)
for result in results:
print(
Expand Down
5 changes: 5 additions & 0 deletions benchmark/agent_validation/contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ class OutputKind(Enum):
SCALAR = "scalar"
TABLE = "table"

@property
def written_as_planes(self) -> bool:
"""Whether a run's result of this kind is image planes in its output plate."""
return self in (OutputKind.ARRAY, OutputKind.LABEL_IMAGE)


class FunctionAvailabilityExpectation(Enum):
"""Expected catalogue decision before a pipeline is authored."""
Expand Down
98 changes: 89 additions & 9 deletions benchmark/agent_validation/corpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from benchmark.agent_validation.perturbations import DiagnosticPerturbationDeclaration
from benchmark.agent_validation.scoring import AttemptJournalScorer
from openhcs.core.io.pipeline_document import PipelineDocumentCodec
from openhcs.core.source.source_projection import OpenHCSPlaneAddress
from python_introspect import to_jsonable


Expand Down Expand Up @@ -72,19 +73,38 @@ def build_authoring_bundle(cls, output_root: Path) -> tuple[TaskAuthoringSpec, .
output_root.mkdir(parents=True, exist_ok=False)
specs = []
for declaration in cls.task_declarations():
task_root = output_root / declaration.task_id
input_root = task_root / "inputs"
input_root.mkdir(parents=True)
case_rows = cls._write_inputs(declaration, input_root)
spec = declaration.authoring_spec(Path("inputs"))
specs.append(spec)
_write_json(task_root / "task.json", TaskBundleRecord(spec, case_rows))
specs.append(cls._write_task(declaration, output_root / declaration.task_id))
_write_json(
output_root / "corpus.json",
CorpusBundleRecord(tuple(spec.task_id for spec in specs)),
)
return tuple(specs)

@classmethod
def build_task(cls, task_root: Path, task_id: str) -> TaskAuthoringSpec:
"""Write the blind task named `task_id`, one whose result `check_output_plate`
reads."""

checked = {declaration.task_id: declaration for declaration in cls.task_declarations()
if declaration.output_kind.written_as_planes}
if task_id not in checked:
raise ValueError(f"{task_id} is not a task whose result is checked as a plate: "
f"{', '.join(checked)}")
return cls._write_task(checked[task_id], task_root)

@classmethod
def _write_task(
cls, declaration: type[ValidationTaskDeclaration], task_root: Path,
) -> TaskAuthoringSpec:
"""One task's answer-free prompt, provenance and source images."""

input_root = task_root / "inputs"
input_root.mkdir(parents=True)
spec = declaration.authoring_spec(Path("inputs"))
_write_json(task_root / "task.json",
TaskBundleRecord(spec, cls._write_inputs(declaration, input_root)))
return spec

@classmethod
def build_diagnostic_bundle(cls, output_root: Path) -> tuple[str, ...]:
"""Write opaque flawed candidates without revealing their failure class."""
Expand Down Expand Up @@ -189,13 +209,73 @@ def score(
lifecycle_passed=journal.lifecycle_passed,
)

@classmethod
def check_output_plate(cls, task_root: Path) -> tuple[AssertionResult, ...]:
"""Check the plate an OpenHCS run wrote beside one blind task's inputs.

A case is a site of the input plate, so its result is the planes the run wrote for
that site: one plane as written, several as a stack in z order. Every held-out
assertion of the task is made on it. A case with no plane fails by name; this reads
image planes, so a task whose result is a table or a number fails here until its
result has a plane to be read from.
"""

bundle = json.loads((task_root / "task.json").read_text(encoding="utf-8"))
declaration = ValidationTaskDeclaration.get(bundle["spec"]["task_id"])
planes = cls._output_planes(task_root, task_root / bundle["spec"]["input_root"])
results: list[AssertionResult] = []
for site, case in cls._sited_cases(declaration):
written = [path for _, path in sorted(planes.get(site, ()))]
if not written:
results.append(AssertionResult(
f"{case.case_id}.output", False,
f"no output plane for site {site} in a plate beside the inputs"))
continue
stack = [tifffile.imread(path) for path in written]
actual = stack[0] if len(stack) == 1 else np.stack(stack)
results.extend(
AssertionResult(f"{case.case_id}.{assertion.name}", assertion.passed,
assertion.detail)
for assertion in declaration.assert_case(case, actual))
return tuple(results)

@staticmethod
def _output_planes(task_root: Path, input_root: Path) -> dict[int, list[tuple[int, Path]]]:
"""Each site's planes, as (z, file), in the one plate a run wrote beside the inputs:
a directory OpenHCS left its metadata in that is not the inputs."""

plates = sorted(
metadata.parent for metadata in task_root.glob("*/openhcs_metadata.json")
if metadata.parent.resolve() != input_root.resolve())
if len(plates) != 1:
raise ValueError(
f"{task_root} holds {len(plates)} output plates beside its inputs; "
"a check reads exactly one.")
planes: dict[int, list[tuple[int, Path]]] = {}
for path in sorted(plates[0].rglob("*.tif")):
parsed = OpenHCSPlaneAddress.from_filename(path.name)
if parsed is None:
continue
address = parsed.address.as_component_metadata()
planes.setdefault(int(address["site"]), []).append((int(address["z_index"]), path))
return planes

@staticmethod
def _sited_cases(
declaration: type[ValidationTaskDeclaration],
) -> tuple[tuple[int, ScoringCase], ...]:
"""Each scoring case and the site of the plate it is written to and read from."""

return tuple(enumerate(declaration.scoring_cases(), start=1))

@classmethod
def _write_inputs(
cls,
declaration: type[ValidationTaskDeclaration],
input_root: Path,
) -> tuple[TaskCaseRecord, ...]:
rows = []
for site, case in enumerate(declaration.scoring_cases(), start=1):
for site, case in cls._sited_cases(declaration):
files: list[InputFileRecord] = []
for input_value in case.inputs:
array = np.asarray(input_value.array)
Expand All @@ -212,7 +292,7 @@ def _write_inputs(
f"z{z_index:03d}_t001.tif"
)
path = input_root / filename
tifffile.imwrite(path, np.asarray(plane))
tifffile.imwrite(path, np.atleast_2d(plane))
files.append(
InputFileRecord(
input_name=input_value.name,
Expand Down
2 changes: 1 addition & 1 deletion benchmark/agent_validation/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ def scoring_cases(cls) -> tuple[ScoringCase, ...]:
ScoringCase(
"case-1",
(TaskInput("image", image, stack_axis=0),),
np.asarray([0, 4, 0, 0, 3, 0]),
np.asarray([[0, 4, 0, 0, 3, 0]]),
),
)

Expand Down
4 changes: 3 additions & 1 deletion benchmark/annotated_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
from collections.abc import Iterator
from metaclass_registry import AutoRegisterMeta
from python_introspect import to_jsonable
from openhcs.core.measurements.runtime_measurements import MeasurementRowAxisField
from openhcs.core.measurements.runtime_measurements import (
MeasurementRowAxisField,
)
from openhcs.processing.backends.cellprofiler.intensity_family.intensity import (
MeasureObjectIntensityModule,
)
Expand Down
4 changes: 3 additions & 1 deletion benchmark/equivalence/exported_relationships.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@
RelationshipAggregateFeatureContext,
RelationshipAggregateFeatureSemantics,
)
from openhcs.core.measurements.runtime_measurements import RuntimeScopedMeasurementTable
from openhcs.core.measurements.runtime_measurements import (
RuntimeScopedMeasurementTable,
)
from openhcs.core.measurements.measurement_row_materialization import (
columnar_row_values,
iter_measurement_rows,
Expand Down
8 changes: 5 additions & 3 deletions benchmark/equivalence/measurement_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
object_measurement_feature_matches_marker,
)
from openhcs.core.equivalence.policy import RuntimeEquivalencePolicy
from openhcs.core.measurements.runtime_measurements import (
from openhcs.core.measurements.measurement_declarations import (
MeasurementScope,
MeasurementStatistic,
ObjectCoreMeasurementFeature,
ObjectIdentifierFeatureMarker,
ObjectLocationFeatureMarker,
)
from openhcs.core.measurements.runtime_measurements import (
MeasurementStatistic,
ObjectCoreMeasurementFeature,
)


@dataclass(frozen=True, slots=True)
Expand Down
8 changes: 5 additions & 3 deletions benchmark/equivalence/measurement_rows.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@
MeasurementRowSourceImageName,
measurement_row_has_long_form_measurement_fields,
)
from openhcs.core.measurements.measurement_declarations import (
MeasuredObjectAnchorFeatureMarker,
RuntimeMeasurementRowIdentityContract,
)
from openhcs.core.measurements.runtime_measurements import (
MeasurementRowValueField,
MeasurementRowAxisField,
MeasurementRowValueField,
MeasurementScope,
MeasuredObjectAnchorFeatureMarker,
RuntimeMeasurementFeatureOwner,
RuntimeMeasurementRowIdentityContract,
)
from openhcs.core.payload.runtime_tabular_values import (
MeasurementObjectRowIdentity,
Expand Down
4 changes: 3 additions & 1 deletion benchmark/equivalence/object_label_measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@
RuntimeObjectMeasurementRowIdentity,
)
from openhcs.core.payload.runtime_identifier import normalize_runtime_identifier
from openhcs.core.measurements.runtime_measurements import (
from openhcs.core.measurements.measurement_declarations import (
ObjectCountFeatureMarker,
ObjectIdentifierFeatureMarker,
ObjectLocationFeatureMarker,
)
from openhcs.core.measurements.runtime_measurements import (
RuntimeMeasurementFeatureSemanticMarker,
)
from openhcs.core.artifact_store.runtime_stores import StoredRuntimeValue
Expand Down
4 changes: 3 additions & 1 deletion benchmark/equivalence/outputs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"""Runtime output snapshot construction for equivalence checks."""

from __future__ import annotations
from openhcs.core.measurements.runtime_measurements import MeasurementRowAxisField
from openhcs.core.measurements.runtime_measurements import (
MeasurementRowAxisField,
)

from abc import ABC, abstractmethod
from dataclasses import dataclass, replace
Expand Down
2 changes: 1 addition & 1 deletion benchmark/equivalence/row_identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from dataclasses import dataclass

from openhcs.core.axes.axis_declarations.component_group_scope import ComponentGroupScope
from openhcs.core.axes.component_group_scope import ComponentGroupScope
from openhcs.core.equivalence.cells import (
RuntimeCellSignature,
RuntimeMeasurementCellSignatureProjection,
Expand Down
14 changes: 9 additions & 5 deletions benchmark/equivalence/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
MeasurementBearingArtifactType,
RelationshipsArtifactType,
)
from openhcs.core.axes.axis_declarations.component_group_scope import ComponentGroupScope
from openhcs.core.axes.component_group_scope import ComponentGroupScope
from openhcs.core.measurements.measurement_row_materialization import (
iter_measurement_rows,
measurement_row_source_image_name,
Expand All @@ -54,13 +54,15 @@
RuntimeArtifactExecutionObservation,
)
from openhcs.core.source.source_matching import SourceImageSetIdentityPolicy
from openhcs.core.measurements.measurement_declarations import (
ObjectGroupInvariantFeatureMarker,
ObjectIdentifierFeatureMarker,
ObjectLocationFeatureMarker,
)
from openhcs.core.measurements.runtime_measurements import (
MeasurementScope,
MeasurementStatistic,
ObjectCoreMeasurementFeature,
ObjectGroupInvariantFeatureMarker,
ObjectIdentifierFeatureMarker,
ObjectLocationFeatureMarker,
)
from openhcs.core.payload.runtime_tabular_values import measurement_row_mapping
from openhcs.core.artifact_store.runtime_stores import StoredRuntimeValue
Expand Down Expand Up @@ -152,7 +154,9 @@
from openhcs.core.equivalence.relationships import (
RelationshipAggregateFeatureSemantics,
)
from openhcs.core.measurements.runtime_measurements import RuntimeScopedMeasurementTable
from openhcs.core.measurements.runtime_measurements import (
RuntimeScopedMeasurementTable,
)
from benchmark.equivalence.exported_relationships import (
RelationshipMeasurementSemantics,
)
Expand Down
4 changes: 3 additions & 1 deletion benchmark/equivalence/table_snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
MEASUREMENT_SPARSE_CELL,
MeasurementSparseColumnarRows,
)
from openhcs.core.measurements.measurement_declarations import (
RuntimeMeasurementRowIdentityContract,
)
from openhcs.core.measurements.runtime_measurements import (
MeasurementRowAxisField,
MeasurementScalarLiteral,
MeasurementScope,
MeasurementSubject,
MeasurementTable,
RuntimeMeasurementRowIdentityContract,
)
from openhcs.core.payload.runtime_tabular_values import (
FieldSpec,
Expand Down
Loading
Loading