diff --git a/CHANGES.txt b/CHANGES.txt index 7c014b077..348785fe8 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -2,6 +2,7 @@ v0.5.0, 2015-??-?? -- ??? * jobs: * mr() no longer takes positional arguments (#814) * removed jar() (use mrjob.step.JarStep) + * JarStep() only takes "args" and "main_class" keyword args * removed testing methods parse_counters() and parse_output() * runners: * All runners: diff --git a/mrjob/step.py b/mrjob/step.py index 0964eaab0..b0841f6a7 100644 --- a/mrjob/step.py +++ b/mrjob/step.py @@ -32,9 +32,12 @@ # params to specify how to run the step. need at least one of these _JOB_STEP_FUNC_PARAMS = _MAPPER_FUNCS + _COMBINER_FUNCS + _REDUCER_FUNCS -# all allowable step params +# all allowable MRStep params _JOB_STEP_PARAMS = _JOB_STEP_FUNC_PARAMS + _HADOOP_OPTS +# all allowable JarStep constructor keyword args +_JAR_STEP_KWARGS = ['args', 'main_class'] + log = logging.getLogger(__name__) @@ -91,8 +94,8 @@ def __init__(self, **kwargs): # limit which keyword args can be specified bad_kwargs = sorted(set(kwargs) - set(_JOB_STEP_PARAMS)) if bad_kwargs: - raise TypeError( - 'mr() got an unexpected keyword argument %r' % bad_kwargs[0]) + raise TypeError('MRStep() got an unexpected keyword argument %r' % + bad_kwargs[0]) if not set(kwargs) & set(_JOB_STEP_FUNC_PARAMS): raise ValueError("Step has no mappers and no reducers") @@ -253,8 +256,7 @@ class JarStep(object): #: with the step's output path OUTPUT = '' - # in v0.5.0, replace "*args" with "jar" - def __init__(self, *args, **kwargs): + def __init__(self, jar, **kwargs): """Define a Java JAR step. Accepts the following keyword arguments: @@ -267,35 +269,19 @@ def __init__(self, *args, **kwargs): in the jar's manifest file. :param args: (optional) A list of arguments to the jar + *jar* can also be passed as a positional argument + See :ref:`non-hadoop-streaming-jar-steps` for sample usage. """ - if args: - self._init_deprecated(*args, **kwargs) - else: - self._init_kwargs(**kwargs) - - def _init_deprecated( - self, name, jar, main_class=None, step_args=None, args=None): - log.warning('Positional arguments to JarStep() (other than' - ' jar) are deprecated and will be removed in v0.5.0') + bad_kwargs = sorted(set(kwargs) - set(_JAR_STEP_KWARGS)) + if bad_kwargs: + raise TypeError('JarStep() got an unexpected keyword argument %r' % + bad_kwargs[0]) self.jar = jar - self.main_class = main_class - self.args = args or step_args or [] - - def _init_kwargs( - self, jar, main_class=None, args=None, step_args=None, name=None): - # deprecated arguments - if step_args: - log.warning('step_args argument to JarStep() has been' - ' renamed to args, and will be removed in v0.5.0') - if name: - log.warning('name argument to JarStep() has no effect, and will' - ' be removed in v0.5.0') - self.jar = jar - self.main_class = main_class - self.args = args or step_args or [] + self.args = kwargs.get('args') or [] + self.main_class = kwargs.get('main_class') def __repr__(self): repr_args = [] diff --git a/tests/test_step.py b/tests/test_step.py index 1f4b6a194..e34d00c90 100644 --- a/tests/test_step.py +++ b/tests/test_step.py @@ -60,40 +60,6 @@ def test_some(self): self.assertEqual(JarStep(**kwargs).description(0), expected) -class JarStepDeprecatedArgumentsTestCase(TestCase): - - def test_positional(self): - with logger_disabled('mrjob.step'): - self.assertEqual( - JarStep('foo', 'bell.jar', 'First', ['one', '2']), - JarStep(jar='bell.jar', main_class='First', args=['one', '2']) - ) - - def test_mixed(self): - with logger_disabled('mrjob.step'): - self.assertEqual( - JarStep('foo', jar='bell.jar', args=['3', 'four']), - JarStep(jar='bell.jar', args=['3', 'four']) - ) - - def test_step_args_kwarg(self): - with logger_disabled('mrjob.step'): - self.assertEqual( - JarStep(jar='bell.jar', step_args=['5', 'six']), - JarStep(jar='bell.jar', args=['5', 'six']) - ) - - def test_name_kwarg(self): - with logger_disabled('mrjob.step'): - self.assertEqual( - JarStep(jar='pickle.jar', name='Bubbies'), - JarStep(jar='pickle.jar') - ) - - def test_bad_kwarg(self): - self.assertRaises(TypeError, JarStep, foo='bar') - - class MRStepInitTestCase(TestCase): ### Basic behavior ###