Marks¶
Built-in marks are exposed dynamically via pytask.mark, so their API is documented
manually here.
Built-In Marks¶
pytask.mark.persist¶
@pytask.mark.persist
Prevent execution of a task when all neighboring nodes exist, even if something changed. See making tasks persist.
pytask.mark.skip¶
@pytask.mark.skip
Skip a task and all downstream tasks. See skipping tasks.
pytask.mark.skipif¶
@pytask.mark.skipif(condition: bool, *, reason: str)
Skip a task and all downstream tasks when condition is True.
See skipping tasks.
pytask.mark.try_first¶
@pytask.mark.try_first
Prefer running a task as early as possible in the DAG. See how to influence build order.
pytask.mark.try_last¶
@pytask.mark.try_last
Prefer running a task as late as possible in the DAG. See how to influence build order.
Mark Classes¶
pytask.Mark
dataclass
¶
pytask.mark = MarkGenerator()
module-attribute
¶
The singleton instance of the pytask.MarkGenerator.
pytask.MarkDecorator
dataclass
¶
A decorator for applying a mark on task function.
Decorators are created with pytask.mark.
mark1 = pytask.mark.NAME # Simple MarkDecorator
mark2 = pytask.mark.NAME(name1=value) # Parametrized MarkDecorator
and can then be applied as decorators to task functions
@mark2
def task_function():
pass
When a pytask.MarkDecorator is called it does the following:
- If called with a single function as its only positional argument and no
additional keyword arguments, it attaches the mark to the function, containing
all the arguments already stored internally in the
pytask.MarkDecorator. - When called in any other case, it returns a new
pytask.MarkDecoratorinstance with the originalpytask.MarkDecorator's content updated with the arguments passed to this call.
Notes
The rules above prevent decorators from storing only a single function or class
reference as their positional argument with no additional keyword or positional
arguments. You can work around this by using MarkDecorator.with_args().
args
property
¶
Alias for mark.args.
kwargs
property
¶
Alias for mark.kwargs.
name
property
¶
Alias for mark.name.
with_args(*args, **kwargs)
¶
Return a MarkDecorator with extra arguments added.
Unlike calling the pytask.MarkDecorator,
pytask.MarkDecorator.with_args can be used even if the sole argument is a
callable.
pytask.MarkGenerator
¶
Factory for pytask.MarkDecorator objects.
Example
import pytask
@pytask.mark.skip
def task_function() -> None:
pass
This applies a skip pytask.mark to task_function.
config = None
class-attribute
instance-attribute
¶
Optional[Dict[str, Any]]: The configuration.
Mark Utilities¶
pytask.get_all_marks(obj_or_task)
¶
Get all marks from a callable or task.
pytask.get_marks(obj_or_task, marker_name)
¶
Get marks from callable or task.
pytask.has_mark(obj_or_task, marker_name)
¶
Test if callable or task has a certain mark.
pytask.remove_marks(obj_or_task, marker_name)
¶
Remove marks from callable or task.
pytask.set_marks(obj_or_task, marks)
¶
Set marks on a callable or task.