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-42676: Fix quantum backed butler trust mode with chained datastore #951

Merged
merged 7 commits into from Jan 29, 2024

Conversation

timj
Copy link
Member

@timj timj commented Jan 26, 2024

Checklist

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

@@ -1116,6 +1116,11 @@ def transfer_from(
# child datastores.
source_datastores = (source_datastore,)

refs = list(refs)
Copy link
Member Author

Choose a reason for hiding this comment

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

This seems wrong to me but we've declared refs to be Iterable and that doesn't support len.

@@ -1116,6 +1116,11 @@ def transfer_from(
# child datastores.
source_datastores = (source_datastore,)

refs = list(refs)
if len(refs) == 0:
Copy link
Member Author

Choose a reason for hiding this comment

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

if not refs:

does pass mypy for an Iterator but not sure if that's safe.

Copy link
Contributor

Choose a reason for hiding this comment

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

If refs is a list then not refs and len(refs) == 0 work identically.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. That's my point, but in the more general case for Iterator am I setting myself up for pain if I do that. I am wondering if we should make the type annotation be Collection instead and therefore guarantee that len works, or do something like:

if not isinstance(refs, Sized):
    refs = list(refs)

Copy link
Contributor

Choose a reason for hiding this comment

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

If we need len then Collection annotation is probably better.

Copy link

codecov bot commented Jan 26, 2024

Codecov Report

Attention: 12 lines in your changes are missing coverage. Please review.

Comparison is base (6af44e7) 88.41% compared to head (7f485cf) 88.40%.

Files Patch % Lines
python/lsst/daf/butler/_named.py 0.00% 0 Missing and 4 partials ⚠️
...hon/lsst/daf/butler/datastores/chainedDatastore.py 66.66% 1 Missing and 1 partial ⚠️
python/lsst/daf/butler/dimensions/_record_table.py 0.00% 0 Missing and 2 partials ⚠️
python/lsst/daf/butler/logging.py 0.00% 0 Missing and 2 partials ⚠️
python/lsst/daf/butler/dimensions/_universe.py 0.00% 0 Missing and 1 partial ⚠️
python/lsst/daf/butler/json.py 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #951      +/-   ##
==========================================
- Coverage   88.41%   88.40%   -0.01%     
==========================================
  Files         303      303              
  Lines       39137    39128       -9     
  Branches     8244     8245       +1     
==========================================
- Hits        34602    34591      -11     
+ Misses       3341     3330      -11     
- Partials     1194     1207      +13     

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

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, one question about possible issues with .datastores.

@@ -1116,6 +1116,11 @@ def transfer_from(
# child datastores.
source_datastores = (source_datastore,)

refs = list(refs)
if len(refs) == 0:
Copy link
Contributor

Choose a reason for hiding this comment

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

If refs is a list then not refs and len(refs) == 0 work identically.

Comment on lines 360 to 362
for this_datastore in getattr(datastore, "datastores", [datastore]):
if hasattr(this_datastore, "trustGetRequest"):
this_datastore.trustGetRequest = True
Copy link
Contributor

Choose a reason for hiding this comment

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

So, if by some chance non-chained datastore adds datastores attribute, we won't try to set its trustGetRequest? And it will also crash if datastore.datastores is not an Iterable?

Copy link
Member Author

Choose a reason for hiding this comment

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

If datastores is not an iterable we are in trouble indeed. I was pondering adding datastores to Datastore and making it return [self] by default. Then it would be clear that it has a special purpose that only something like ChainedDatastore can override.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe just add "private" method _set_trust_mode() to the base class?

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 will do that. I wasn't sure I wanted to make it something that top-level given we can't think of anything outside FileDatastore caring.

@timj timj merged commit b175c21 into main Jan 29, 2024
16 of 18 checks passed
@timj timj deleted the tickets/DM-42676 branch January 29, 2024 15:45
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