Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 3 additions & 2 deletions benchmark/adapters/cellprofiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
ToolNotInstalledError,
)
from benchmark.timing import BenchmarkPhase, PhaseTimingTrace
from openhcs.constants import AllComponents, Backend
from openhcs.constants import Backend
from openhcs.core.config import GlobalPipelineConfig, WellFilterConfig
from openhcs.core.source_binding_workspace import (
SourceBindingWorkspaceMaterialization,
Expand All @@ -55,6 +55,7 @@
)
from openhcs.microscopes.source_schema import SourceSchemaFilenameParser
from openhcs.processing.backends.cellprofiler.infrastructure import MetadataModule
from openhcs.domains.microscopy.axes import Microscopy

PYTHONHASHSEED_ENV = "PYTHONHASHSEED"
DETERMINISTIC_PYTHONHASHSEED = "0"
Expand Down Expand Up @@ -439,7 +440,7 @@ def _virtual_path_well(
raise ValueError(
f"Cannot parse source-binding virtual filename {virtual_path!r}."
)
return str(parsed.required_value(AllComponents.WELL))
return str(parsed.required_value(Microscopy.Well))

@staticmethod
def _workspace_source_path(
Expand Down
4 changes: 2 additions & 2 deletions benchmark/agent_validation/perturbations.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
)
from benchmark.agent_validation.contracts import DiagnosticCheck, ScoringCase
from benchmark.agent_validation.declarations import ValidationTaskDeclaration
from openhcs.constants import GroupBy
from openhcs.core.config import (
LazyProcessingConfig,
LazyStepMaterializationConfig,
PipelineConfig,
)
from openhcs.core.pipeline_document import PipelineDocument, PipelineDocumentAuthority
from openhcs.core.steps.function_step import FunctionStep
from openhcs.core.axes import Ungrouped


class DiagnosticPerturbationDeclaration(ABC, metaclass=AutoRegisterMeta):
Expand Down Expand Up @@ -159,7 +159,7 @@ def flawed_pipeline_document(cls) -> PipelineDocument:
name="Expand labels without overlap",
processing_config=LazyProcessingConfig(
variable_components=[],
group_by=GroupBy.NONE,
group_by=Ungrouped,
),
step_materialization_config=LazyStepMaterializationConfig(
enabled=True,
Expand Down
23 changes: 12 additions & 11 deletions benchmark/bioformats_hcs_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
)
from benchmark.datasets.acquire import acquire_dataset
from benchmark.datasets.registry import DATASET_REGISTRY
from openhcs.constants import AllComponents
from openhcs.core.components.component_values import OpenHCSComponentValues
from openhcs.core.components.component_values import AxisValues
from openhcs.core.virtual_workspace_metadata import component_metadata_field
from openhcs.microscopes import create_microscope_handler
from openhcs.microscopes.bioformats import BioFormatsHandler
from openhcs.core.axes import AxisFamily
from openhcs.domains.microscopy.axes import Microscopy

BIOFORMATS_HCS_VALIDATION_CSV = "bioformats_hcs_validation.csv"
BIOFORMATS_HCS_VALIDATION_JSON = "bioformats_hcs_validation.json"
Expand Down Expand Up @@ -152,18 +153,18 @@ def validate_acquired_bioformats_hcs_dataset(

metadata_handler = handler.metadata_handler
component_values = metadata_handler.component_value_set(acquired.path)
component_keys = OpenHCSComponentValues(
component_keys = AxisValues(
(
component,
_component_keys(component_values.values_for(component)),
)
for component in AllComponents
for component in AxisFamily.active().axes
)
wells = component_keys[AllComponents.WELL]
sites = component_keys[AllComponents.SITE]
channels = component_keys[AllComponents.CHANNEL]
z_indexes = component_keys[AllComponents.Z_INDEX]
timepoints = component_keys[AllComponents.TIMEPOINT]
wells = component_keys[Microscopy.Well]
sites = component_keys[Microscopy.Site]
channels = component_keys[Microscopy.Channel]
z_indexes = component_keys[Microscopy.ZIndex]
timepoints = component_keys[Microscopy.Timepoint]
grid_dimensions = tuple(
metadata_handler.get_metadata_grid_dimensions(acquired.path)
)
Expand Down Expand Up @@ -297,7 +298,7 @@ def _result_fieldnames() -> tuple[str, ...]:

def _csv_row(result: BioFormatsHcsValidationResult) -> dict[str, object]:
row = asdict(result)
for component in AllComponents:
for component in AxisFamily.active().axes:
field_name = component_metadata_field(component)
row[field_name] = ";".join(row[field_name])
row["grid_dimensions"] = (
Expand All @@ -310,7 +311,7 @@ def _csv_row(result: BioFormatsHcsValidationResult) -> dict[str, object]:

def _json_row(result: BioFormatsHcsValidationResult) -> dict[str, object]:
row = asdict(result)
for component in AllComponents:
for component in AxisFamily.active().axes:
field_name = component_metadata_field(component)
row[field_name] = list(row[field_name])
row["grid_dimensions"] = (
Expand Down
4 changes: 2 additions & 2 deletions benchmark/demos/official30_lab_meeting.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
JSONValue,
ManifestCasePayload,
)
from openhcs.constants.constants import AllComponents
from openhcs.core.aligned_image_payload import AlignedImageSliceContext
from openhcs.core.artifacts import ArtifactType, MeasurementsArtifactType
from openhcs.core.config import (
Expand All @@ -44,6 +43,7 @@
prepare_cellprofiler_input_workspace,
)
from openhcs.processing.presets.demo_contribution import PipelineDemoContribution
from openhcs.domains.microscopy.axes import Microscopy

REPOSITORY_ROOT = Path(__file__).resolve().parents[2]
OFFICIAL30_MANIFEST_PATH = (
Expand Down Expand Up @@ -233,7 +233,7 @@ def _materialized_well_labels(
for metadata in prepared.materialization.source_metadata.values()
for value in source_component_metadata_values(
metadata,
AllComponents.WELL,
Microscopy.Well,
)
}
)
Expand Down
4 changes: 2 additions & 2 deletions benchmark/equivalence/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
RuntimeArtifactExecutionObservation,
)
from openhcs.core.runtime_exports import RuntimeExportObservation
from openhcs.constants.constants import AllComponents
from openhcs.core.source_bindings import SourceProjectionRole
from openhcs.core.source_matching import SourceImageSetIdentityPolicy
from openhcs.core.source_projection import SourceProjectionSet
Expand All @@ -34,6 +33,7 @@
METADATA_CONFIG,
OpenHCSMetadataSubdirectories,
)
from openhcs.domains.microscopy.axes import Microscopy


@dataclass(frozen=True, slots=True)
Expand Down Expand Up @@ -136,7 +136,7 @@ def image_snapshots(
if (
not paths
or not source_workspaces
or image_set_policy.is_identity_component(AllComponents.Z_INDEX)
or image_set_policy.is_identity_component(Microscopy.ZIndex)
):
return tuple(RuntimeImageSnapshot.from_image_file(path) for path in paths)
expected_paths = frozenset(path.absolute() for path in paths)
Expand Down
4 changes: 2 additions & 2 deletions benchmark/matched_cellprofiler_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
_write_progress_diagnostics,
well_throughput_start_method_from_manifest,
)
from openhcs.constants.constants import AllComponents
from openhcs.core.config import (
AnalysisConsolidationConfig,
GlobalPipelineConfig,
Expand Down Expand Up @@ -122,6 +121,7 @@
ZMQRuntimeObservationExportScope,
)
from python_introspect import to_jsonable
from openhcs.domains.microscopy.axes import Microscopy


def _parser() -> argparse.ArgumentParser:
Expand Down Expand Up @@ -1291,7 +1291,7 @@ def _run_case(args: argparse.Namespace, client: ZMQExecutionClient | None) -> in
):
raise RuntimeError("CellProfiler import did not prepare a complete document.")
source_wells = {
source_component_metadata_value(metadata, AllComponents.WELL)
source_component_metadata_value(metadata, Microscopy.Well)
for metadata in prepared.materialization.source_metadata.values()
}
wells = _select_genuine_wells(
Expand Down
4 changes: 2 additions & 2 deletions benchmark/native_synthetic_well_scaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
_native_python_executable,
)
from benchmark.well_throughput_scaling import _synthetic_well_ids
from openhcs.constants.constants import AllComponents
from openhcs.core.input_workspace import InputWorkspacePreparationRequest
from openhcs.core.source_matching import source_component_metadata_value
from openhcs.interop.cellprofiler.plate_workspace import (
prepare_cellprofiler_input_workspace,
)
from openhcs.domains.microscopy.axes import Microscopy


def _parser() -> argparse.ArgumentParser:
Expand Down Expand Up @@ -126,7 +126,7 @@ def main(argv: list[str] | None = None) -> int:
if prepared.materialization is None:
raise RuntimeError("Pipeline import has no declared source-binding planes.")
source_wells = {
source_component_metadata_value(metadata, AllComponents.WELL)
source_component_metadata_value(metadata, Microscopy.Well)
for metadata in prepared.materialization.source_metadata.values()
}
if len(source_wells) != 1 or None in source_wells or "" in source_wells:
Expand Down
6 changes: 3 additions & 3 deletions benchmark/pipelines/bbbc021_nuclei_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
LazyStepMaterializationConfig,
LazyNapariStreamingConfig,
)
from openhcs.constants.constants import VariableComponents

# ============================================================================
# SELECT BACKEND (uncomment one set)
Expand All @@ -35,6 +34,7 @@
# --- CPU Backend (numpy/scipy) ---
from benchmark.pipelines.cellprofiler_preprocess import preprocess_cpu as preprocess
from benchmark.pipelines.cellprofiler_nuclei import identify_primary_objects as segment
from openhcs.domains.microscopy.axes import Microscopy

# --- GPU Backend (pyclesperanto - OpenCL, works on AMD/NVIDIA/Intel) ---
# from benchmark.pipelines.cellprofiler_preprocess import preprocess_gpu as preprocess
Expand Down Expand Up @@ -65,7 +65,7 @@
),
name="CellProfiler Preprocessing",
processing_config=LazyProcessingConfig(
variable_components=[VariableComponents.CHANNEL]
variable_components=[Microscopy.Channel]
),
)
pipeline_steps.append(step_1)
Expand All @@ -87,7 +87,7 @@
),
name="IdentifyPrimaryObjects (Nuclei)",
processing_config=LazyProcessingConfig(
variable_components=[VariableComponents.CHANNEL]
variable_components=[Microscopy.Channel]
),
napari_streaming_config=LazyNapariStreamingConfig(),
step_materialization_config=LazyStepMaterializationConfig(),
Expand Down
6 changes: 3 additions & 3 deletions benchmark/pipelines/bbbc022_nuclei_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
LazyStepMaterializationConfig,
LazyNapariStreamingConfig,
)
from openhcs.constants.constants import VariableComponents

# ============================================================================
# SELECT BACKEND (uncomment one set)
Expand All @@ -35,6 +34,7 @@
# --- CPU Backend (numpy/scipy) ---
from benchmark.pipelines.cellprofiler_preprocess import preprocess_cpu as preprocess
from benchmark.pipelines.cellprofiler_nuclei import identify_primary_objects as segment
from openhcs.domains.microscopy.axes import Microscopy

# --- GPU Backend (pyclesperanto - OpenCL, works on AMD/NVIDIA/Intel) ---
# from benchmark.pipelines.cellprofiler_preprocess import preprocess_gpu as preprocess
Expand Down Expand Up @@ -65,7 +65,7 @@
),
name="CellProfiler Preprocessing",
processing_config=LazyProcessingConfig(
variable_components=[VariableComponents.CHANNEL]
variable_components=[Microscopy.Channel]
),
)
pipeline_steps.append(step_1)
Expand All @@ -87,7 +87,7 @@
),
name="IdentifyPrimaryObjects (Nuclei)",
processing_config=LazyProcessingConfig(
variable_components=[VariableComponents.CHANNEL]
variable_components=[Microscopy.Channel]
),
napari_streaming_config=LazyNapariStreamingConfig(),
step_materialization_config=LazyStepMaterializationConfig(),
Expand Down
5 changes: 3 additions & 2 deletions benchmark/validation/corpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from benchmark.datasets.registry import get_dataset_spec
from benchmark.validation.layouts import ValidationCorpusLayoutStrategy
from benchmark.validation.references import ValidationReferenceStrategy
from openhcs.constants import AllComponents, Microscope
from openhcs.constants import Microscope
from openhcs.core.config import LazySourceBindingsConfig, PipelineConfig
from openhcs.core.source_bindings import (
ComponentSelector,
Expand All @@ -53,6 +53,7 @@
SourceFilterSubject,
SourceSelector,
)
from openhcs.domains.microscopy.axes import Microscopy


class ValidationCorpusPreparationError(RuntimeError):
Expand Down Expand Up @@ -532,7 +533,7 @@ def source_bindings_for_validation(
origin=SourceBindingOrigin.PIPELINE_START,
component_identity=(
ComponentSelector(
component=AllComponents.CHANNEL,
component=Microscopy.Channel,
value=channel.value,
),
),
Expand Down
15 changes: 8 additions & 7 deletions benchmark/well_throughput_scaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
execute_measured_openhcs_pipeline_on_client,
)
from benchmark.timing import BenchmarkPhase, PhaseTimingTrace
from openhcs.constants.constants import AllComponents
from openhcs.core.components.parser_metaprogramming import FilenameParseResult
from openhcs.core.config import (
AnalysisConsolidationConfig,
Expand Down Expand Up @@ -80,6 +79,8 @@
ZMQRuntimeObservationExportScope,
)
from python_introspect import to_jsonable
from openhcs.domains.microscopy.axes import Microscopy
from openhcs.core.virtual_workspace_metadata import component_metadata_field

WELL_THROUGHPUT_ROWS_CSV = "well_throughput.csv"
WELL_THROUGHPUT_EVENTS_CSV = "well_throughput_progress_events.csv"
Expand Down Expand Up @@ -3139,7 +3140,7 @@ def _replicate_source_binding_workspace_wells(

available_source_wells = tuple(
dict.fromkeys(
projection.address.value_for(AllComponents.WELL)
projection.address.value_for(Microscopy.Well)
for projection in source_projections.entries.values()
if projection.address is not None
)
Expand Down Expand Up @@ -3173,7 +3174,7 @@ def _replicate_source_binding_workspace_wells(
f"Source projection ref disagrees with workspace mapping: {virtual_path!r}"
)
if (
projection.address.value_for(AllComponents.WELL)
projection.address.value_for(Microscopy.Well)
not in selected_source_well_keys
):
continue
Expand All @@ -3188,7 +3189,7 @@ def _replicate_source_binding_workspace_wells(
f"Source projection address disagrees with virtual path: {virtual_path!r}"
)
for well_id in target_wells:
site = parsed.required_value(AllComponents.SITE)
site = parsed.required_value(Microscopy.Site)
expanded_path = _synthetic_well_virtual_path(
parser,
str(virtual_path),
Expand Down Expand Up @@ -3242,7 +3243,7 @@ def _replicate_source_binding_workspace_wells(
)
)
main_metadata[FIELDS.IMAGE_FILES] = expanded_image_files
main_metadata[FIELDS.WELLS] = {well_id: None for well_id in target_wells}
main_metadata[component_metadata_field(Microscopy.Well)] = {well_id: None for well_id in target_wells}
AtomicMetadataWriter().replace_subdirectory_metadata(
metadata_path, FIELDS.DEFAULT_SUBDIRECTORY, main_metadata
)
Expand All @@ -3259,8 +3260,8 @@ def _synthetic_well_virtual_path(
filename = parser.construct_filename(
parsed.with_values(
(
(AllComponents.WELL, well_id),
(AllComponents.SITE, site),
(Microscopy.Well, well_id),
(Microscopy.Site, site),
)
)
)
Expand Down
Loading
Loading