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-12627: Implement Butler DatasetType #20

Merged
merged 4 commits into from Mar 16, 2018
Merged

DM-12627: Implement Butler DatasetType #20

merged 4 commits into from Mar 16, 2018

Conversation

pschella
Copy link
Collaborator

No description provided.

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 okay. I mainly have questions about template vs FileTemplate and StorageClass vs a string (you document it to be a class but tests use it as a string).

return self._storageClass

def __init__(self, name, template, units, storageClass):
def __init__(self, name, dataUnits, storageClass, template=None):
Copy link
Member

Choose a reason for hiding this comment

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

Is the dataUnits argument here a frozenset and you copy it in the constructor?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It may be any iterable, but it becomes a frozenset in the constructor.

@@ -46,7 +45,7 @@ class DatasetType(object):
All arguments correspond directly to instance attributes.
Copy link
Member

Choose a reason for hiding this comment

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

Could really do with explicit Attributes and Parameters section.

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 thought it was policy to document these in the property docstrings?

Copy link
Member

Choose a reason for hiding this comment

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

Yes. I thought that in this case there was a difference between init parameters and attributes (on phone so not checking).

"""A `StorageClass` that defines how this `DatasetType` is persisted.
"""
return self._storageClass

@property
def template(self):
"""A string with `str`.format-style replacement patterns that can be
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 not related to the file name template used by datastore. Correct? (so this template is not a FileTemplate).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is related to that template. But it is unclear (to me at the moment) if we still want it here. I'll remove it for now.

datasetTypeUnitsTable = self._schema.metadata.tables['DatasetTypeUnits']
with self._engine.begin() as connection:
connection.execute(datasetTypeTable.insert().values(dataset_type_name=datasetType.name,
storage_class=datasetType.storageClass,
Copy link
Member

Choose a reason for hiding this comment

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

StorageClass doesn't have a __str__ method so what gets inserted into the table? Does it magically use StorageClass.name? Is it the full class name? StorageClasses are defined by the datastore so we have to work out how to verify that a registry is not specifying storage class names that a datastore doesn't know about.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is a name of a StorageClass. Not an instance.

result = connection.execute(select([datasetTypeTable.c.storage_class,
datasetTypeTable.c.template]).where(
datasetTypeTable.c.dataset_type_name == name)).fetchone()
storageClass = result['storage_class']
Copy link
Member

Choose a reason for hiding this comment

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

But DatasetType.storageClass is documented to be a StorageClass not 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'll change the docstring. Should be a name (for now at least).

class DatasetTypeTestCase(lsst.utils.tests.TestCase):
"""Test for DatasetType.
"""
def setUp(self):
Copy link
Member

Choose a reason for hiding this comment

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

No need to define it if it doesn't do anything.

datasetTypeName = "test"
storageClass = "StructuredData"
dataUnits = frozenset(("camera", "visit"))
template = "{datasetType}/{camera}/{visit}"
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 worried that we have two distinct template systems now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It should really be the same, but I'll remove it since this seems to be just a remnant of the old system.

DatasetType("a", "StorageA", ("UnitA", ), "{UnitB}"))

def testHashability(self):
types = []
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 test method needs a docstring to explain what is actually being tested. There's a lot going on here before the final conversion of the list to a set.

@pschella pschella merged commit e9143ed into master Mar 16, 2018
@ktlim ktlim deleted the tickets/DM-12627 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