law.parser#

Helpers to extract useful information from the luigi command line parser.

root_task_cls(task: Task | None = None) Type[Task] | None[source]#

Returns the class of the task that was triggered on the command line. The returned class is cached. When task is defined and no root task class was cached yet, this methods acts as a setter.

root_task(task: Task | None = None) Task | None[source]#

Returns the instance of the task that was triggered on the command line. The returned instance is cached. When task is define and no root task was cached yet, this methods acts as a setter.

full_parser() CmdlineParser | None[source]#

Returns the full ArgumentParser used by the luigi CmdlineParser. The returned instance is cached.

root_task_parser() ArgumentParser | None[source]#

Returns a new ArgumentParser instance that only contains parameter actions of the root task. The returned instance is cached.

global_cmdline_args(exclude: Sequence[str] | None = None) dict[str, str] | None[source]#

Returns a dictionary with keys and string values of command line arguments that do not belong to the root task. For bool parameters, such as --local-scheduler, "True" is assumed if they are used as flags, i.e., without a parameter value. The returned dict is cached. exclude can be a list of argument names (with or without the leading "--") to be removed. Example:

global_cmdline_args()
# -> {"--local-scheduler": "True", "--workers": "4"}

global_cmdline_args(exclude=["workers"])
# -> {"--local-scheduler": "True"}
global_cmdline_values() dict[str, Any] | None[source]#

Returns a dictionary of global command line arguments (computed with global_cmdline_args()) to their current values. The returnd dictionary is cached. Example:

global_cmdline_values()
# -> {"core_local_scheduler": True}