sc_tools.pipeline — Phase DAG#
Defines the pipeline phase graph as semantic slugs with explicit dependencies. Use this module to query available next steps and expected checkpoint paths.
from sc_tools.pipeline import get_available_next, get_phase_checkpoint
# What can run after QC and metadata?
completed = {"ingest_raw", "ingest_load", "qc_filter", "metadata_attach"}
next_phases = get_available_next(completed)
# -> {"preprocess"}
# Expected checkpoint path for a phase
path = get_phase_checkpoint("preprocess")
# -> "results/adata.normalized.h5ad"
- class sc_tools.pipeline.PhaseSpec(label, depends_on=<factory>, branch='main', checkpoint=None, phase_group='data_processing', required_obs=<factory>, required_obsm=<factory>, x_format='', qc_report=None, old_code='', human_in_loop=False, optional=False, iterative=False)[source]#
Bases:
objectSpecification for a single pipeline phase.
- Parameters:
label (
str) – Human-readable name shown in reports and UIs.depends_on (
list[str|tuple[str,str]]) – List of(phase_group, subphase)tuples that must be complete before this phase can start. Empty list means this is a root phase. For backward compatibility, flat slug strings are also accepted and will be auto-converted to("data_processing", slug)tuples at DAG construction time.branch (
str) – Conceptual branch name for grouping parallel tracks. Examples: “ingestion”, “main”, “scoring”, “demographics”, “meta”.checkpoint (
str|None) – Default output filename template. May contain{sample_id}or other format fields.Nonemeans the phase produces no single checkpoint file (e.g. figures-only or per-sample outputs).phase_group (
str) – The phase group this phase belongs to. Standard pipeline phases use"data_processing". Discovery phases use"discovery".required_obs (
list[str]) – obs columns that must exist after this phase completes.required_obsm (
list[str]) – obsm keys that must exist after this phase completes.x_format (
str) – Description of what X should contain (e.g. “raw counts”, “normalized”).qc_report (
str|None) – Filename template for the QC report produced by this phase (if any).old_code (
str) – Legacy phase code (e.g. “p0a”, “p1”, “p3.5b”) for documentation.human_in_loop (
bool) – If True, this phase requires human intervention to complete.optional (
bool) – If True, this phase can be skipped without breaking downstream phases.iterative (
bool) – If True, this phase can be re-entered (re-run) after completion without it being considered an error. Used for human-in-loop cycles such as manual cell typing.
- sc_tools.pipeline.get_phase(slug)[source]#
Return the
PhaseSpecfor slug.Accepts either a flat slug (
"qc_filter") or a tuple (("data_processing", "qc_filter")).
- sc_tools.pipeline.get_available_next(completed)[source]#
Return phase keys whose dependencies are all satisfied.
Excludes phases that are already complete, except for
iterativephases which can always be re-entered.
- sc_tools.pipeline.get_phase_checkpoint(slug, **kwargs)[source]#
Return the expected checkpoint path for a phase, with placeholders filled in.
Accepts either a flat slug or a
(phase_group, subphase)tuple.- Parameters:
- Returns:
Formatted checkpoint path, or
Noneif the phase has no checkpoint.- Return type:
str or None
- sc_tools.pipeline.get_dag()[source]#
Return a copy of the current phase DAG (standard + any custom phases).
Keys are
(phase_group, subphase)tuples.
- sc_tools.pipeline.extend_dag(slug, spec)[source]#
Register a custom phase (project-specific or experimental).
- Parameters:
- Raises:
ValueError – If any
depends_onentry is not registered.- Return type: