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

Tickets/dm 7469 #27

Merged
merged 10 commits into from Oct 13, 2016
Merged

Tickets/dm 7469 #27

merged 10 commits into from Oct 13, 2016

Conversation

n8pease
Copy link
Contributor

@n8pease n8pease commented Sep 21, 2016

No description provided.

Copy link
Contributor

@ktlim ktlim left a comment

Choose a reason for hiding this comment

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

Mostly looks good.

repoData.repo.write(location, obj)
if isinstance(location, ButlerComposite):
components = {}
location.disassembler(obj=obj, dataId=location.dataId, componentDict=components)
Copy link
Contributor

@ktlim ktlim Sep 22, 2016

Choose a reason for hiding this comment

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

Might be nice to prefill components with the names of the datasets expected and even to pass the disassembler the expected dataset types. It's also a little confusing to have a local components dict as well as location.components.

if isinstance(location, ButlerComposite):
for name, info in location.components.items():
location.components[name] = self.get(info.datasetType, location.dataId, immediate=True,
**rest)
Copy link
Contributor

Choose a reason for hiding this comment

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

**rest has already been added to the dataId, so it shouldn't need to be passed through here.

from . import iterify, doImport

class ButlerComposite(object):
componentInfo = namedtuple('componentInfo', 'datasetType subset inputOnly')
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a class, so it should be capitalized, I would think.

:param dataId: the dataId that is used to look up components
:param mapper: a reference to the mapper that created this ButlerComposite object
"""
self.assembler = doImport(assembler) if isinstance(assembler, basestring) else assembler
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need a from past.builtins import basestring to run under Python3?

@@ -27,7 +27,7 @@
import inspect
Copy link
Contributor

@ktlim ktlim Sep 22, 2016

Choose a reason for hiding this comment

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

Not using inspect anymore, I think.

if type(self._mapper) != type(repositoryArgs.mapper):
return False
# check mapperArgs for any keys in common and if their value does not match then return false.
if self._mapperArgs is not None and repositoryArgs.mapperArgs is not None:
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't still need to check the mapperArgs?

@@ -123,20 +123,16 @@ def makeFromArgs(repositoryArgs, parents):
def matchesArgs(self, repositoryArgs):
Copy link
Contributor

Choose a reason for hiding this comment

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

docstring?

@@ -606,6 +606,14 @@ def get(self, datasetType, dataId=None, immediate=False, **rest):
bypassFunc = getattr(location.mapper, "bypass_" + datasetType)
callback = lambda: bypassFunc(datasetType, pythonType, location, dataId)
else:
if isinstance(location, ButlerComposite):
for name, info in location.components.items():
location.components[name] = self.get(info.datasetType, location.dataId, immediate=True,
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is a subset, this will have to be more complicated, no?

componentInfo = namedtuple('componentInfo', 'datasetType subset inputOnly')

def __init__(self, assembler, disassembler, python, dataId, mapper):
"""Initializer
Copy link
Contributor

Choose a reason for hiding this comment

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

Not required now, but you might think of starting to convert to Numpydoc (https://developer.lsst.io/docs/py_docs.html#documenting-python-apis)

@n8pease n8pease force-pushed the tickets/DM-7469 branch 4 times, most recently from 84db7e9 to 1aa0ec2 Compare September 27, 2016 21:16
import pkgutil
import lsstimport
__path__ = pkgutil.extend_path(__path__, __name__)

Copy link
Member

Choose a reason for hiding this comment

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

Why is this needed? I'm concerned it may be fragile to have an __init__.py file that has both the above invocation and any real content (such as the imports below). It implies that there is another __init__.py with the same Python name (i.e. lsst.daf.persistence) in another location, and I believe only one of those is ever executed.

The dataId that is used to look up components.
mapper : Mapper instance
A reference to the mapper that created this ButlerComposite object.
"""
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 docstrings for __init__ functions don't actually work as you might expect in Python (they don't appear when you ask for on-line help on the type). It's standard to instead document the constructor and its parameters in the class docstring. More on that here.

#

"""Python interface to lsst::daf::persistence classes
"""
Copy link
Member

Choose a reason for hiding this comment

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

Docstring is inaccurate (and perhaps not useful here).

self.data = data

def __eq__(self, other):
return self.data == other.data
Copy link
Member

Choose a reason for hiding this comment

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

Even if you don't use it, I'd recommend implementing __ne__ as well, just so avoid confusing behavior down the road (if you don't implement it, != will fall back to pointer equality instead of the inverse of your custom equality operator).

@n8pease n8pease force-pushed the tickets/DM-7469 branch 2 times, most recently from 73b038c to 148196b Compare September 28, 2016 21:15
@n8pease n8pease merged commit 9a47476 into master Oct 13, 2016
@ktlim ktlim deleted the tickets/DM-7469 branch August 25, 2018 06:14
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

3 participants