CCPEM Pipeliner
Guide

Cleanup and Archiving

Reclaiming disk space with cleanup and trash, and preserving projects as archives


Overview

This page explains how to reclaim disk space in a pipeliner project and how to preserve a completed workflow as a portable archive. Cleanup operations remove intermediate files from job directories (optionally moving them to a Trash/Cleanup/ holding area so they can be restored), while archiving bundles the upstream job graph for a terminal job into a compressed tarball stored under ProjectArchives/. Both capabilities are available through pipeliner CLI flags and the PipelinerProject Python API.


Prerequisites

Before you begin:

  • ccpem-pipeliner installed in your Python 3.9+ environment (pip install ccpem-pipeliner)
  • A pipeliner project open in the current working directory (a default_pipeline.star file and a .CCPEM_pipeliner_project marker must exist)
  • For archiving: all jobs in the upstream graph of the chosen terminal job must have a status of Succeeded, Failed, or Aborted — Running or Scheduled jobs block archive creation
  • For a full archive: sufficient disk space to copy entire job directories
  • tar available on PATH when tar=True (the default) is used via the Python API

Usage

Cleanup

Cleanup removes intermediate files from one or more job directories to recover disk space. A normal cleanup removes files that are not needed for downstream jobs; a harsh cleanup (--harsh) removes even more, potentially including files needed to rerun the job. Removed files are moved into Trash/Cleanup/ (not deleted outright), so they can be restored later. Each cleanup operation appends a timestamped line to the project-level log file .CCPEM_pipeliner_cleanup.

CLI — clean specific jobs:

pipeliner --cleanup MotionCorr/job002/ CtfFind/job003/

CLI — harsh cleanup of specific jobs:

pipeliner --cleanup MotionCorr/job002/ --harsh

CLI — clean all jobs:

pipeliner --cleanup ALL

CLI — clean all jobs harshly:

pipeliner --cleanup ALL --harsh

Important: PipelinerProject.run_cleanup() requires full job names (e.g., 'MotionCorr/job002/'). Short forms like 'job002' or '2' are not resolved by the Python API — the method logs 'Could not find job' and returns False. The CLI --cleanup flag resolves short forms automatically.

Python API — clean specific jobs:

from pipeliner.api.manage_project import PipelinerProject

proj = PipelinerProject()
proj.run_cleanup(['MotionCorr/job002/', 'CtfFind/job003/'], harsh=False)

Python API — harsh cleanup of all jobs:

proj.cleanup_all(harsh=True)

Only jobs with status Succeeded are cleaned. run_cleanup() (pipeliner --cleanup <jobs>) skips any other job with a line in .CCPEM_pipeliner_cleanup; cleanup_all() (pipeliner --cleanup ALL) skips them without logging them. run_cleanup() returns bool: False as soon as a job cannot be found (jobs earlier in the list have already been cleaned and later ones are not processed), otherwise True, even if a job was skipped or had nothing to remove. cleanup_all() returns None; check .CCPEM_pipeliner_cleanup to see what was cleaned.


Restoring cleaned files

Files moved to Trash/Cleanup/ by a cleanup operation can be restored to their original job directories.

CLI:

pipeliner --restore_cleaned_files MotionCorr/job002/

Run --restore_cleaned_files without a job name to restore all cleaned files.

Python API:

proj.restore_from_cleanup('MotionCorr/job002/')

Deleting and undeleting jobs

Deleting a job moves it (and all its child jobs) to Trash/. The job can be restored with --undelete_job. Jobs in any status — including Running or Scheduled — can be deleted.

CLI:

pipeliner --delete_job MotionCorr/job002/
pipeliner --undelete_job MotionCorr/job002/

Python API:

success: bool = proj.delete_job('MotionCorr/job002/')
success: bool = proj.undelete_job('MotionCorr/job002/')

Emptying the trash

Emptying the trash permanently deletes everything in Trash/. This cannot be undone.

CLI (prompts for confirmation):

pipeliner --empty_trash

Python API (no confirmation prompt):

success: bool = PipelinerProject.empty_trash()  # staticmethod

empty_trash() returns True on success or False with a warning if Trash/ is empty.


Archiving

Archiving collects the job graph upstream of a terminal job and writes a compressed tarball to ProjectArchives/. Two modes are available:

ModeCLI flagcreate_archive argumentWhat is included
Simple (default)--simple_archive <job>full=FalseDirectory structure, parameter files, and a run_project.py re-run script
Full--full_archive <job>full=TrueComplete job directories including all output data

A simple archive is sufficient for reproducing the processing workflow. Use a full archive when you need to preserve all intermediate and output data.

CLI — simple archive:

pipeliner --simple_archive Refine3D/job007/

CLI — full archive:

pipeliner --full_archive Refine3D/job007/

Python API:

from pipeliner.api.manage_project import PipelinerProject

proj = PipelinerProject()

# Simple archive (default)
archive_path: str = proj.create_archive('Refine3D/job007/')

# Full archive
archive_path: str = proj.create_archive('Refine3D/job007/', full=True)

# Without tar compression
archive_path: str = proj.create_archive('Refine3D/job007/', full=False, tar=False)

create_archive() returns the archive filename (with .tar.gz appended when tar=True), or an empty string '' if the terminal job is not found.

Archive creation will raise ValueError if any upstream job is still Running or Scheduled. Failed and Aborted jobs are permitted in the upstream graph.

If a simple archive encounters a job of type external.processingimport, archive creation raises ValueError recommending a full archive instead.


Examples

Example 1 — Normal and harsh cleanup, then restore

from pipeliner.api.manage_project import PipelinerProject

proj = PipelinerProject()

# Normal cleanup: remove intermediate files, moved to Trash/Cleanup/
proj.run_cleanup(['MotionCorr/job002/', 'CtfFind/job003/'])

# Harsh cleanup: remove even more files
proj.run_cleanup(['Class2D/job005/'], harsh=True)

# Restore a job's cleaned files from Trash/Cleanup/ back to the job directory
proj.restore_from_cleanup('MotionCorr/job002/')

Example 2 — Delete a job, then empty the trash

from pipeliner.api.manage_project import PipelinerProject

proj = PipelinerProject()

# Move a job and its child jobs to Trash/
proj.delete_job('Class2D/job005/')

# Permanently delete everything in Trash/ — cannot be undone
PipelinerProject.empty_trash()

Example 3 — Create a simple and a full archive

from pipeliner.api.manage_project import PipelinerProject

proj = PipelinerProject()

# Simple archive: parameter files + re-run script only (default)
simple_path = proj.create_archive('PostProcess/job010/')

# Full archive: entire job directories
full_path = proj.create_archive('PostProcess/job010/', full=True)

Both archives are written under ProjectArchives/ as .tar.gz files.


Troubleshooting

run_cleanup() logs 'Could not find job' and returns False

Symptom: Calling proj.run_cleanup(['job002/']) or proj.run_cleanup(['2']) cleans nothing and returns False, logging Could not find job <name> to clean up.

Cause: PipelinerProject.run_cleanup() requires full job names (e.g., 'MotionCorr/job002/'). Short forms like 'job002' or '2' are not resolved by the Python API.

Fix: Use the full job name including the type prefix and trailing slash:

proj.run_cleanup(['MotionCorr/job002/'])

Alternatively, use the CLI --cleanup flag, which resolves short forms automatically.


Archive creation raises ValueError about a running or scheduled job

Symptom: create_archive() or pipeliner --full_archive raises:

ValueError: ERROR: Job <name> is still marked as running or scheduled! Archives cannot be created unless all jobs have terminated
No archive created.

Cause: One or more upstream jobs in the graph have status Running or Scheduled.

Fix: Wait for those jobs to finish, or use pipeliner --set_status <job> failed to mark stale jobs as terminated before archiving.


Simple archive raises ValueError about external.processingimport

Symptom:

ValueError: ERROR: The job <name> contains external processing steps that will not be preserved by a simple archive.
A full archive is more appropriate for this project.
No archive created.

Cause: A job of type external.processingimport is in the upstream graph. Simple archives cannot preserve these steps.

Fix: Use a full archive instead:

pipeliner --full_archive <terminal_job>
proj.create_archive('<terminal_job>', full=True)

create_archive() returns an empty string

Symptom: archive_path = proj.create_archive('Refine3D/job007/') returns ''.

Cause: The specified terminal job was not found in the pipeline.

Fix: Verify the job name by inspecting default_pipeline.star. (pipeliner --available_jobs lists job types such as relion.refine3d, not the jobs in the project.) Use the full job name including the type prefix and trailing slash.


Cleaned files cannot be restored — Trash/Cleanup/ is empty

Symptom: restore_from_cleanup() or --restore_cleaned_files finds nothing to restore.

Cause: Either the files were never cleaned (cleanup was not run on that job), or empty_trash() / --empty_trash was called after cleanup, permanently deleting the files.

Fix: Re-run the job to regenerate the intermediate files. There is no recovery path after empty_trash() has been called.