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-12640: Implement Initial Butler Registry Hierarchy #14

Merged
merged 1 commit into from Mar 2, 2018

Conversation

pschella
Copy link
Collaborator

No description provided.

@pschella pschella force-pushed the tickets/DM-12640 branch 3 times, most recently from 1628416 to 8c7e189 Compare March 1, 2018 19:56
@pschella pschella changed the title DM-12640: Implement Initial Butler Registry Hierarchy DM-12640: Initialize SqlRegistry Schema from YAML Mar 1, 2018
@pschella pschella force-pushed the tickets/DM-12640 branch 6 times, most recently from 2aaae47 to cbeac36 Compare March 1, 2018 20:26
@pschella pschella changed the title DM-12640: Initialize SqlRegistry Schema from YAML DM-12640: Implement Initial Butler Registry Hierarchy Mar 1, 2018
Copy link
Member

@timj timj left a 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):
Copy link
Member

Choose a reason for hiding this comment

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

elif?

Copy link
Collaborator Author

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'])
Copy link
Member

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
Copy link
Member

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.

#
# LSST Data Management System
#
# Copyright 2008-2018 AURA/LSST.
Copy link
Member

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:')
Copy link
Member

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/>.
Copy link
Member

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):
Copy link
Member

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'):
Copy link
Member

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?

Copy link
Collaborator Author

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.

Copy link
Member

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
Copy link
Member

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?

Copy link
Collaborator Author

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
Copy link
Member

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.

Copy link
Collaborator Author

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?

Copy link
Member

Choose a reason for hiding this comment

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

@pschella pschella merged commit 1a4c99d into master Mar 2, 2018
@ktlim ktlim deleted the tickets/DM-12640 branch August 25, 2018 06:49
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