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
daf_persistence Tickets/dm 8686 #46
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.
Looks OK, my comments mostly for docstrings as I'm not sure I understand all (or any) butler details yet.
|
||
Returns | ||
------- | ||
ButlerLocaiton or a list of ButlerLocation |
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.
First ButlerLocaiton is misspelled.
If no locaiton was found for this map operation, the derived mapper | ||
class may raise a lsst.daf.persistence.NoResults exception. Butler | ||
catches this and will look in the next Repository if there is one. | ||
""" | ||
func = getattr(self, 'map_' + datasetType) |
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 will throw AttributeError if method is not there, should this be listed in docstring too? Or is it not supposed to happen?
|
||
import yaml | ||
|
||
from . import LogicalLocation, Persistence, Policy, StorageList, Registry, Storage, RepositoryCfg, safeFileIo | ||
from . import LogicalLocation, Persistence, Policy, StorageList, Registry, Storage, RepositoryCfg, \ | ||
safeFileIo, ButlerLocation |
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 can do
from . import (LogicalLocation, Persistence, Policy, StorageList, Registry, Storage, RepositoryCfg,
safeFileIo, ButlerLocation)
then you don't need that ugly backslash 😄
string | ||
A relative path that describes the path from fromUri to toUri. | ||
""" | ||
return os.path.relpath(toUri, fromUri) |
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.
Is URI a URI or filesystem path? Can this handle file:///path
?
"""Implementaion of PosixStorage.exists for ButlerLocation objects.""" | ||
storageName = location.getStorageName() | ||
if storageName not in ('BoostStorage', 'FitsStorage', 'PafStorage', | ||
'PickleStorage', 'ConfigStorage', 'FitsCatalogStorage'): |
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.
Is this list of magic names going to grow, maybe move it to more visible location?
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.
it's not going to grow, at least not much. We are planning to add a pluggable system for storageName functionality.
@@ -61,16 +87,16 @@ def v1Constructor(loader, node): | |||
""" | |||
d = loader.construct_mapping(node) | |||
cfg = RepositoryCfg(root=d['_root'], mapper=d['_mapper'], mapperArgs=d['_mapperArgs'], | |||
parents=d['_parents'], policy=d.get('_policy', None)) | |||
parents=d['_parents'], policy=d.get('_policy', None), deserialzing=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.
And here
:return: a Storage subclass instance. | ||
Parameters | ||
---------- | ||
uri - string |
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 canonical format is uri : string
. And generally I think we are supposed to use backticks around types in docstrings.
tests/repository.py
Outdated
@@ -718,7 +724,7 @@ def test(self): | |||
mapper=MapperForTestWriting, | |||
mapperArgs=None, | |||
parents=[os.path.join(ROOT, | |||
'TestOutputAlreadyHasParent/a'),], | |||
'TestOutputAlreadyHasParent/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.
That comma is not really needed there?
parentRepoData = self._repos.byCfgRoot[parentCfgRoot] | ||
parents.append(parentRepoData) | ||
parents.extend(self._getParentRepodDatas(parentRepoData)) | ||
return parents |
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'd probably make it a generator.
if parentRepoData.cfg.mapper == repoData.cfg.mapper: | ||
if not parentRepoData.repo: | ||
raise RuntimeError("Parent repo should be initialized before child repos.") | ||
registry = parentRepoData.repo.getRegistry() |
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 break
here?
7a4e0de
to
e504a75
Compare
f214ea4
to
33bdae6
Compare
The test used to rely on mapper checking before trying to load repos. The Butler has changed so that this no longer works, fix the test to actually create repos.
move CameraMapper.parentSearch impl to PosixStorage
PosixStorage 1. sets up the output repo 2. makes a _parent symlink from output to input I'm not sure what will have to be done for other storages.
adds ability to not follow _parent symlink in parentSearch. adds unit test
Also remove commented code
this allows resources e.g. the registry to be fetched from parent repos, even if the parent is of a write-only repo (that is, even if the parent is not used as an input)
The parent rule is "parents of writable repositories must be inputs". This might end up being a little tedious, as if an existing output is loaded a second time, all the parents of that output must exactly match the inputs passed to Butler.__init__. This might be acceptable in our environment as reloaded Butler output repositories will be loaded by scripts that I think will load all the same repos as needed multiple times. If it's not ok, we can add a stage that preloads the parents of outputs as inputs before the final parents list is needed to be known.
33bdae6
to
3c6f5a8
Compare
can't add parents to an existing output repository
a42ea2f
to
5661e43
Compare
No description provided.