Skip to content

Fix resource plot filename collisions across workflow runs#316

Merged
daniel-thom merged 1 commit into
mainfrom
fix/resource-plot-filename-collisions
May 10, 2026
Merged

Fix resource plot filename collisions across workflow runs#316
daniel-thom merged 1 commit into
mainfrom
fix/resource-plot-filename-collisions

Conversation

@daniel-thom
Copy link
Copy Markdown
Collaborator

Summary

  • generate_resource_plots was passing an empty prefix to the plotter, so aggregate plots (system_timeline, system_summary, summary, cpu_all_jobs, memory_all_jobs) from different workflow runs silently overwrote each other when the output directory was shared.
  • Derive the plot filename prefix from the DB file stem (resource_metrics_<unique_label>.db) so HTML filenames inherit the same wf{id}_h{host}_r{run} (local) or wf{id}_sl{slurm_job}_n{node}_p{pid} (slurm) disambiguation the DB already uses.
  • Per-job plots get the same prefix, so they no longer collide either when two workflows happen to share a job-id range or when the same workflow is re-run.

Test plan

  • cargo clippy --all --all-targets --all-features -- -D warnings
  • Run two workflows back-to-back into the same output_dir with resource_monitor.generate_plots: true and verify both sets of system_timeline/summary/cpu_all_jobs/memory_all_jobs HTML files survive with distinct prefixes.

🤖 Generated with Claude Code

generate_resource_plots was passing an empty prefix to the plotter, so
aggregate plots (system_timeline, system_summary, summary, cpu_all_jobs,
memory_all_jobs) from different workflow runs sharing an output directory
silently overwrote each other. Derive the prefix from the DB file stem
(`resource_metrics_<unique_label>.db`) so the plot filenames inherit the
same workflow/host/run (or slurm-job/pid) disambiguation that the DB
already uses.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents generated resource plot HTML files from being silently overwritten when multiple workflow runs share the same output directory by ensuring plot output filenames are run-specific.

Changes:

  • Derive the plot filename prefix from the resource metrics DB filename stem (stripping resource_metrics_).
  • Pass that derived prefix into plot_resources_cmd::Args so both aggregate and per-job plots get disambiguated filenames.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/client/job_runner.rs
Comment on lines +1070 to +1076
// when they share an output directory. The DB is named
// `resource_metrics_<unique_label>.db`; the unique_label already
// disambiguates by workflow + host + run (or slurm job + pid).
let prefix = db_path
.file_stem()
.and_then(|s| s.to_str())
.and_then(|s| s.strip_prefix("resource_metrics_"))
Comment thread src/client/job_runner.rs
Comment on lines +1067 to 1084
// Derive the plot filename prefix from the DB stem so aggregate plots
// (system_timeline, summary, cpu_all_jobs, etc.) from different
// workflow runs / compute-node allocations don't overwrite each other
// when they share an output directory. The DB is named
// `resource_metrics_<unique_label>.db`; the unique_label already
// disambiguates by workflow + host + run (or slurm job + pid).
let prefix = db_path
.file_stem()
.and_then(|s| s.to_str())
.and_then(|s| s.strip_prefix("resource_metrics_"))
.unwrap_or("")
.to_string();
let args = crate::plot_resources_cmd::Args {
db_paths: vec![db_path.to_path_buf()],
output_dir,
job_ids: Vec::new(),
prefix: String::new(),
prefix,
format: "html".to_string(),
@daniel-thom daniel-thom merged commit f6b148a into main May 10, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants