task
— Task specification
This module collects a few task classes that can be used with the
scheduler
and depgraph
modules.
This module defines a dummy Task
class that may be used as a base
class and extended.
The Task.do
method takes two arguments:
env is an environment for task execution. The idea of the environment is that tasks may use it to store information about their execution. For instance, a task may create a file and store its location in the environment, so that later tasks may be able to retrieve it. The type of env is really immaterial, but it is probably natural to use a key-value mapping of some kind. Note, however, that most of the tasks defined in the
task
module hierarchy expect env to be anEnv
object.config is a
Config
object describing the configuration for the current run. Tasks may look up global configuration values here.
The Task
class models two types of inter-task dependencies. Hard
dependencies represent dependencies that are crucial for the execution of the
task at hand. If task A has a hard dependency on task B, it means that A
cannot run unless B has successfully completed. If B fails, then it makes
no sense to run A. On the other hand, if task A has a soft dependency
on task B, it means that A will not start before B’s termination, but it
makes sense to run A even if B fails.
- class valjean.cosette.task.TaskStatus(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Enumeration for the task status. The possible values are:
WAITING
(the task is waiting to be scheduled)PENDING
(the task is under execution)DONE
(the task was executed and it succeeded)FAILED
(the task was executed and it failed)SKIPPED
(the task was skipped by the scheduler; this may happen, for instance, if the one of the task dependencies was not successful)
- __format__(format_spec, /)
Default object formatter.
- __new__(value)
- class valjean.cosette.task.Task(name, *, deps=None, soft_deps=None)[source]
Base class for other task classes.
- __init__(name, *, deps=None, soft_deps=None)[source]
Initialize the task.
- Parameters:
name (str) – The name of the task. Task names must be unique!
deps (list(Task) or None) – The list of (hard) dependencies for this task. It must be either None (i.e. no dependencies) or list of
Task
objects.soft_deps (list(Task) or None) – The list of soft dependencies for this task. It must be either None (i.e. no dependencies) or list of
Task
objects.
- class valjean.cosette.task.DelayTask(name, delay=1.0)[source]
Task that waits for the specified number of seconds. This task is useful to test scheduling algorithms under different load conditions.