Task Run¶
It can be imported from fluid.scheduler:
fluid.scheduler.TaskRun
pydantic-model
¶
Bases: BaseModel, Generic[TP, TD]
A TaskRun contains all the data generated by a Task run
This model is never initialized directly, it is created by the TaskManager
Fields:
-
id(str) -
task(Task) -
priority(TaskPriority) -
params(TP) -
state(TaskState) -
task_manager(TaskManager) -
queued(datetime | None) -
start(datetime | None) -
end(datetime | None) -
execute_after(datetime | None) -
rate_limit_attempt(int) -
retry_attempt(int) -
from_run_id(str) -
root_run_id(str)
execute_after
pydantic-field
¶
Do not execute before this UTC timestamp. Set by retry logic.
rate_limit_attempt
pydantic-field
¶
Number of rate-limit retries already consumed.
from_run_id
pydantic-field
¶
ID of the task run that queued this one, empty when the run was not queued from another task run.
root_run_id
pydantic-field
¶
ID of the first task run in the chain, shared by every run queued from it, directly or indirectly. Empty for a run that starts a chain.
deps
property
¶
Dependencies of the TaskManager running this task.
Annotate the second type parameter to type them, for example
TaskRun[MyParams, MyDeps]. It defaults to Any, therefore
TaskRun and TaskRun[MyParams] keep working unchanged.
abort
¶
set_state
¶
Set the state of the task run, with proper handling of timestamps and state transitions.
This method is called by the task consumer and should not be called directly by the task executor.
Source code in fluid/scheduler/models.py
queue
async
¶
Queue another task from within this task run.
The new run records this run in from_run_id and inherits its root_run_id, so a chain of tasks queued this way can be traced back to the run that started it.
This returns as soon as the run is on the queue, it does not wait for it to execute.
| PARAMETER | DESCRIPTION |
|---|---|
task
|
The task or task name, if a task name it must be registered with the task manager.
TYPE:
|
run_id
|
Unique ID for the task run. If not provided a new UUID is generated.
TYPE:
|
priority
|
Override the default task priority if provided
TYPE:
|
**params
|
The optional parameters for the task run. They must match the task params model
TYPE:
|
Source code in fluid/scheduler/models.py
lock
¶
Get a lock for this task run
Source code in fluid/scheduler/models.py
queue_dump_json
¶
Serialize the task run for the task queue
Params are dumped with secret values revealed so they survive the round-trip through the queue - all other dumps keep secrets masked.