Cleaning run artifacts

A PyRETIS run leaves a number of generated files and directories behind – log files, the regenerated out.toml / out.rst, restart files, the NNN ensemble directories (each holding its generate scratch, the accepted operational trajectory store and the archive long-term store), the report directory, the multi-run runs directory, Python byte-code caches, and so on. (A flat top-level load directory only exists when it is staged by hand as legacy input, and is no longer a built-in default.) The pyretis tools clean sub-command removes them so a run (or example) directory can be reset to its committed inputs:

pyretis tools clean              # clean the current directory
pyretis tools clean some/dir     # clean another directory
pyretis tools clean --dry-run    # list what would be removed, delete nothing

pyretis tools clean deletes immediately; use --dry-run (or -n) first if you want to preview the list.

Note

pyretis clean (without tools) still works as a deprecated alias: it prints a one-line notice and then behaves identically. Use pyretis tools clean in new scripts.

What is removed

The removed set is the union of a comprehensive built-in default and an optional per-directory configuration file. The built-in defaults cover the full set of artifacts a routed run generates, so a plain run folder resets with no clean.toml at all:

  • files – byte-code / compiled order parameters (*.pyc, *.pyo, *.so), the translated config and restart store (output.toml*, out.toml*, out.rst*, infswap.toml, restart.toml*, pyretis.restart, ensemble.restart), the per-run text output (energy.txt*, order.txt*, pathensemble.txt*, cross.txt*, thermo.txt*, traj.txt*), the logs of both pyretis run and pyretis analyse including their backup copies (pyretis.log*, pyretisanalyse.log*, sim.log, worker[0-9]*.log), the RNG state, the engine scratch of every engine (*.tpr, *.edr, *.cpt, *.lammpstrj, …), and the run-done marker / plots;

  • directories – __pycache__, the NNN ensemble directories ([0-9][0-9][0-9], which subsume their generate / accepted / archive sub-stores), the accepted / archive stores and their previous names (paths / trajs), the retired worker* scratch, and the report and runs directories.

Two mechanisms keep these otherwise-aggressive defaults safe (the clean-safety sweep asserts no git-tracked file is ever removed):

  • Excluded reference/input directories. Anything below results, output_data, load or load_copy is never cleaned. These hold committed reference (golden) output and the committed load/NNN initial-path inputs a load- or restart-initiated run reads.

  • The ``keep`` list (below), for committed inputs that live outside those excluded names – for example a non-standard committed load directory, or the load/0 .. load/7 initial paths of the validation suite.

Per-directory configuration

Drop a clean.toml next to the files to extend (or replace) the defaults:

[clean]
use_defaults = true        # apply the built-in defaults (default: true)
find_files = ["out.toml*", "*.log"]   # extra file-name globs (recursive)
find_dirs  = ["report"]               # extra directory names (recursive)
rm_paths   = ["0*", "lammps/system.data"]  # root-relative rm -rf globs
keep       = ["load/0", "load/1"]     # never delete these (or ancestors)
  • find_files – file-name globs deleted wherever they occur in the tree (like find . -name PATTERN -delete).

  • find_dirs – directory names deleted recursively wherever they occur.

  • rm_paths – root-relative paths or globs removed with rm -rf semantics.

  • keep – paths that must survive; a kept path, anything inside it, and its ancestor directories are never removed. Use this to protect committed inputs that would otherwise match (for example the committed load/0 .. load/7 initial paths of the validation suite).

  • use_defaults = false disables the built-in defaults so the file is the complete, explicit recipe.

This replaces the per-example Makefile clean targets used in earlier PyRETIS versions.