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
Tickets/dm 7469 #27
Conversation
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.
Mostly looks good.
repoData.repo.write(location, obj) | ||
if isinstance(location, ButlerComposite): | ||
components = {} | ||
location.disassembler(obj=obj, dataId=location.dataId, componentDict=components) |
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.
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) |
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.
**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') |
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 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 |
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.
Do you need a from past.builtins import basestring
to run under Python3?
@@ -27,7 +27,7 @@ | |||
import inspect |
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 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: |
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.
You don't still need to check the mapperArgs
?
@@ -123,20 +123,16 @@ def makeFromArgs(repositoryArgs, parents): | |||
def matchesArgs(self, repositoryArgs): |
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?
@@ -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, |
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.
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 |
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 required now, but you might think of starting to convert to Numpydoc (https://developer.lsst.io/docs/py_docs.html#documenting-python-apis)
84db7e9
to
1aa0ec2
Compare
import pkgutil | ||
import lsstimport | ||
__path__ = pkgutil.extend_path(__path__, __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.
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. | ||
""" |
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 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 | ||
""" |
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 is inaccurate (and perhaps not useful here).
self.data = data | ||
|
||
def __eq__(self, other): | ||
return self.data == other.data |
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.
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).
73b038c
to
148196b
Compare
also becuase of auto import behavior of unit test packages, TestObject had been renamed to ObjectTest; I put it back to TestObject.
148196b
to
0bd26ef
Compare
No description provided.