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

daf_persistence Tickets/dm 8686 #46

Merged
merged 55 commits into from Mar 15, 2017
Merged

daf_persistence Tickets/dm 8686 #46

merged 55 commits into from Mar 15, 2017

Conversation

n8pease
Copy link
Contributor

@n8pease n8pease commented Feb 22, 2017

No description provided.

Copy link
Contributor

@andy-slac andy-slac left a 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
Copy link
Contributor

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)
Copy link
Contributor

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

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)
Copy link
Contributor

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

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?

Copy link
Contributor Author

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)
Copy link
Contributor

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

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.

@@ -718,7 +724,7 @@ def test(self):
mapper=MapperForTestWriting,
mapperArgs=None,
parents=[os.path.join(ROOT,
'TestOutputAlreadyHasParent/a'),],
'TestOutputAlreadyHasParent/a'), ],
Copy link
Contributor

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

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()
Copy link
Contributor

Choose a reason for hiding this comment

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

No break here?

n8pease and others added 26 commits March 14, 2017 13:15
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.
Nate Pease and others added 2 commits March 15, 2017 13:15
can't add parents to an existing output repository
@n8pease n8pease merged commit 5661e43 into master Mar 15, 2017
@ktlim ktlim deleted the tickets/DM-8686 branch August 25, 2018 06:15
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