Skip to content

Commit

Permalink
Ditch $PIPE_OUTPUT_ROOT as dafault output
Browse files Browse the repository at this point in the history
$PIPE_OUTPUT_ROOT should be a parent directory. Stop using it
as a default output directory if --output or --rerun not specified.
  • Loading branch information
r-owen committed Mar 11, 2016
1 parent f3eee9a commit 4b9fd8a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
16 changes: 7 additions & 9 deletions python/lsst/pipe/base/argumentParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,12 @@ def parse_args(self, config, args=None, log=None, override=None):

obeyShowArgument(namespace.show, namespace.config, exit=False)

# No environment variable or --output or --rerun specified.
if self.requireOutput and namespace.output is None and namespace.rerun is None:
self.error("no output directory specified.\n"
"An output directory must be specified with the --output or --rerun\n"
"command-line arguments.\n")

namespace.butler = dafPersist.Butler(
root = namespace.input,
calibRoot = namespace.calib,
Expand Down Expand Up @@ -496,12 +502,6 @@ def parse_args(self, config, args=None, log=None, override=None):
namespace.config.validate()
namespace.config.freeze()

# No environment variable or --output or --rerun specified.
if self.requireOutput and namespace.output is None and namespace.rerun is None:
self.error("no output directory specified.\n"
"An output directory must be specified with the --output or --rerun\n"
"command-line arguments or the PIPE_OUTPUT_ROOT environment variable.\n")

return namespace

def _parseDirectories(self, namespace):
Expand All @@ -516,10 +516,8 @@ def _parseDirectories(self, namespace):
# If an output directory is specified, process it and assign it to the namespace
if namespace.rawOutput:
namespace.output = _fixPath(DEFAULT_OUTPUT_NAME, namespace.rawOutput)
# This catches the case where the output was not specified, but _fixPath must still
# be run as there may be an environment variable set for the output
else:
namespace.output = _fixPath(DEFAULT_OUTPUT_NAME, namespace.rawOutput)
namespace.output = None

# This section processes the rerun argument, if rerun is specified as a colon separated
# value, it will be parsed as an input and output. The input value will be overridden if
Expand Down
13 changes: 2 additions & 11 deletions tests/testArgumentParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def testPipeVars(self):
)
self.assertEqual(namespace.input, os.path.abspath(DataPath))
self.assertEqual(namespace.calib, None)
self.assertEqual(namespace.output, os.path.abspath(DataPath))
self.assertEqual(namespace.output, None)

def testBareHelp(self):
"""Make sure bare help does not print an error message (ticket #3090)
Expand Down Expand Up @@ -469,6 +469,7 @@ def testConfigDatasetTypeNoFieldDefault(self):
"""Test ConfigDatasetType with a config field that has no default value"""
name = "dsTypeNoDefault"
ap = pipeBase.ArgumentParser(name="argumentParser")
ap.requireOutput = False # Allow simpler command-line
dsType = pipeBase.ConfigDatasetType(name=name)

ap.add_id_argument("--id", dsType, "help text")
Expand Down Expand Up @@ -496,16 +497,6 @@ def testOutputs(self):
self.assertEqual(args.output, path)
self.assertIsNone(args.rerun)

# Specified by environment variable
try:
os.environ["PIPE_OUTPUT_ROOT"] = path
args = parser.parse_args(config=self.config, args=[DataPath,])
self.assertEqual(args.input, DataPath)
self.assertEqual(args.output, path)
self.assertIsNone(args.rerun)
finally:
os.environ.pop("PIPE_OUTPUT_ROOT", None)

# Specified by rerun
args = parser.parse_args(config=self.config, args=[DataPath, "--rerun", "foo"])
self.assertEqual(args.input, DataPath)
Expand Down

0 comments on commit 4b9fd8a

Please sign in to comment.