Add additional hook to modify task parameters before instantiation.
@@ -122,18 +122,34 @@ class BaseTask(six.with_metaclass(BaseRegister, luigi.Task)):
return success
@classmethod
- def get_param_values(cls, *args, **kwargs):
- values = super(BaseTask, cls).get_param_values(*args, **kwargs)
+ def get_param_values(cls, params, args, kwargs):
+ # try to modify the values before values are assigned
+ if callable(cls.modify_param_args):
+ params, args, kwargs = cls.modify_param_args(params, args, kwargs)
+
+ # assign to actual parameters
+ values = super(BaseTask, cls).get_param_values(params, args, kwargs)
+
+ # try to modify the values afterwards
if callable(cls.modify_param_values):
- return list(cls.modify_param_values(OrderedDict(values)).items())
- else:
+ values = list(cls.modify_param_values(OrderedDict(values)).items())
+
return values
+ # method that can be implemented to update parameter objects, args and kwargs before before task
+ # instantiation and before parameter values are assined in the super get_param_values
+ # example:
+ # @classmethod
+ # def modify_param_args(cls, params, args, kwargs):
+ # return params, args, kwargs
+ modify_param_args = None
+
# method that can be implemented to update parameters via get_param_values before instantiation
# example:
# @classmethod
- # def modify_param_values(cls, params):
- # return params
+ # def modify_param_values(cls, values):
+ # values["some_name"] = "some_value"
+ # return values
modify_param_values = None
@classmethod
