Skip to content
Draft
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/polystore/streaming/receivers/napari/layer_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ def build_route_key(
display_layout: ViewerBatchDisplayPayload,
data_type: StreamingDataType,
) -> str:
"""Build hidden route key from producer identity, slice components, and type."""
"""Build a hidden route key from producer identity, layer components, and type."""
producer = StreamProducerIdentity.from_payload(producer_identity)
route_parts: list[str] = list(producer.route_parts())
for component in display_layout.components_for_mode(ViewerComponentMode.SLICE):
for component in display_layout.components_for_mode(ViewerComponentMode.LAYER):
if component not in component_info:
raise ValueError(
f"Napari route key missing slice component {component!r}."
f"Napari route key missing layer component {component!r}."
)
route_parts.append(f"{component}_{component_info[component]}")

Expand Down
22 changes: 11 additions & 11 deletions tests/test_streaming_receiver_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,19 @@ def test_named_main_outputs_share_projection_and_keep_exact_provenance() -> None
),
data_type=StreamingDataType.IMAGE,
)
slice_layout = ViewerBatchDisplayPayload(
component_modes={"channel": "slice"},
layer_layout = ViewerBatchDisplayPayload(
component_modes={"channel": "layer"},
component_order=("channel",),
)
assert build_route_key(
producer_identity=first,
component_info={"channel": 1},
display_layout=slice_layout,
display_layout=layer_layout,
data_type=StreamingDataType.IMAGE,
) != build_route_key(
producer_identity=second,
component_info={"channel": 2},
display_layout=slice_layout,
display_layout=layer_layout,
data_type=StreamingDataType.IMAGE,
)

Expand Down Expand Up @@ -285,13 +285,13 @@ def test_stream_producer_display_name_authority_matches_pipeline_editor_indexing
)


def test_napari_route_key_builder_uses_producer_slice_components_and_payload_type() -> None:
def test_napari_route_key_builder_uses_producer_layer_components_and_payload_type() -> None:
producer = PipelineProducerFixture.artifact_output(
output_key="Nuclei",
step_name="Segment",
pipeline_position=2,
)
component_modes = {"well": "slice", "channel": "stack", "site": "slice"}
component_modes = {"well": "layer", "channel": "stack", "site": "layer"}
component_order = ["well", "channel", "site"]
component_info = {"well": "A01", "channel": 2, "site": 3}

Expand All @@ -318,7 +318,7 @@ def test_napari_route_key_builder_uses_producer_slice_components_and_payload_typ
assert key_shapes == "origin_pipeline_kind_artifact_projection_Nuclei_step_2_name_Segment_well_A01_site_3_shapes"


def test_napari_route_key_builder_rejects_missing_slice_component() -> None:
def test_napari_route_key_builder_rejects_missing_layer_component() -> None:
producer = PipelineProducerFixture.artifact_output(
output_key="Nuclei",
step_name="Segment",
Expand All @@ -330,26 +330,26 @@ def test_napari_route_key_builder_rejects_missing_slice_component() -> None:
producer_identity=producer,
component_info={"well": "A01"},
display_layout=ViewerBatchDisplayPayload(
component_modes={"well": "slice", "site": "slice"},
component_modes={"well": "layer", "site": "layer"},
component_order=["well", "site"],
),
data_type=StreamingDataType.IMAGE,
)
except ValueError as error:
assert "site" in str(error)
else:
raise AssertionError("missing slice component must fail loudly")
raise AssertionError("missing layer component must fail loudly")


def test_normalize_component_layout_dict_config() -> None:
display_layout = normalize_component_layout(
{
"component_modes": {"well": "slice", "channel": "stack"},
"component_modes": {"well": "layer", "channel": "stack"},
"component_order": ["well", "channel"],
}
)
assert list(display_layout.component_order) == ["well", "channel"]
assert display_layout.component_modes["well"] == "slice"
assert display_layout.component_modes["well"] == "layer"


def test_debounced_batch_engine_flush_processes_pending_once() -> None:
Expand Down
Loading