Adding Temporary Directory Routine - #9029
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds the exported Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
…ply.github.com> I, Eric Kerfoot <17726042+ericspod@users.noreply.github.com>, hereby add my Signed-off-by to this commit: a95e44e I, Eric Kerfoot <17726042+ericspod@users.noreply.github.com>, hereby add my Signed-off-by to this commit: d9cd2d1 I, Eric Kerfoot <17726042+ericspod@users.noreply.github.com>, hereby add my Signed-off-by to this commit: 5e7e430 Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
monai/apps/utils.py (2)
46-54: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winSort
__all__to satisfy RUF022.Ruff reports this export list is unsorted.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@monai/apps/utils.py` around lines 46 - 54, Sort the entries in the __all__ export list alphabetically to satisfy RUF022, preserving all existing exported symbols and their values.Source: Linters/SAST tools
436-452: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument filesystem exceptions.
Add a Google-style
Raisessection forOSErrorfrom temporary-directory creation oros.makedirs.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@monai/apps/utils.py` around lines 436 - 452, Update the create_temp_dir docstring to include a Google-style Raises section documenting OSError from temporary-directory creation and os.makedirs, without changing the function’s behavior or existing documentation.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@monai/apps/utils.py`:
- Around line 461-462: Update the delete_on_finalise cleanup registration in
create_temp_dir to make shutil.rmtree ignore missing directories, ensuring
repeated callbacks are idempotent and exit cleanup does not raise
FileNotFoundError.
---
Nitpick comments:
In `@monai/apps/utils.py`:
- Around line 46-54: Sort the entries in the __all__ export list alphabetically
to satisfy RUF022, preserving all existing exported symbols and their values.
- Around line 436-452: Update the create_temp_dir docstring to include a
Google-style Raises section documenting OSError from temporary-directory
creation and os.makedirs, without changing the function’s behavior or existing
documentation.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: f394f467-bd08-4818-9576-ff8eeb031547
📒 Files selected for processing (3)
monai/apps/__init__.pymonai/apps/utils.pytests/apps/test_create_temp_dir.py
There was a problem hiding this comment.
🧹 Nitpick comments (3)
tests/apps/test_create_temp_dir.py (1)
60-80: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUse a descriptive file-handle name.
Rename
otofile_handleor similar.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/apps/test_create_temp_dir.py` around lines 60 - 80, In test_finalisation, rename the file handle variable o to a descriptive name such as file_handle, and update its write call accordingly.Source: Path instructions
monai/apps/utils.py (2)
46-54: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueSort
__all__to satisfy Ruff.
create_temp_dirshould be placed alphabetically with the other exports.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@monai/apps/utils.py` around lines 46 - 54, Sort the export names in __all__ alphabetically, moving create_temp_dir into its correct position while preserving all existing exports.Source: Linters/SAST tools
437-452: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument propagated filesystem errors.
Add a Google-style
Raisessection forOSErrorfrom directory creation.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@monai/apps/utils.py` around lines 437 - 452, Update the docstring for the temporary-directory function to add a Google-style Raises section documenting that directory creation can raise OSError. Keep the existing arguments and return documentation unchanged.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@monai/apps/utils.py`:
- Around line 46-54: Sort the export names in __all__ alphabetically, moving
create_temp_dir into its correct position while preserving all existing exports.
- Around line 437-452: Update the docstring for the temporary-directory function
to add a Google-style Raises section documenting that directory creation can
raise OSError. Keep the existing arguments and return documentation unchanged.
In `@tests/apps/test_create_temp_dir.py`:
- Around line 60-80: In test_finalisation, rename the file handle variable o to
a descriptive name such as file_handle, and update its write call accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: d3aa5766-d56d-47e5-b8be-dea4293006fa
📒 Files selected for processing (3)
monai/apps/__init__.pymonai/apps/utils.pytests/apps/test_create_temp_dir.py
🚧 Files skipped from review as they are similar to previous changes (1)
- monai/apps/init.py
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
Description
This adds a temporary directory creation routine to replace the following cell in many tutorial notebooks:
This should be functionally equivalent, but can also add a finaliser function to delete the directory when the notebook closes. The notebooks can then be updated to reduce the amount of code.
Types of changes
./runtests.sh -f -u --net --coverage../runtests.sh --quick --unittests --disttests.make htmlcommand in thedocs/folder.