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-27985: Improvements to query system, especially temporal aspects #450
Conversation
7227604
to
c9733e4
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.
I have to stop for today, here are the comments so far.
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, bunch of minor comments for docstrings mostly. I'm still not sure what to think about empty Timespan, its semantic looks confusing to me (but I'm easily confused by many things in daf_butler🙂).
c9733e4
to
a12009f
Compare
Thanks for the detailed review, @andy-slac. I've pushed a few more commits and amended many more, and I think I've addressed all comments. If you're up for it, two of the new ones may be worth another look. The other new one, 15afa4a, is totally mechanical, so the most you'd want to look at is the commit message, I think. |
if constant is ExpressionConstant.INGEST_DATE: | ||
return TreeSummary(hasIngestDate=True) | ||
elif constant is not None: | ||
return TreeSummary() |
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.
Maybe try to make it a bit more stable w.r.t. potential extension of ExpressionConstant, like:
if constant is ExpressionConstant.INGEST_DATE:
...
elif constant is ExpressionConstant.NULL:
....
assert constant is None, "..."
class TimeConverter(metaclass=Singleton): | ||
"""A singleton that provides methods for mapping TAI times to integer |
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.
A bit surprising to see singleton used to solve this problem, but probably fine. I guess I just don't like singletons in general 🙂.
I checked recent commits, they look fine, couple of minor comments. |
a12009f
to
82b8b87
Compare
This adds a new SpatialRegionDatabaseRepresentation class to encapsulate how we store regions in the database, and shuffles some code between TimespanDatabaseRepresentation and its (and the new class's) base class, TopologicalEndpointDatabaseRepresentation. Because we still only have one representation for spatial regions in the database (opaque byte strings with no database-side operators), this doesn't change functionality, but it cleans up centralizes what was previously a lot of scattered hard-coding of how we handle regions. It may also make it a bit easier to support database-native regions with real operators someday in the future, but given that don't know if we'll ever want that, that's at most a small side bonus.
In addition to adding __repr__ and one __str__ to the classes returned by .full and .records, this makes DataCoordate.__repr__ report only required dimensions, because that's all that's in keys(). That's good because the inherited values() implementation returns a ValuesView with a __repr__ that prints the __repr__ of the whole mapping, so before this change, the keys *appearing* there would differ both from what was actually in the ValuesView and what was in the keys (and the same was true of items()/ItemsView, I think).
This moves conversion to integer nanoseconds from astropy.time.Time to Timespan, instead of at the SQLAlchemy layer, which means we can finally make the edge-case handling (which has been improved - in that it's now consistent - in other ways) actually the same in Python and the DB. This also adds methods to construct TimespanDatabaseRepresentation instances from Timespan literals. That means we don't need to provide methods that relate TimespanDatabaseRepresentation to Timespan anymore. Code that starts with a mix of those types is now responsible for doing the conversion. On the other hand, because Timespan and TimespanDatabaseRepresentation can't exactly represent instants in time, we do need "overloads" for relatinship methods that take astropy.time.Time and sqlalchemy.sql.ColumnElement objects that represent times.
This one has support for timespan columns and bindparams, but is not used yet.
This was the old way of converting expression trees to SQL.
This commit is _just_ moving code around and changing import statements.
This defers all operations until first use (instead of import-time) and adds a bit of encapsulation.
...and similarly for regRepr->RegionReprClass. These symbols invariably refer to a type object that is a subclass of TimespanDatabaseRepresentation (or SpatialRegionDatabaseRepresentation).
82b8b87
to
75c3c1f
Compare
No description provided.