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-12640: Implement Initial Butler Registry Hierarchy #14
Conversation
1628416
to
8c7e189
Compare
2aaae47
to
cbeac36
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 good but some cleanup required.
if not isinstance(config, RegistryConfig): | ||
if isinstance(config, str): | ||
config = Config(config) | ||
if isinstance(config, Config): |
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.
elif
?
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.
No, because it needs to build a RegistryConfig
.
@@ -37,18 +37,25 @@ class Registry(metaclass=ABCMeta): | |||
""" | |||
@staticmethod | |||
def fromConfig(config): | |||
cls = doImport(config['registry.cls']) |
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.
Add docstring.
config = RegistryConfig(config['registry']) | ||
else: | ||
raise ValueError("Incompatible Registry configuration: {}".format(config)) | ||
cls = doImport(config['cls']) | ||
return cls(config=config) | ||
|
||
def __init__(self, config): | ||
"""Constructor |
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.
docstring for constructor goes in class docstring.
https://developer.lsst.io/docs/py_docs.html#placement-of-class-docstrings
I won't mention this again in the review.
tests/test_schema.py
Outdated
# | ||
# LSST Data Management System | ||
# | ||
# Copyright 2008-2018 AURA/LSST. |
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.
Please use the updated preamble. Remove this copyright because it's in the COPYRIGHT
file now.
self.schemaFile = os.path.join(self.testDir, "../config/registry/default_schema.yaml") | ||
self.config = SchemaConfig(self.schemaFile) | ||
self.schema = Schema(self.config) | ||
self.engine = create_engine('sqlite:///:memory:') |
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.
This is good. Means that the tests can all run in parallel.
@@ -21,351 +21,148 @@ | |||
# see <https://www.lsstcorp.org/LegalNotices/>. |
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'm not sure how this file still has the old preamble. I fixed it in 0346dbc
metadata = None # Needed to make disabled test_hsc not fail on import | ||
|
||
|
||
def iterable(a): |
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 think this should go in the utils.py
package.
- a string -> return single element iterable (e.g. [a]) | ||
- not iterable -> return single elment iterable (e.g. [a]). | ||
""" | ||
if hasattr(a, 'encode'): |
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.
Why can't we just see if it's a str
?
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 had a debate about this with @natelust. This should be faster.
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.
In [3]: x = "xxx"
In [4]: %timeit hasattr(x, "encode")
109 ns ± 0.692 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)
In [5]: %timeit isinstance(x, str)
102 ns ± 0.961 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)
It doesn't look obviously different. I think we should go for the obvious implementation rather than looking for a side effect (and I can easily break yours by having a class with an encode method).
Description of the column to be created. | ||
Should always contain: | ||
- name, descriptive name | ||
- type, valid column type |
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.
This type is a type understood by the underlying database technology (in this case sqlaclhemy?) and not some abstract type that will be translated to something db-specific later on?
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.
Not quite. It should be a type in our type naming convention (which we haven't formalized yet).
|
||
Raises | ||
------ | ||
e : `ValueError |
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.
The docstring style guide does not include the e :
for exceptions.
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.
Doesn't the a : T
syntax require a name?
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.
cbeac36
to
71f6590
Compare
5f7a9fd
to
221a7fa
Compare
No description provided.