Skip to content

Commit 94a67a4

Browse files
author
David Marin
committed
Merge pull request #855 from dterror/setting-script-path-fix
First arg is script_path unless explicitly set
2 parents 1b424a4 + 5d82aff commit 94a67a4

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

mrjob/launch.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -368,12 +368,12 @@ def _process_args(self, args):
368368
uses all args as input files. This method determines the behavior:
369369
MRJobLauncher takes off the first arg as the script path.
370370
"""
371-
if self._script_path:
372-
self._script_path = os.path.abspath(args[0])
373-
elif len(args) < 1:
374-
self.option_parser.error('Must supply script path')
375-
376-
self.args = args[1:]
371+
if not self._script_path:
372+
if len(args) < 1:
373+
self.option_parser.error('Must supply script path')
374+
else:
375+
self._script_path = os.path.abspath(args[0])
376+
self.args = args[1:]
377377

378378
def _help_main(self):
379379
self.option_parser.option_groups = []

tests/test_launch.py

+4
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,7 @@ def test_no_conf_overrides(self):
278278
def test_no_conf_overridden(self):
279279
mr_job = MRCustomJobLauncher(args=['', '--no-conf', '-c', 'blah.conf'])
280280
self.assertEqual(mr_job.options.conf_paths, ['blah.conf'])
281+
282+
def test_requires_script_path(self):
283+
self.assertRaises(ValueError, MRCustomJobLauncher, args=[])
284+

0 commit comments

Comments
 (0)