Projects and the Pipeline Graph
What a project directory contains and how jobs and nodes form the pipeline graph
A pipeliner project is a directory that pipeliner treats as a single, self-contained unit of work. It holds every job subdirectory, a central pipeline graph file (default_pipeline.star), and a marker file (.CCPEM_pipeliner_project) that identifies the directory as a pipeliner project. Understanding what the project directory contains—and how the ProjectGraph, Process, and Node Python objects model the pipeline—is essential for anyone integrating pipeliner into automation scripts, recovering a broken project, or writing a custom job plugin. This page explains the structure and the in-memory model; it does not walk through installation or configuration (see those separate pages).
Before reading this page you should already have:
- ccpem-pipeliner installed in a Python ≥ 3.9 environment (install with
pip install ccpem-pipeliner). - A basic familiarity with Python imports and STAR-format files (used throughout RELION and pipeliner).
- An existing project directory to inspect, or the intention to create one with
PipelinerProject(make_new_project=True)— this page focuses on what already exists inside such a directory, not on how to run jobs.
The project directory
A pipeliner project is an ordinary filesystem directory that contains a specific set of files and subdirectories. The presence of the marker file .CCPEM_pipeliner_project identifies it as a managed project. The most important file is default_pipeline.star (the pipeline star file), which records the complete directed graph of jobs and data nodes.
The directory layout looks like this:
my_project/
├── .CCPEM_pipeliner_project # project marker
├── .CCPEM_pipeliner_cleanup # single append-only cleanup log
├── default_pipeline.star # the full pipeline graph
├── .relion_lock/ # directory-based write lock (present only when locked)
├── .Nodes/ # empty placeholder files for expected output nodes
├── Import/
│ └── job001/
│ ├── job.star # job parameters in STAR format
│ ├── run.job # job parameters in label==value format
│ ├── continue_job.star # parameters for a continuation run
│ ├── job_pipeline.star # this job's mini sub-graph
│ ├── default_pipeline.star # backup of the project pipeline at scheduling time
│ ├── run.out # stdout from the job runner
│ ├── run.err # stderr from the job runner
│ ├── note.txt # executed commands
│ └── PIPELINER_JOB_EXIT_SUCCESS # (or FAILED / ABORTED)
├── MotionCorr/
│ └── job002/
│ └── ...
└── ...
All pipeliner operations run relative to the current working directory; PipelinerProject does not accept a path argument and is not a context manager.
The pipeline STAR file (default_pipeline.star)
default_pipeline.star can contain up to five STAR blocks. A block is written only when it has rows, so the file of a new, empty project contains only pipeline_general:
| Block name | Contents |
|---|---|
pipeline_general | The global job counter |
pipeline_processes | One row per job: name, alias, type, status |
pipeline_nodes | One row per data node: filename and type |
pipeline_input_edges | Directed edges from node → job |
pipeline_output_edges | Directed edges from job → node |
This file is the authoritative source of truth for the pipeline graph. The job counter in pipeline_general is project-wide, so jobs receive sequential numbers regardless of type (e.g., Import/job001/, MotionCorr/job002/, CtfFind/job003/).
ProjectGraph — reading and writing the pipeline
ProjectGraph is the low-level object that reads, writes, and locks default_pipeline.star. You rarely need to instantiate it directly when using PipelinerProject, but understanding it clarifies the locking model.
from pipeliner.project_graph import ProjectGraph
# Open read-only — no lock acquired, safe to use in parallel
with ProjectGraph(name="default", read_only=True) as graph:
for proc in graph.process_list:
print(proc.name, proc.type, proc.status)
for node in graph.node_list:
print(node.name, node.toplevel_type)
Opening for writing acquires the .relion_lock directory-based lock:
with ProjectGraph(name="default", read_only=False) as graph:
# Changes made here are written back to default_pipeline.star on __exit__
...
Key constructor behaviour:
namesets the pipeline name; the file is<name>_pipeline.starinpipeline_dir(default.).read_only=True(the default) raisesRuntimeErrorif the file is an older RELION 3 format, because conversion requires writing.read_only=Falseconverts RELION 3 files in-place (moving the original to<file>.old) and acquires the lock; RELION 4 files have their node-type names mapped in memory when read, and are rewritten in pipeliner format when the writable graph is closed (no.oldbackup is kept).create_new=TrueraisesFileExistsErrorif a pipeline file already exists.- If the lock cannot be acquired within 60 seconds,
RuntimeErroris raised. - Always use
ProjectGraphas a context manager, or callclose()explicitly, to ensure the lock is released.
Attributes populated after opening:
graph.process_list— list ofProcessobjects, one per jobgraph.node_list— list ofNodeobjects, one per data filegraph.job_counter— the number of the next job to be created
The Process object
Each entry in pipeline_processes becomes a Process instance:
from pipeliner.project_graph import ProjectGraph
with ProjectGraph(read_only=True) as graph:
for proc in graph.process_list:
print(proc.name) # e.g. "MotionCorr/job002/"
print(proc.type) # e.g. "relion.motioncorr.own"
print(proc.status) # "Succeeded", "Failed", "Aborted", "Running", or "Scheduled"
print(proc.alias) # human-readable alias, or None
print(proc.outdir) # e.g. "MotionCorr" (the top-level directory)
print(proc.job_number) # integer job number, e.g. 2
print(proc.input_nodes) # list of Node objects used as input
print(proc.output_nodes) # list of Node objects produced
Important: the job type is stored in proc.type, not proc.ptype (accessing proc.ptype raises AttributeError).
Job status values (proc.status) are the exact strings:
"Succeeded"— job completed withPIPELINER_JOB_EXIT_SUCCESS"Failed"— job completed withPIPELINER_JOB_EXIT_FAILED"Aborted"— job completed withPIPELINER_JOB_EXIT_ABORTED"Running"— job is currently running (no exit file present)"Scheduled"— job is queued but not yet started (no exit file present)
The PIPELINER_JOB_ABORT_NOW file is an abort request trigger, not a status.
The Node object
Each entry in pipeline_nodes becomes a Node instance. Nodes are the edges of the directed graph — they connect the output of one job to the input of the next.
from pipeliner.project_graph import ProjectGraph
with ProjectGraph(read_only=True) as graph:
for node in graph.node_list:
print(node.name) # file path, e.g. "MotionCorr/job002/corrected_micrographs.star"
print(node.toplevel_type) # e.g. "MicrographGroupMetadata"
print(node.format) # generalised file extension, e.g. "star"
print(node.kwds) # list of keywords
print(node.output_from_process) # Process that created this node
print(node.input_for_processes_list) # list of Processes that consume this node
Node type constants
Node types are string constants defined in pipeliner.data_structure and imported from there. Pass them to add_output_node() when writing custom jobs. A selection of the most common types:
| Constant | Value | Typical file |
|---|---|---|
NODE_MICROGRAPHMOVIEGROUPMETADATA | "MicrographMovieGroupMetadata" | movies.star |
NODE_MICROGRAPHGROUPMETADATA | "MicrographGroupMetadata" | micrographs.star |
NODE_MICROGRAPHCOORDSGROUP | "MicrographCoordsGroup" | coordinates.star |
NODE_PARTICLEGROUPMETADATA | "ParticleGroupMetadata" | particles.star |
NODE_DENSITYMAP | "DensityMap" | map.mrc |
NODE_MASK3D | "Mask3D" | mask.mrc |
NODE_OPTIMISERDATA | "OptimiserData" | run_it025_optimiser.star |
NODE_ATOMCOORDS | "AtomCoords" | refined.mmcif |
NODE_LOGFILE | "LogFile" | logfile.pdf |
NODE_TILTSERIES | "TiltSeries" | — |
NODE_TOMOGRAMGROUPMETADATA | "TomogramGroupMetadata" | — |
Import them like this:
from pipeliner.data_structure import (
NODE_MICROGRAPHGROUPMETADATA,
NODE_PARTICLEGROUPMETADATA,
NODE_DENSITYMAP,
)
Per-job files
Each job directory contains several files with distinct roles:
| File | Purpose |
|---|---|
job.star | Job parameters in STAR format (for edit_jobstar() and RELION compatibility) |
run.job | Job parameters in <label> == <value> format (human-readable; for pipeliner --run_job) |
continue_job.star | STAR job file written at scheduling time, edited before calling continue_job() |
job_pipeline.star | This job's own mini sub-graph (input/output nodes only; parameters are in job.star and run.job, not here) |
default_pipeline.star | A backup copy of the project pipeline written at scheduling time — this is what pipeliner.recover_project restores from |
run.out | Standard output from the job runner |
run.err | Standard error from the job runner |
note.txt | Executed commands (written separately, not appended to run.out) |
PIPELINER_JOB_EXIT_SUCCESS / PIPELINER_JOB_EXIT_FAILED / PIPELINER_JOB_EXIT_ABORTED | Sentinel files indicating completed job status |
job_pipeline.star and the backup default_pipeline.star serve entirely different purposes. The backup is used for crash recovery; job_pipeline.star records the sub-graph structure.
continue_job.star is written when the job is first scheduled (during schedule_job()), not after the job completes. Edit it before calling continue_job() to modify parameters for the continuation.
.Nodes/ placeholder files
When a job is scheduled, pipeliner registers its expected output nodes in default_pipeline.star and creates empty placeholder files (not directories) at:
.Nodes/<TopLevelType>/<node_path>
For example, scheduling a motion-correction job that will produce MotionCorr/job002/corrected_micrographs.star creates:
.Nodes/MicrographGroupMetadata/MotionCorr/job002/corrected_micrographs.star
These marker files let other jobs and the GUI know that the output is expected, before the actual data file exists. The real output data file is written only when the job actually runs.
Project locking (.relion_lock)
The project is locked at the project level through a .relion_lock directory (not a file) placed next to default_pipeline.star. The directory-based lock is atomic on POSIX filesystems.
- The lock is acquired automatically when you open
ProjectGraphwithread_only=False. - It is released when the context manager exits or
close()is called. - Individual job directories do not have per-job locks — only the project-level
.relion_lockdirectory. - Job status is tracked by sentinel files (
PIPELINER_JOB_EXIT_*), not by locks. - If the lock directory is left behind after a crash, use
pipeliner.recover_projectto remove it and restore the pipeline from the newest per-job backup.
RELION compatibility
ProjectGraph handles pipeline files from multiple RELION versions automatically:
| Pipeline version | Read-only open | Writable open |
|---|---|---|
| ccpem-pipeliner | Read as-is | Read and write normally |
| RELION 4 | Node-type names mapped in memory; file not rewritten | Node-type names mapped in memory; file rewritten in pipeliner format when the writable session closes, with no .old backup (run pipeliner --convert_pipeline_file first to keep one) |
| RELION 3.x | Raises RuntimeError | Converts in-place; original moved to <file>.old |
To work with an existing RELION project, cd into the project directory and use pipeliner commands directly. The --new_project flag is not needed and raises ValueError if a pipeline file already exists.
Example 1 — Inspect the pipeline graph
Open the current project in read-only mode and print every job and its status.
import os
from pipeliner.project_graph import ProjectGraph
# Run this from inside the project directory
os.chdir("/path/to/my_project")
with ProjectGraph(name="default", read_only=True) as graph:
print(f"Job counter (next job number): {graph.job_counter}")
for proc in graph.process_list:
alias_str = f" (alias: {proc.alias})" if proc.alias else ""
print(f" {proc.name}{alias_str} [{proc.type}] status={proc.status}")
for node in proc.output_nodes:
print(f" -> {node.name} ({node.toplevel_type})")
Example 2 — Inspect node connectivity
For each node in the pipeline, show which job produced it and which jobs consume it.
from pipeliner.project_graph import ProjectGraph
with ProjectGraph(name="default", read_only=True) as graph:
for node in graph.node_list:
producer = (
node.output_from_process.name
if node.output_from_process
else "(none — imported externally)"
)
consumers = [
p.name for p in node.input_for_processes_list
]
print(f"Node: {node.name}")
print(f" type : {node.toplevel_type}")
print(f" produced : {producer}")
print(f" consumed : {consumers}")
Example 3 — Use node-type constants from pipeliner.data_structure or pipeliner.nodes
Node type constants can be imported from pipeliner.data_structure or pipeliner.nodes; both expose the same values. This example imports them from pipeliner.data_structure and demonstrates that the string values match what is stored in the pipeline file.
from pipeliner.data_structure import (
NODE_MICROGRAPHGROUPMETADATA,
NODE_PARTICLEGROUPMETADATA,
NODE_DENSITYMAP,
NODE_OPTIMISERDATA,
)
from pipeliner.project_graph import ProjectGraph
# Print all nodes whose type is MicrographGroupMetadata
with ProjectGraph(name="default", read_only=True) as graph:
mic_nodes = [
n for n in graph.node_list
if n.toplevel_type == NODE_MICROGRAPHGROUPMETADATA
]
print(f"Found {len(mic_nodes)} MicrographGroupMetadata nodes:")
for n in mic_nodes:
print(f" {n.name}")
RuntimeError: Error reading pipeline file default_pipeline.star
Symptom: Opening ProjectGraph raises RuntimeError with this message.
Likely causes:
- The pipeline file is in RELION 3.x format and you opened it with
read_only=True. - The file is corrupt or truncated.
Fix:
- For a RELION 3.x file opened read-only: open it for writing instead (
read_only=False) so pipeliner can convert it, or runpipeliner --convert_pipeline_file default_pipeline.starfrom the project directory. - For a corrupt file: run
pipeliner.recover_projectfrom the project directory to restoredefault_pipeline.starfrom the newest per-job backup copy.
RuntimeError: Trying to open pipeline … could not acquire lock after waiting for 60 seconds
Symptom: Opening ProjectGraph with read_only=False raises this error.
Likely cause: Another process holds the .relion_lock directory lock, or a previous process crashed and left the lock directory behind.
Fix: If no other pipeliner process is running, use pipeliner.recover_project to remove the stale .relion_lock directory and restore the pipeline file.
FileExistsError: Pipeline file default_pipeline.star already exists
Symptom: ProjectGraph(create_new=True) raises this error.
Likely cause: You are trying to create a new project in a directory that already contains a pipeline file.
Fix: Either change to an empty directory, or open the existing project without create_new=True. Note that the CLI pipeliner --new_project raises ValueError (not FileExistsError) in the same situation.
FileNotFoundError: ERROR: Pipeline file default_pipeline.star not found
Symptom: Opening ProjectGraph raises this error.
Likely cause: The current working directory does not contain the pipeline file. (PipelinerProject() does not raise this message: see the next two entries.)
Fix: Confirm you are inside the project directory (ls default_pipeline.star). If the file has been deleted, pipeliner.recover_project cannot help (it requires default_pipeline.star to already exist); copy the newest default_pipeline.star backup from one of the job subdirectories (*/job*/default_pipeline.star) back to the project root.
FileNotFoundError: Could not find a project to open in directory … and "make_new_project" was not set
Symptom: PipelinerProject() raises this error.
Likely cause: The current working directory is not a project: it has neither a .CCPEM_pipeliner_project marker nor a pipeline file.
Fix: cd into the project directory before creating PipelinerProject, or pass make_new_project=True to create a new project there.
ValueError: A pipeliner project has been found … but the expected pipeline file … is missing
Symptom: PipelinerProject() raises this error.
Likely cause: .CCPEM_pipeliner_project exists (marking the directory as a project) but default_pipeline.star has been deleted.
Fix: Copy the most recent default_pipeline.star from a job subdirectory back to the project root, or run pipeliner.recover_project after restoring the file manually.
Project appears locked after a crash; pipeliner.recover_project is needed
Symptom: All pipeliner write operations fail because .relion_lock is present but no pipeliner process is running.
Fix: Run pipeliner.recover_project from the project directory. Without the -y / --assume-yes flag it will prompt for confirmation before removing .relion_lock and restoring default_pipeline.star from the newest per-job backup. Any jobs scheduled after that backup was written will be lost from the restored pipeline.
AttributeError when accessing proc.ptype
Symptom: Accessing proc.ptype on a Process object raises AttributeError.
Likely cause: The job type attribute is named type, not ptype.
Fix: Use proc.type instead of proc.ptype.