-
Notifications
You must be signed in to change notification settings - Fork 43
Distinguishing prefixes from objects in iterdir()
results
#193
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
Comments
Hi @oir >>> from pathlib import Path
>>> Path('s3path/')
PosixPath('s3path') It's a good point that we need to fix the doc's About optimization, |
Sounds great, I think I would benefit from either of the suggested solutions. Thanks for the heads up. |
Fixed and deployed in version 0.6.2 |
Will take a look asap! 🙏 |
I tried updating to s3path 0.6.2 and noticed my testing Failure: https://github.com/pypa/bandersnatch/actions/runs/14916487772/job/41903180127?pr=1944 Summary:
I've commented here cause I saw in the code you plan to make this more robust - Is this including maybe a "no_cahce=True" param to do the expensive operation? |
Ahhh - Creating a new S3Path object does the trick ... diff --git a/src/bandersnatch/tests/plugins/test_storage_plugin_s3.py b/src/bandersnatch/tests/plugins/test_storage_plugin_s3.py
index cfa7d69..ab3b006 100644
--- a/src/bandersnatch/tests/plugins/test_storage_plugin_s3.py
+++ b/src/bandersnatch/tests/plugins/test_storage_plugin_s3.py
@@ -27,8 +27,10 @@ def test_update_safe(s3_mock: S3Path) -> None:
def test_path_mkdir(s3_mock: S3Path) -> None:
new_folder = s3.S3Path(f"/{s3_mock.bucket}/test_folder")
+ assert not new_folder.is_dir()
new_folder.mkdir()
- assert new_folder.is_dir()
+ new_folder2 = s3.S3Path(f"/{s3_mock.bucket}/test_folder")
+ assert new_folder2.is_dir() If this is how you envision how people should use this should maybe it should be documented. |
@cooperlees Tx for the debugging |
"There are only two hard things in Computer Science: cache invalidation and naming things." - Phil Karlton (Netscape) |
Hi! Apologies if I missed this in the docs. In the readme, it looks like the surface form string should have a trailing slash for "folders" (i.e. common prefixes):
However when I run something similar, I don't observe the trailing slashes, so it looks something like:
This means after any
iterdir()
, I have to make an extra call tois_file()
oris_dir()
to determine which ones among the returned are "files" and which ones are "folders", which become expensive. Is this expected? Or am I missing a configuration?I am using s3path 0.6.1 with a custom s3-compatible object storage and custom configuration with
register_configuration_parameter()
if it makes a difference.The text was updated successfully, but these errors were encountered: