law.task.base#
Custom luigi base task definitions.
Class BaseRegister#
Class BaseTask#
- class BaseTask(*args, **kwargs)[source]#
Bases:
Task- classmethod deregister(task_cls: BaseRegister | None = None) bool[source]#
Removes a task class task_cls from the luigi task register. When None, this class is used. Task family strings and patterns are accepted as well. True is returned when at least one class was successfully removed, and False otherwise.
- classmethod modify_task_attributes() None[source]#
Hook to modify class attributes before the class is added to the register.
- classmethod modify_param_args(params: list[tuple[str, Parameter]], args: tuple[Any, ...], kwargs: dict[str, Any]) tuple[list[tuple[str, Parameter]], tuple[Any, ...], dict[str, Any]][source]#
Hook to modify command line arguments before they are event created within
get_param_values().
- classmethod modify_param_values(params: dict[str, Any]) dict[str, Any][source]#
Hook to modify command line arguments before instances of this class are created.
- classmethod get_param_values(params: list[tuple[str, Parameter]], args: tuple[Any, ...], kwargs: dict[str, Any]) list[Any][source]#
Get the values of the parameters from the args and kwargs.
- Parameters:
params – list of (param_name, Parameter).
args – positional arguments
kwargs – keyword arguments.
- Returns:
list of (name, value) tuples, one for each parameter.
- complete() bool[source]#
If the task has any outputs, return
Trueif all outputs exist. Otherwise, returnFalse.However, you may freely override this method with custom logic.
- input() Any[source]#
Returns the outputs of the Tasks returned by
requires()See Task.input
- Returns:
a list of
Targetobjects which are specified as outputs of all required Tasks.
Class Register#
Class Task#
Class WrapperTask#
- class WrapperTask(*args, **kwargs)[source]#
Bases:
TaskUse for tasks that only wrap other tasks and that by definition are done if all their requirements exist.
- complete() bool[source]#
If the task has any outputs, return
Trueif all outputs exist. Otherwise, returnFalse.However, you may freely override this method with custom logic.
- output() Any[source]#
The output that this Task produces.
The output of the Task determines if the Task needs to be run–the task is considered finished iff the outputs all exist. Subclasses should override this method to return a single
Targetor a list ofTargetinstances.- Implementation note
If running multiple workers, the output must be a resource that is accessible by all workers, such as a DFS or database. Otherwise, workers might compute the same output since they don’t see the work done by other workers.
See Task.output