-
Notifications
You must be signed in to change notification settings - Fork 16
fix: Remove _is_dir caching, use .snakemake-timestamp instead #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughRemoved cached directory-state tracking in the S3 storage plugin, replacing Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant is_dir
participant local_path
participant S3
Caller->>is_dir: is_dir()
is_dir->>local_path: check if local_path() is directory
alt local_path is directory
local_path-->>is_dir: True
is_dir-->>Caller: return True
else local_path is not directory
local_path-->>is_dir: False
is_dir->>S3: attempt load s3obj(".snakemake_timestamp")
alt sentinel object exists
S3-->>is_dir: success
is_dir-->>Caller: return True
else 404 error
S3-->>is_dir: 404
is_dir-->>Caller: return False
else other exception
S3-->>is_dir: exception
is_dir-->>Caller: re-raise exception
end
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
snakemake_storage_plugin_s3/__init__.py (1)
327-341:is_dirlogic looks good; consider a small cleanup of control flow and exception re‑raiseThe new directory detection via
.snakemake_timestampis consistent with Snakemake’s directory semantics and fits well with howexists(),mtime(), andsize()useis_dir().There are two small, non‑blocking cleanups you may want to make:
- The final
return Falseis unreachable, since all paths in thetry/excepteither return or raise.- Re‑raising with
raiseinstead ofraise epreserves the original traceback and addresses the TRY201 hint.You can address both (and the TRY300 hint about
returnintry) with a minimal refactor:def is_dir(self): - if self.local_path().is_dir(): - return True - - try: - self.s3obj(".snakemake_timestamp").load() - return True - except botocore.exceptions.ClientError as e: - err_code = e.response["Error"]["Code"] - if err_code == "404": - return False - else: - raise e - - return False + if self.local_path().is_dir(): + return True + + try: + self.s3obj(".snakemake_timestamp").load() + except botocore.exceptions.ClientError as e: + err_code = e.response["Error"]["Code"] + if err_code == "404": + return False + raise + return TrueThis keeps behavior identical while simplifying the flow and aligning with Ruff’s suggestions.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
snakemake_storage_plugin_s3/__init__.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py
⚙️ CodeRabbit configuration file
**/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of theselfargument of methods.
Do not suggest type annotation of theclsargument of classmethods.
Do not suggest return type annotation if a function or method does not contain areturnstatement.
Files:
snakemake_storage_plugin_s3/__init__.py
🪛 Ruff (0.14.5)
snakemake_storage_plugin_s3/__init__.py
333-333: Consider moving this statement to an else block
(TRY300)
339-339: Use raise without specifying exception name
Remove exception name
(TRY201)
|
And....now I'm seeing there are two other pull requests both to fix the same issue! I think I like how #60 did it as it preserves the caching. I'll leave this up, though, as a reference for an alternate fix to be closed once one of the other PRs is merged. |
This addresses issue #61
See issue for details on the motivation for this fix.
I am using this dev version to run some jobs (so I know it runs), but I'd like to be able to run the tests. However, the tests seem to run on some sort of local s3 mirror? Happy to run the tests if you could provide instructions on how.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.