Skip to content

Commit

Permalink
Force Workspace to report absolute paths.
Browse files Browse the repository at this point in the history
  • Loading branch information
kfindeisen committed Apr 14, 2020
1 parent a976c38 commit 5d74d63
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
26 changes: 16 additions & 10 deletions python/lsst/ap/verify/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ class Workspace:
"""

def __init__(self, location):
self._location = location
# Properties must be `str` for backwards compatibility
self._location = str(pathlib.Path(location).resolve())

mode = stat.S_IRWXU | stat.S_IRGRP | stat.S_IROTH # a+r, u+rwx
kwargs = {"parents": True, "exist_ok": True, "mode": mode}
Expand All @@ -66,45 +67,50 @@ def __init__(self, location):

@property
def workDir(self):
"""The location of the workspace as a whole (`str`, read-only).
"""The absolute location of the workspace as a whole
(`str`, read-only).
"""
return self._location

@property
def configDir(self):
"""The location of a directory containing custom Task config files for
use with the data (`str`, read-only).
"""The absolute location of a directory containing custom Task config
files for use with the data (`str`, read-only).
"""
return os.path.join(self._location, 'config')

@property
def dataRepo(self):
"""The URI to a Butler repo for science data (`str`, read-only).
"""The absolute path/URI to a Butler repo for science data
(`str`, read-only).
"""
return os.path.join(self._location, 'ingested')

@property
def calibRepo(self):
"""The URI to a Butler repo for calibration data (`str`, read-only).
"""The absolute path/URI to a Butler repo for calibration data
(`str`, read-only).
"""
return os.path.join(self._location, 'calibingested')

@property
def templateRepo(self):
"""The URI to a Butler repo for precomputed templates (`str`, read-only).
"""The absolute path/URI to a Butler repo for precomputed templates
(`str`, read-only).
"""
return self.dataRepo

@property
def outputRepo(self):
"""The URI to a Butler repo for AP pipeline products (`str`, read-only).
"""The absolute path/URI to a Butler repo for AP pipeline products
(`str`, read-only).
"""
return os.path.join(self._location, 'output')

@property
def dbLocation(self):
"""The default location of the source association database to be
created or updated by the pipeline (`str`, read-only).
"""The default absolute location of the source association database to
be created or updated by the pipeline (`str`, read-only).
Shall be a filename to a database file suitable
for the sqlite backend of `Apdb`.
Expand Down
3 changes: 2 additions & 1 deletion tests/test_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def testDirectories(self):
The exact repository locations are not tested, as they are likely to change.
"""
root = self._testWorkspace
# Workspace should report all paths as absolute
root = os.path.abspath(os.path.realpath(self._testWorkspace))
self.assertEqual(self._testbed.workDir, root)
self._assertInDir(self._testbed.configDir, root)
for repo in WorkspaceTestSuite._allRepos(self._testbed):
Expand Down

0 comments on commit 5d74d63

Please sign in to comment.