Skip to content
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

DM-37510: Make HttpResourcePath.exists() more robust for WebDAV endpoints #38

Merged
merged 20 commits into from Feb 4, 2023

Conversation

airnandez
Copy link
Contributor

Checklist

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

I recognise this PR involves several changes not initially intended. The changes implemented for using webDAV-specific methods for exist() and size() had more consequences than initially anticipated. This was an opportunity (and a necessity) for improving the test suite.

@codecov
Copy link

codecov bot commented Feb 1, 2023

Codecov Report

Base: 85.05% // Head: 84.74% // Decreases project coverage by -0.31% ⚠️

Coverage data is based on head (804c253) compared to base (6dcda2c).
Patch coverage: 81.53% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #38      +/-   ##
==========================================
- Coverage   85.05%   84.74%   -0.31%     
==========================================
  Files          27       27              
  Lines        3218     3415     +197     
  Branches      671      713      +42     
==========================================
+ Hits         2737     2894     +157     
- Misses        380      408      +28     
- Partials      101      113      +12     
Impacted Files Coverage Δ
python/lsst/resources/http.py 80.37% <66.84%> (-5.40%) ⬇️
tests/test_http.py 97.74% <97.61%> (-0.14%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

# single remote resource, the response must include properties for
# that single resource. So either its response status is OK or not.
tree = etree.fromstring(resp.content.strip())
element = tree.find("./{DAV:}response/{DAV:}propstat/[{DAV:}status='HTTP/1.1 200 OK']")
Copy link
Contributor

Choose a reason for hiding this comment

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

A question for my edification: can this ever be a different HTTP version (e.g. 1.0 or 2.0)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My understanding of the RFC 4918is that the response to PROPFIND requires that status be of the form HTTP/1.1 <status code> <message>.

But I would say this does not preclude that the communication protocol used between client and server be HTTP2 or HTTP3.

log.debug("Response:")
log.debug(f" status_code={resp.status_code}")
log.debug(f" headers={resp.headers}")
if resp.content is None:
Copy link
Member

Choose a reason for hiding this comment

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

mypy is convinced that resp.content can never be None. I don't know if that's true but maybe changing this line to if not resp.content would work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think mypy is wrong, indeed. I changed the test to make it happy.

Copy link
Member

Choose a reason for hiding this comment

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

The problem with requests type annotations is that they come in through the types-requests package which is a standalone external package not directly part of the requests code base. It's possible there is a bug in that annotation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My issue is that the results of running mypy locally in my development host are not the same as the ones ran in github actions. That makes I need several roundtrips to make mypy happy. I need to take the time to understand in detail how to make it work locally.

Copy link
Member

Choose a reason for hiding this comment

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

are you using the mypy from rubin-env-developer conda package? I seem to have 0.991 installed and that is the version the action seems to be using.

@timj
Copy link
Member

timj commented Feb 1, 2023

@airnandez I just merged #39 which updates dependencies and runs black 23.1. You will need to rebase and I'm hoping the rebase is not problematic given you had to run black yourself.

@timj
Copy link
Member

timj commented Feb 1, 2023

@airnandez I rebased for you -- it was not completely trivial so it seemed unfair to make you do it. I have checked that the test_http.py file did not change after rebasing.

@airnandez
Copy link
Contributor Author

@airnandez I rebased for you -- it was not completely trivial so it seemed unfair to make you do it. I have checked that the test_http.py file did not change after rebasing.

Thanks @timj for rebasing. I pulled the rebased branch and successfully ran the test suite. From my perspective the work I intended for this ticket is done.

Copy link
Member

@timj timj left a comment

Choose a reason for hiding this comment

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

Thanks for doing all this work and significantly enhancing the test code.

I have some minor cleanups I think are needed.

python/lsst/resources/http.py Outdated Show resolved Hide resolved
python/lsst/resources/http.py Outdated Show resolved Hide resolved
python/lsst/resources/http.py Outdated Show resolved Hide resolved
python/lsst/resources/http.py Outdated Show resolved Hide resolved
python/lsst/resources/http.py Outdated Show resolved Hide resolved
python/lsst/resources/http.py Show resolved Hide resolved
python/lsst/resources/http.py Outdated Show resolved Hide resolved
tests/test_http.py Outdated Show resolved Hide resolved
tests/test_http.py Outdated Show resolved Hide resolved
tests/test_http.py Outdated Show resolved Hide resolved
Copy link
Member

@timj timj left a comment

Choose a reason for hiding this comment

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

Thanks for making the changes. Looks great.

@airnandez
Copy link
Contributor Author

This was far much work than I initially anticipated. But I am happy with the result. I think this code is more robust and overall better now. Thanks for your time and for this very detailed feedback.

@airnandez airnandez merged commit 14c3e05 into main Feb 4, 2023
@airnandez airnandez deleted the tickets/DM-37510 branch February 4, 2023 10:33
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.

None yet

3 participants