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-39563: Make clearer error message when repo alias has failed to find something #849

Merged
merged 11 commits into from Jun 8, 2023

Conversation

timj
Copy link
Member

@timj timj commented Jun 7, 2023

Checklist

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

@codecov
Copy link

codecov bot commented Jun 7, 2023

Codecov Report

Patch coverage: 97.72% and project coverage change: +0.01 🎉

Comparison is base (3af63b5) 87.95% compared to head (3d6cecf) 87.96%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #849      +/-   ##
==========================================
+ Coverage   87.95%   87.96%   +0.01%     
==========================================
  Files         269      269              
  Lines       35426    35482      +56     
  Branches     7432     7448      +16     
==========================================
+ Hits        31159    31213      +54     
- Misses       3123     3125       +2     
  Partials     1144     1144              
Impacted Files Coverage Δ
python/lsst/daf/butler/_quantum_backed.py 88.54% <ø> (-0.18%) ⬇️
python/lsst/daf/butler/_butlerConfig.py 96.92% <92.00%> (-3.08%) ⬇️
python/lsst/daf/butler/_butler.py 79.02% <100.00%> (-0.24%) ⬇️
python/lsst/daf/butler/_butlerRepoIndex.py 97.26% <100.00%> (+0.96%) ⬆️
python/lsst/daf/butler/script/configDump.py 100.00% <100.00%> (ø)
tests/test_butler.py 97.77% <100.00%> (+0.04%) ⬆️

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

Copy link
Contributor

@andy-slac andy-slac left a comment

Choose a reason for hiding this comment

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

Looks good, a couple of minor questions. I agree that you want to catch a wider set of exceptions when reading index.

python/lsst/daf/butler/_butlerRepoIndex.py Outdated Show resolved Hide resolved
Comment on lines +105 to +115
def clean_environment() -> None:
"""Remove external environment variables that affect the tests."""
for k in (
"DAF_BUTLER_REPOSITORY_INDEX",
"S3_ENDPOINT_URL",
"AWS_ACCESS_KEY_ID",
"AWS_SECRET_ACCESS_KEY",
"AWS_SHARED_CREDENTIALS_FILE",
):
os.environ.pop(k, None)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to make this more reusable and move to python/lsst/daf/butler/tests/utils.py?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm half inclined to remove the S3 code from here completely but we need one remote datastore for testing and we don't use the webdav one by default. There is lsst.resources.s3utils that tries to have something but it's not quite what we need. I probably should be trying to make that work for the S3 use case at USDF (where pytest doesn't work without this change). The DAF_BUTLER_REPOSITORY_INDEX clean up is really only needed for this one test of testConstructor and a general utility for the S3 tests in butler is only relevant for this one file.

@timj
Copy link
Member Author

timj commented Jun 7, 2023

I did just push a tweak which catches Exception and rewrites it to make it a bit clearer where it's coming from.

timj added 10 commits June 7, 2023 14:51
This also includes a more explicit error message rather than
relying on the Config() constructor.
This helps to explain why something didn't work.
This makes it easier to work out when no alias
resolution has happened.
This allows the logic, especially that revolving around
the construction of the error message, to be in one location.
An external DAF_BUTLER_REPOSITORY_INDEX setting can mess up
the tests. Additionally S3 env vars have the same effect.
The S3 tests also can be corrupted by the environment.
Now works directly with ButlerConfig.
If it's got malformed contents we still want to be able
to read a butler without using the alias.
Now cache the actual exception for later retrieval and
reset it on each call.
@timj timj merged commit 65f6e76 into main Jun 8, 2023
13 checks passed
@timj timj deleted the tickets/DM-39563 branch June 8, 2023 17:27
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

2 participants