Fix resource plot filename collisions across workflow runs#316
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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::Argsso both aggregate and per-job plots get disambiguated filenames.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 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(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
generate_resource_plotswas passing an emptyprefixto 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.resource_metrics_<unique_label>.db) so HTML filenames inherit the samewf{id}_h{host}_r{run}(local) orwf{id}_sl{slurm_job}_n{node}_p{pid}(slurm) disambiguation the DB already uses.Test plan
cargo clippy --all --all-targets --all-features -- -D warningsoutput_dirwithresource_monitor.generate_plots: trueand verify both sets ofsystem_timeline/summary/cpu_all_jobs/memory_all_jobsHTML files survive with distinct prefixes.🤖 Generated with Claude Code