Repository navigation
(feat,osw): auto clean cache files from temp dir - #9029
Conversation
📝 WalkthroughWalkthroughAdded a Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI
participant Workflow as OpenSwathWorkflow
participant Loader as loadSwathFiles
participant FS as FileSystem
CLI->>Workflow: parse flags (incl. keep_cached_files, readOptions)
alt readOptions == "cache"
Workflow->>FS: create per_run_tmp under tempDirectory
Workflow->>Loader: load/write cached artifacts using per_run_tmp
Loader->>FS: read/write cached files in per_run_tmp
else
Workflow->>Loader: load/write using shared tmp_dir
end
Workflow->>Workflow: processing completes
alt created per_run_tmp && !keep_cached_files
Workflow->>FS: remove per_run_tmp recursively
else
Note right of Workflow: retain per_run_tmp
end
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/topp/OpenSwathWorkflow.cpp`:
- Around line 1027-1048: The per-run cache directory cleanup currently runs too
early and not reliably on failure paths; modify the code around per_run_tmp and
created_run_tmp so that any run-local cache-backed objects/readers are destroyed
or explicitly closed before calling File::removeDirRecursively(per_run_tmp), and
wrap the created_run_tmp cleanup in an RAII scope guard (or an inner scope) that
calls File::removeDirRecursively in its destructor so the directory is removed
on all exits (normal, return, exception); ensure the cleanup guard is
constructed only when created_run_tmp is true and reference the same per_run_tmp
variable used when creating the directory.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ff94cb47-ae14-4ed2-aa2b-160341bee4ac
📒 Files selected for processing (1)
src/topp/OpenSwathWorkflow.cpp
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/topp/OpenSwathWorkflow.cpp`:
- Around line 1078-1098: The per_run_tmp allocation is unsafe: when readoptions
== "cache" treat both an existing directory and a failed makeDir() as allocation
failures; do not mark created_run_tmp true just because File::isDirectory()
returned true. Modify the block that creates per_run_tmp (variables per_run_tmp,
created_run_tmp and calls to File::getUniqueName(), File::isDirectory(),
File::makeDir()) so that you loop/retry generating a fresh unique name if the
candidate already exists or if makeDir() fails (or else abort/propagate an
error), and only set created_run_tmp = true after a confirmed successful
File::makeDir() call.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2762f141-ef4e-4ee7-b039-6a53ddd29a2b
📒 Files selected for processing (2)
CHANGELOGsrc/topp/OpenSwathWorkflow.cpp
✅ Files skipped from review due to trivial changes (1)
- CHANGELOG
| bool created_run_tmp = false; | ||
| if (readoptions == "cache") | ||
| { | ||
| const int max_attempts = 10; |
There was a problem hiding this comment.
We have some mechanisms to delete temp files in our tests or search engine adapters. Maybe worth a look
There was a problem hiding this comment.
Thanks for pointing that out, I've updated to using some of the existing stuff in File.cpp/h
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/openms/include/OpenMS/SYSTEM/File.h (1)
42-47: Use explicit Doxygen tags for the new public constructor docs.Please switch this new constructor comment block to
@briefstyle (and keep@paramtags) to match header documentation rules consistently.As per coding guidelines: “Use Doxygen
@brief(required) followed by blank line and details.”🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/openms/include/OpenMS/SYSTEM/File.h` around lines 42 - 47, Update the Doxygen for the public constructor TempDir(const String& base_dir, bool keep_dir = false) to use an explicit `@brief` tag followed by a blank line and then the longer description, and retain the `@param` tags for base_dir and keep_dir; in other words replace the current freeform comment lines with an `@brief` one-line summary, a blank line, detailed explanation, and the existing `@param` entries so the comment follows the project's header documentation rules.src/topp/OpenSwathWorkflow.cpp (1)
1052-1054: Consider logging the effective run-local temp path on load failures.Now that loading uses
per_run_tmp, the failure message should print that value (instead of sharedtmp_dir) for accurate diagnostics.Suggested patch
- << " (split_file=" << (split_file ? "true" : "false") << ", tmp_dir='" << tmp_dir << "', readoptions='" << readoptions << "')" + << " (split_file=" << (split_file ? "true" : "false") << ", tmp_dir='" << per_run_tmp << "', readoptions='" << readoptions << "')" ... - << " (split_file=" << (split_file ? "true" : "false") << ", tmp_dir='" << tmp_dir << "', readoptions='" << readoptions << "')" + << " (split_file=" << (split_file ? "true" : "false") << ", tmp_dir='" << per_run_tmp << "', readoptions='" << readoptions << "')"Also applies to: 1067-1069
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/topp/OpenSwathWorkflow.cpp` around lines 1052 - 1054, The failure branches that check the return of loadSwathFiles currently log the shared tmp_dir value, but since loading uses per_run_tmp the error message should include per_run_tmp for accurate diagnostics; update the error logging in the if-block(s) that follow loadSwathFiles (the call passing per_run_tmp and &qc_consumer) to print the effective per_run_tmp path instead of tmp_dir, and make the analogous change for the second loadSwathFiles call (the other failing branch around the subsequent call) so both failure messages report per_run_tmp.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/openms/include/OpenMS/SYSTEM/File.h`:
- Around line 42-47: Update the Doxygen for the public constructor TempDir(const
String& base_dir, bool keep_dir = false) to use an explicit `@brief` tag followed
by a blank line and then the longer description, and retain the `@param` tags for
base_dir and keep_dir; in other words replace the current freeform comment lines
with an `@brief` one-line summary, a blank line, detailed explanation, and the
existing `@param` entries so the comment follows the project's header
documentation rules.
In `@src/topp/OpenSwathWorkflow.cpp`:
- Around line 1052-1054: The failure branches that check the return of
loadSwathFiles currently log the shared tmp_dir value, but since loading uses
per_run_tmp the error message should include per_run_tmp for accurate
diagnostics; update the error logging in the if-block(s) that follow
loadSwathFiles (the call passing per_run_tmp and &qc_consumer) to print the
effective per_run_tmp path instead of tmp_dir, and make the analogous change for
the second loadSwathFiles call (the other failing branch around the subsequent
call) so both failure messages report per_run_tmp.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9f5fbb50-c863-4cc6-b2de-179c2bf9c7b1
📒 Files selected for processing (4)
CHANGELOGsrc/openms/include/OpenMS/SYSTEM/File.hsrc/openms/source/SYSTEM/File.cppsrc/topp/OpenSwathWorkflow.cpp
✅ Files skipped from review due to trivial changes (1)
- CHANGELOG
Description
When using the cache read options for OpenSwathWorkflow, temporary cache files are written to disk in a temp directory set by the user. These files are usually left to the user to remember to clean up and delete, but sometimes they may be forgotten about and can accumulate and take up storage space. Added the ability to automatically clean and delete the cache files (after each run is processed), and added a flag to let the user explicitly keep the cached files if they want.
Temporary cache management improvements:
keep_cached_filesto allow users to retain cached files in the temporary directory, disabling automated cleanup.readOptionsparameter is set tocache, ensuring isolation and preventing conflicts between runs.loadSwathFilesto use the per-run temporary directory instead of the global temp directory, ensuring that each run uses its own cache space. [1] [2]keep_cached_filesflag. This helps manage disk usage and prevents leftover temporary files.Filesystem compatibility:
dirpathvariable to usestd::filesystem::pathdirectly instead ofstd::filesystem::u8path, improving compatibility and simplifying the code.Checklist
How can I get additional information on failed tests during CI
Click to expand
If your PR is failing you can check outIf you click in the column that lists the failed tests you will get detailed error messages.
Advanced commands (admins / reviewer only)
Click to expand
/reformat(experimental) applies the clang-format style changes as additional commit. Note: your branch must have a different name (e.g., yourrepo:feature/XYZ) than the receiving branch (e.g., OpenMS:develop). Otherwise, reformat fails to push.rebuild jenkinswill retrigger Jenkins-based CI buildsSummary by CodeRabbit
New Features
keep_cached_filesCLI flag to control whether per-run temporary cache directories are retained.Chores