Task¶
A Task defines the implementation of a given operation, the inputs required and the scheduling metadata. Usually, a Task is not created directly, but rather through the use of the @task decorator.
Example¶
A task function is decorated vya the @task decorator and must accept the TaskRun object as its first and only argument.
from fluid.scheduler import task, TaskRun
@task
def hello(ctx: TaskRun) -> None:
print("Hello, world!")
fluid.scheduler.task
¶
task(executor: TaskExecutor) -> Task
task(
*,
name: str | None = None,
schedule: Scheduler | None = None,
short_description: str | None = None,
description: str | None = None,
randomize: RandomizeType | None = None,
max_concurrency: int = 0,
priority: TaskPriority = medium,
cpu_bound: bool = False,
k8s_config: K8sConfig | None = None,
timeout_seconds: int = 60
) -> TaskConstructor
Decorator to create a Task
This decorator can be used in two ways:
- As a simple decorator of the executor function
- As a function with keyword arguments
Source code in fluid/scheduler/models.py
fluid.scheduler.Task
¶
Bases: NamedTuple
, Generic[TP]
A Task executes any time it is invoked
short_description
class-attribute
instance-attribute
¶
Short task description - one line
description
class-attribute
instance-attribute
¶
Task description - obtained from the executor docstring if not provided
schedule
class-attribute
instance-attribute
¶
Task schedule - None means the task is not scheduled
randomize
class-attribute
instance-attribute
¶
Randomize function for task schedule
max_concurrency
class-attribute
instance-attribute
¶
how many tasks can run in each consumer concurrently - 0 means no limit
timeout_seconds
class-attribute
instance-attribute
¶
Task timeout in seconds - how long the task can run before being aborted
info
¶
Source code in fluid/scheduler/models.py
fluid.scheduler.TaskPriority
¶
fluid.scheduler.TaskState
¶
Bases: StrEnum