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-41724: make dimension record construction more strict #907

Merged
merged 8 commits into from
Nov 17, 2023

Conversation

TallJimbo
Copy link
Member

@TallJimbo TallJimbo commented Nov 17, 2023

Checklist

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

Copy link

codecov bot commented Nov 17, 2023

Codecov Report

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

Comparison is base (8e2519f) 87.72% compared to head (32800dc) 87.72%.

Files Patch % Lines
python/lsst/daf/butler/dimensions/_records.py 75.00% 1 Missing and 1 partial ⚠️
...on/lsst/daf/butler/script/queryDimensionRecords.py 81.81% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #907      +/-   ##
==========================================
- Coverage   87.72%   87.72%   -0.01%     
==========================================
  Files         285      285              
  Lines       36743    36760      +17     
  Branches     7690     7698       +8     
==========================================
+ Hits        32232    32246      +14     
- Misses       3340     3341       +1     
- Partials     1171     1173       +2     

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

Timespan.__repr__ has complete information, so we can make __str__ a
bit more concise while still including the information we tend to care
about.
Timespan was messy and quite long, and is now concise.  Regions were
really long and not very useful on the CLI, and are now elided
entirely.

This drops a test workaround for older astropys and bumps the version
in requirements.txt, which is already required in rubin-env.
datetimeBegin and datetimeEnd have never been recognized as timespan
bounds, but DimensionRecord ignores kwargs it doesn't recognize.
These had gone unnoticed because DimensionRecord silently ignores
kwargs it does not recognize.
This field is no longer part of the default DimensionUniverse but it's
present in some old YAML exports we want to continue to support.
Right now it's being dropped by virtue of DimensionRecord.__init__
silently ignoring any kwargs it does not recognize, which is not ideal.
Copy link
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.

Looks OK to me, other than the one behavior change above where I wasn't sure if it was intentional or not.

Comment on lines +299 to +309
if self.definition.temporal is not None and self.timespan is None and "datetime_begin" in kwargs:
object.__setattr__(
self,
"timespan",
Timespan(
kwargs.pop("datetime_begin"),
kwargs.pop("datetime_end"),
),
)
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a small change in behavior here, not sure if it is intended to enforce that any Timespan here will always be bounded or not.

Previously if only datetime_begin was passed without also including datetime_end, it would create a Timespan without an upper bound. Now it throws KeyError in this case instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

It was intentional, but the reader shouldn't have to wonder about that; I'll add a code comment saying that if you pass one you're required to pass both.

@TallJimbo TallJimbo merged commit f22234c into main Nov 17, 2023
16 of 17 checks passed
@TallJimbo TallJimbo deleted the tickets/DM-41724 branch November 17, 2023 23:31
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.

2 participants