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-27985: Improvements to query system, especially temporal aspects #450

Merged
merged 20 commits into from Dec 17, 2020

Conversation

TallJimbo
Copy link
Member

No description provided.

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.

I have to stop for today, here are the comments so far.

python/lsst/daf/butler/core/time_utils.py Outdated Show resolved Hide resolved
python/lsst/daf/butler/registry/queries/_structs.py Outdated Show resolved Hide resolved
python/lsst/daf/butler/core/timespan.py Outdated Show resolved Hide resolved
python/lsst/daf/butler/core/timespan.py Show resolved Hide resolved
python/lsst/daf/butler/core/timespan.py Show resolved Hide resolved
python/lsst/daf/butler/core/timespan.py Show resolved Hide resolved
python/lsst/daf/butler/core/timespan.py Outdated Show resolved Hide resolved
python/lsst/daf/butler/core/timespan.py Show resolved Hide resolved
python/lsst/daf/butler/core/timespan.py Outdated Show resolved Hide resolved
python/lsst/daf/butler/core/timespan.py Outdated Show resolved Hide resolved
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 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🙂).

python/lsst/daf/butler/core/_topology.py Outdated Show resolved Hide resolved
python/lsst/daf/butler/core/_topology.py Show resolved Hide resolved
python/lsst/daf/butler/core/_topology.py Outdated Show resolved Hide resolved
python/lsst/daf/butler/registry/tests/_registry.py Outdated Show resolved Hide resolved
@TallJimbo
Copy link
Member Author

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.

Comment on lines 198 to 201
if constant is ExpressionConstant.INGEST_DATE:
return TreeSummary(hasIngestDate=True)
elif constant is not None:
return TreeSummary()
Copy link
Contributor

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, "..."

Comment on lines +45 to +46
class TimeConverter(metaclass=Singleton):
"""A singleton that provides methods for mapping TAI times to integer
Copy link
Contributor

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 🙂.

@andy-slac
Copy link
Contributor

I checked recent commits, they look fine, couple of minor comments.

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).
@TallJimbo TallJimbo merged commit 8bab6bc into master Dec 17, 2020
@TallJimbo TallJimbo deleted the tickets/DM-27985 branch December 17, 2020 04:01
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