Exercises: inspect and restart an analysis
Run these exercises only in work-science/program, after the core walkthrough. Exercises 1 and 3 belong to the core lesson; exercise 2 requires the completed full analysis. Keep the cloned source repositories unchanged.
1. Trace one job
Find the fit_correlator rule. For the fit tmin10-tmax22_model1exp, write down the four output paths, the chosen INI, and the log filename. Why does the rule list four outputs?
2. Extension: recover one missing output
Before running anything, predict the plan if one candidate file is missing. Move one result out of the candidate directory:
mv ../data/energy_fits/d000_energy_tmin10-tmax22_model1exp.jack ../saved-energy.jack
snakemake --cores 2 --scheduler greedy --dry-run
Which jobs will run? Will Snakemake rerun one momentum or the whole four-output fit? Now restore the workflow by execution:
snakemake --cores 2 --scheduler greedy
snakemake --cores 2 --scheduler greedy
Check that the missing output exists again and the final run has nothing to do. Keep saved-energy.jack outside the input directory: the original selection script reads that directory's candidate files.
3. Review a marker-based design
This is a code-reading exercise; do not create or execute the files shown. A proposed run_fit.sh runs Python and then creates a marker:
#!/bin/bash
python fit_correlator.py -i input.ini
touch fit.done
The rule launches it in a separate Bash process:
rule fit:
input: "input.ini"
output: "fit.done"
shell: "bash run_fit.sh"
Assume error stopping (errexit, the set -e option) is disabled in that Bash process and that touch succeeds. A later rule reads the energy directory but depends only on fit.done.
- What happens if Python exits with an error? Which exit code does Snakemake receive from the wrapper?
- What happens if an energy file is removed after a successful run, while
fit.doneremains? - Sketch corrected inputs, outputs and error propagation without changing the numerical program.
Compare with the solutions.