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 9039 #43

Merged
merged 35 commits into from Feb 22, 2017
Merged

daf_persistence Tickets/dm 9039 #43

merged 35 commits into from Feb 22, 2017

Conversation

n8pease
Copy link
Contributor

@n8pease n8pease commented Feb 1, 2017

No description provided.

handler function for creating inputs & outputs
when Butler.__init__ is called with root,
mapper, mapperArgs
also change most locations that abbreviated repository
to repo to use full word "repository"
IE make it official. Moves the arg into the repocfg
constructor, and adjusts use cases.

Allows setting mapper in cfg if the cfg is for a
new repo.
they are related to Butler state and don't belong in
an object that gets serialized.
(said 'read only', clearly meant 'write only'; outputs
by default are write only, which is what is done here.)
The new Butler init sequence requires that input repositories
exist. This test was using an input that did not exist, and
it did not matter that the repo did not exist, because the
test is entirely for processing mapper data, that is hard
coded into the test mapper for this test.

Fix is to make the the repo used by the Butler for this test
be an output with mode='rw' instead of an input with mode='r'.
Butler now handles v1 repos in _createRepoData
some of the unit tests use a folder called _parent (instead
of a symlink called _parent to another folder).
@@ -115,6 +125,8 @@ def testAbsoluteFilePathWithSchema(self):
butler = dp.Butler(outputs=args)
self.assertTrue(os.path.exists(os.path.join(self.testDir, 'repositoryCfg.yaml')))

butler2 = dp.Butler(inputs=uri)
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 mean to perform the same exact call twice?
It seems to me you only want the second call on line 131 which explicitly fails the test if an exception is thrown

repo1Root = os.path.join(self.testDir, 'repo1')
repo2Root = os.path.join(self.testDir, 'repo2')
butler = dp.Butler(outputs=(dp.RepositoryArgs(root=repo1Root, mapper=mapper1)))
del butler
Copy link
Contributor

Choose a reason for hiding this comment

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

Is del butler necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sometimes it clarifies intention (a new one is created later), and other times it gets the linter to stop complaining about unused variables. and sometimes both.

"""Test if a URI is for a local filesystem storage.

This is mostly for backward compatibility; Butler V1 repositories were only ever on the local
filesystem. They may exist but not have a RepositoryCfg class. This enables conditional checking for a
Copy link
Contributor

Choose a reason for hiding this comment

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

doc string length

True if the URI is associated with a posix storage, else false.
"""
parseRes = urllib.parse.urlparse(uri)
if parseRes.scheme in ('file', ''):
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add to the function documentation that you are checking for the explicit file scheme in the uri or interpreting the lack of a specific scheme to tacitly imply thefile scheme. I say this just because this line looks quite funny at first glance - it's not apparent that you are accepting the lack of a scheme at first glance.

@@ -179,6 +200,7 @@ def map(self, *args, **kwargs):
:return: The type of item is dependent on the mapper being used but is typically a ButlerLocation.
"""
if self._mapper is None:
raise RuntimeError("no mapper for repo") # remind me why we allow this
Copy link
Contributor

Choose a reason for hiding this comment

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

Next line is unreachable

def cfgRoot(self):
if self._cfgRoot is not None:
return self._cfgRoot
else:
return self.root

@property
def root(self):
if self._root 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.

Is it possible for self._root or self._cfgRoot to ever be False?
If not, potentially consider:
return self._root if self._root else self._cfgRoot
(and the opposite for def cfgRoot(self): above

"""
if not os.path.exists(root):
return False
return os.listdir(root)
Copy link
Contributor

Choose a reason for hiding this comment

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

os.listdir returns a list. len(os.listdir)?

Maybe:
return os.path.exists(root) and len(os.listdir(root))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually:
return os.path.exists(root) and bool(os.listdir(root))
but yup. ok.

isV1Args = inputs is None and outputs is None
if isV1Args:
inputs, outputs = self._convertV1Args(root=root, mapper=mapper, mapperArgs=mapperArgs)
elif root:
Copy link
Contributor

Choose a reason for hiding this comment

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

If root is throwing a RuntimeError, shouldn't the message say "root is no longer a supported parameter", since deprecated usually means warning.

return parents

def _createRepoDatas(self, inputs, outputs):
"""Create the RepoDataContainer and put a RepoData object in it for each repository listed in inputs
Copy link
Contributor

Choose a reason for hiding this comment

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

too long

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.
@n8pease n8pease merged commit a211d6c into master Feb 22, 2017
@ktlim ktlim deleted the tickets/DM-9039 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