Skip to content

DM-52947: Add a ResourcePath.get_info() method#140

Merged
timj merged 19 commits intomainfrom
tickets/DM-52947
Apr 6, 2026
Merged

DM-52947: Add a ResourcePath.get_info() method#140
timj merged 19 commits intomainfrom
tickets/DM-52947

Conversation

@timj
Copy link
Copy Markdown
Member

@timj timj commented Mar 31, 2026

This is a standardized way to get the file size, last modified time, and any checksums known to the backend.

Checklist

  • ran Jenkins
  • added a release note for user-visible changes to doc/changes

@timj
Copy link
Copy Markdown
Member Author

timj commented Mar 31, 2026

@airnandez this is a first attempt at adding a get_info method. I need to test it on a real S3 but it uses your existing info() implementation for WebDAV.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

❌ Patch coverage is 76.15741% with 103 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.62%. Comparing base (3f963e5) to head (6c06ddf).
⚠️ Report is 20 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
tests/test_gs.py 64.00% 43 Missing and 2 partials ⚠️
python/lsst/resources/gs.py 51.21% 12 Missing and 8 partials ⚠️
python/lsst/resources/http.py 69.35% 9 Missing and 10 partials ⚠️
python/lsst/resources/file.py 57.89% 6 Missing and 2 partials ⚠️
python/lsst/resources/s3.py 74.07% 4 Missing and 3 partials ⚠️
python/lsst/resources/packageresource.py 60.00% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #140      +/-   ##
==========================================
- Coverage   83.63%   83.62%   -0.01%     
==========================================
  Files          36       36              
  Lines        7601     7958     +357     
  Branches      916      956      +40     
==========================================
+ Hits         6357     6655     +298     
- Misses        976     1007      +31     
- Partials      268      296      +28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@timj timj force-pushed the tickets/DM-52947 branch from 5c9355f to 10cbe02 Compare March 31, 2026 02:15
This is a standardized way to get the file size, last modified
time, and any checksums known to the backend.
@timj timj force-pushed the tickets/DM-52947 branch from 10cbe02 to c879311 Compare March 31, 2026 05:03
@timj timj force-pushed the tickets/DM-52947 branch from f97d017 to fd5376e Compare March 31, 2026 17:41
@timj timj force-pushed the tickets/DM-52947 branch from 8f50a04 to 2e2fa2a Compare March 31, 2026 20:08
@timj timj force-pushed the tickets/DM-52947 branch from 15ade6b to e24f1ae Compare April 1, 2026 17:10
Copy link
Copy Markdown
Contributor

@dhirving dhirving left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't review the GS stuff, but the rest looks good to me.

Comment on lines +1016 to +1033
resp = self._propfind()
if resp.status_code != requests.codes.multi_status:
raise FileNotFoundError(
f"Resource {self} does not exist, status: {resp.status_code} {resp.reason}"
)

prop = _parse_propfind_response_body(resp.text)[0]
if not prop.exists:
raise FileNotFoundError(f"Resource {self} does not exist")

return ResourceInfo(
uri=str(self),
is_file=prop.is_file,
size=prop.size,
last_modified=prop.last_modified,
creation_time=None,
checksums=dict(prop.checksums),
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can probably leave out the WebDAV special case -- the regular HTTP one will still work against WebDAV, and it will be one less thing to back out when we go through and clean all the WebDAV stuff out of this file.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this code path does lead to a semantic change regarding directories. One of the tests is checking that you can't ask for the size of a directory but now that get_info does work for a directory. I think I should fix the test to expect 0 instead, consistent with what file URI does and non-webdav

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I'm getting some cascading errors from the test system for the change of behavior so I think I might leave the code in for now if I cant fix them relatively quickly.

Comment on lines +71 to +85
- name: Start fake-gcs-server
run: |
docker run -d --name fake-gcs-server -p 4443:4443 \
fsouza/fake-gcs-server -scheme http -filesystem-root /tmp/fake-gcs-server

for i in $(seq 1 30); do
if curl --silent --fail http://127.0.0.1:4443/storage/v1/b >/dev/null; then
exit 0
fi
sleep 1
done

docker logs fake-gcs-server
exit 1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you do end up keeping this, the testcontainers library is a nice way to embed the docker setup logic in unit tests.

Example: https://github.com/lsst/daf_butler/blob/main/tests_integration/test_docker_container.py

timj added 2 commits April 6, 2026 12:03
It only exists on macOS APFS and whilst that's great for
macOS users it doesn't help at all for our main systems.
In theory non-zero size S3 objects with trailing / can exist
even though ResourcePath does not make them. get_info now
handles that case and returns is_file=True if the file object
has non-zero size.
@timj timj force-pushed the tickets/DM-52947 branch from b210567 to 2ef3a4f Compare April 6, 2026 20:44
@timj timj merged commit 42d460a into main Apr 6, 2026
22 of 24 checks passed
@timj timj deleted the tickets/DM-52947 branch April 6, 2026 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants