phenotypic.gui.builder._conversion_dag.from_pipeline_dag#

phenotypic.gui.builder._conversion_dag.from_pipeline_dag(pipeline: ImagePipeline) _DagBuilderState[source]#

Convert an ImagePipeline to a DAG-shaped BuilderState.

Steps (spec §5.4):

  1. Construct an empty BuilderState (the root BuilderScope auto-seeds an InputImage block via its __post_init__).

  2. Walk pipeline.get_ops() + get_meas() + get_post() minting one BlockNode per entry and adding "image" edges between consecutive entries (plus from InputImage to the first entry).

  3. For each block, extract op-typed parameters via the registry’s ParamInfo metadata into embedded aux blocks + aux edges. Recursive walks handle aux-of-aux + container aux.

  4. Track an id(op) block_id map: when the same Python instance appears in both _ops and a consumer’s aux param (legacy shared-instance edge case), deep-copy the aux source into a fresh block and append an info toast to state.toast_queue.

  5. Copy pipeline.name, pipeline._desc, pipeline.nrows, and pipeline.ncols to the root scope; container scopes leave nrows/ncols as None.

Parameters:

pipeline (ImagePipeline) – The ImagePipeline to mirror.

Returns:

A BuilderState whose root scope reproduces the pipeline.

Return type:

_DagBuilderState

Examples

Mirror a tiny ImagePipeline back into a DAG BuilderState. The auto-seeded InputImage block sits at index 0 of the root scope’s blocks list and the mirrored op follows at index 1:

>>> from phenotypic import ImagePipeline
>>> from phenotypic.enhance import GaussianBlur
>>> from phenotypic.data import load_synth_yeast_plate
>>> from phenotypic.gui.builder._conversion_dag import (
...     from_pipeline_dag,
... )
>>> pipeline = ImagePipeline(ops=[GaussianBlur()], name="demo")
>>> state = from_pipeline_dag(pipeline)
>>> [b.class_name for b in state.root.blocks]
['InputImage', 'GaussianBlur']
>>> _ = load_synth_yeast_plate()  # microbiology context anchor