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-38915: Fix handling of empty collection lists #835

Merged
merged 2 commits into from May 4, 2023
Merged

Conversation

andy-slac
Copy link
Contributor

Empty collection iterable is now handled as it was supposed to be handled -
producing empty result (with "doomed by" messages). I added a proper type
annotation for collections parameter in Registry methods to help me
verify that it is used correctly (maybe need to extend that to Butler
methods too). Also needed to update couple of CLI scripts to fix their
handling of the default collection values. Unit tests was added to check
that it works correctly now.

Checklist

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

Empty collection iterable is now handled as it was supposed to be handled -
producing empty result (with "doomed by" messages). I added a proper type
annotation for `collections` parameter in Registry methods to help me
verify that it is used correctly (maybe need to extend that to Butler
methods too). Also needed to update couple of CLI scripts to fix their
handling of the default collection values. Unit tests was added to check
that it works correctly now.
@codecov
Copy link

codecov bot commented May 3, 2023

Codecov Report

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

Comparison is base (f80a4f1) 87.75% compared to head (af9692a) 87.76%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #835      +/-   ##
==========================================
+ Coverage   87.75%   87.76%   +0.01%     
==========================================
  Files         268      268              
  Lines       35181    35246      +65     
  Branches     7407     7420      +13     
==========================================
+ Hits        30873    30935      +62     
  Misses       3154     3154              
- Partials     1154     1157       +3     
Impacted Files Coverage Δ
python/lsst/daf/butler/script/transferDatasets.py 44.44% <50.00%> (+3.26%) ⬆️
python/lsst/daf/butler/registries/remote.py 80.69% <71.42%> (+0.39%) ⬆️
python/lsst/daf/butler/registry/tests/_registry.py 98.08% <90.62%> (-0.17%) ⬇️
python/lsst/daf/butler/registries/sql.py 85.01% <95.65%> (+0.32%) ⬆️
python/lsst/daf/butler/registry/_registry.py 94.55% <100.00%> (+0.15%) ⬆️
python/lsst/daf/butler/registry/wildcards.py 54.54% <100.00%> (+0.43%) ⬆️
python/lsst/daf/butler/script/queryDataIds.py 86.66% <100.00%> (+0.95%) ⬆️
python/lsst/daf/butler/script/queryDatasets.py 87.50% <100.00%> (+0.17%) ⬆️
...on/lsst/daf/butler/script/queryDimensionRecords.py 74.19% <100.00%> (+4.96%) ⬆️
python/lsst/daf/butler/script/retrieveArtifacts.py 100.00% <100.00%> (ø)

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

Copy link
Member

@TallJimbo TallJimbo 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.

I don't think it's necessary to modify the butler methods right now unless you feel like it. It does seem like we should try to get to that point eventually. I had originally thought just using Any was fine here since we always conformed it with the wildcard class, but if it less this inconsistency slip through it's probably better to have this type alias.

"""Return true if both ``strings`` and ``patterns`` are empty."""
# bool(Ellipsis) is True
return not self.strings and not self.patterns

Copy link
Member

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 implement __bool__ instead, with the opposite sign?

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 thought about __bool__, but I decided that explicit method is better, it's too easy to mix check for True/False with check for None.

@andy-slac andy-slac merged commit 3e38a7b into main May 4, 2023
13 checks passed
@andy-slac andy-slac deleted the tickets/DM-38915 branch May 4, 2023 17:09
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