Conversation
Enhances the download_dependency function to check for an existing "done" file before initiating a download, preventing unnecessary downloads of already cached dependencies. Adds unit tests to verify this behavior, ensuring that downloads are skipped when the cache is present and triggered when it is absent.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR makes download_dependency() idempotent by checking for a per-version "{py_ver}-done" marker file ( Sequence Diagram(s)sequenceDiagram
participant Caller
participant FS as FileSystem
participant SubP as Subprocess (aws/tar)
Caller->>FS: check {py_ver}-done marker
alt marker exists
FS-->>Caller: marker present
Caller->>Caller: log "already cached, skipping download"
else marker missing
Caller->>FS: create target directory
Caller->>SubP: run aws s3 cp (Popen)
SubP-->>Caller: aws returns
Caller->>SubP: run tar -x (Popen)
SubP-->>Caller: tar returns
Caller->>FS: touch {py_ver}-done marker
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
|
📦 Python package built successfully!
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #84 +/- ##
=======================================
Coverage 74.32% 74.32%
=======================================
Files 94 94
Lines 5534 5534
Branches 824 824
=======================================
Hits 4113 4113
Misses 1155 1155
Partials 266 266
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@dockerfiles/cache-downloader/cache-downloader.py`:
- Around line 22-26: The check uses os.path.isfile(done_file) while the codebase
uses pathlib.Path; replace this with a Path-based check by ensuring done_file is
a pathlib.Path (or wrap it: Path(done_file)) and call its is_file() method
(i.e., use done_file.is_file()) in the block that prints the
"{datetime.datetime.now()}: {release_name} python{python_version} already
cached..." message so it follows the project's pathlib convention.
In `@tests/unit/test_cache_downloader.py`:
- Around line 184-188: The nested context managers should be combined into a
single with statement to make the test more concise and PEP8-friendly: replace
the two nested with patch.object calls (patch.object(_mod, "BASE_PATH",
str(tmp_path)) and patch.object(_mod.subprocess, "Popen") as mock_popen) with
one combined with patch.object(_mod, "BASE_PATH", str(tmp_path)),
patch.object(_mod.subprocess, "Popen") as mock_popen: before calling
download_dependency(release, py_ver, "fake-bucket") and keep
mock_popen.assert_not_called() after the combined block.
- Around line 206-210: The two nested context managers in the test should be
combined into a single with statement to simplify the code: merge the with
patch.object(_mod, "BASE_PATH", str(tmp_path)) and with
patch.object(_mod.subprocess, "Popen", side_effect=[mock_aws, mock_tar]) as
mock_popen into one line using a comma-separated with, keeping the same as
mock_popen binding and then call download_dependency(release, py_ver,
"fake-bucket") inside that single context.
🪄 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: ASSERTIVE
Plan: Pro
Run ID: 8c0c1c98-952b-4597-86b2-3d16d0325133
📒 Files selected for processing (2)
dockerfiles/cache-downloader/cache-downloader.pytests/unit/test_cache_downloader.py
|
🚀 Review App Deployment Started
|
Replaces os.path.isfile with pathlib.Path.is_file in the download_dependency function to improve code readability and adhere to project standards. Updates unit tests to maintain functionality while ensuring consistent use of context managers for patching.
…nloaded-toolkit-cache
Summary
donefile before downloading, skipping S3 download + extraction for versions already on diskopen().close()pattern to usePath.touch()to avoid potential resource warningsSummary by CodeRabbit