-
Notifications
You must be signed in to change notification settings - Fork 14
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
Conversation
Codecov ReportAttention:
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. |
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.
a9970df
to
c8766bb
Compare
There was a problem hiding this 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.
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"), | ||
), | ||
) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
bd79a50
to
32800dc
Compare
Checklist
doc/changes