dragon.workflows.batch.batch.Task
- class Task[source]
Bases:
object- __init__(task_core: TaskCore, batch: Batch, reads: list | None = None, writes: list | None = None, compiled: bool = False) None [source]
Initializes a new task.
- Parameters:
task_core (TaskCore) – The core parts of the task, allowing us to send leaner objects to the managers.
batch (Batch) – The batch to which this task belongs.
reads (Optional[list ]) – A list of
Readobjects created by callingBatch.read.writes (Optional[list ]) – A list of
Writeobjects created by callingBatch.write.compiled (bool ) – A flag indicating if this task is compiled.
- Returns:
Returns None.
- Return type:
None
Methods
__init__(task_core, batch[, reads, writes, ...])Initializes a new task.
dump_dag(file_name)Dump a PNG image of the dependency DAG associated with a compiled program.
get()Performs a batch fence to guarantee the completion of all tasks batched in the background, and then gets the result for this task.
read(obj, *channels)Indicates READ accesses of a specified set of channels on a communication object, and associates these accesses with this task.
run([timeout])Starts a task and waits for it to complete.
start()Start this task by sending its work chunks to the managers.
wait([timeout])Wait for this Task to complete.
write(obj, *channels)Indicates WRITE accesses of a specified set of channels on a communication object, and associates these accesses with this task.
Attributes
Handle for the task's result.
Handle for the task's stderr.
Handle for the task's stdout.
Provides the unique ID for this task.
- __init__(task_core: TaskCore, batch: Batch, reads: list | None = None, writes: list | None = None, compiled: bool = False) None [source]
Initializes a new task.
- Parameters:
task_core (TaskCore) – The core parts of the task, allowing us to send leaner objects to the managers.
batch (Batch) – The batch to which this task belongs.
reads (Optional[list ]) – A list of
Readobjects created by callingBatch.read.writes (Optional[list ]) – A list of
Writeobjects created by callingBatch.write.compiled (bool ) – A flag indicating if this task is compiled.
- Returns:
Returns None.
- Return type:
None
- read(obj, *channels) None [source]
Indicates READ accesses of a specified set of channels on a communication object, and associates these accesses with this task. Associating READ accesses with a task allows the Batch service to infer dependencies between subtasks in a compiled task, but has no effect on individual (non-compiled) tasks.
- Parameters:
obj – The communication object being accessed.
*channels –
A tuple of channels on the communcation object that will be read from.
- Returns:
Returns None.
- Return type:
None
- write(obj, *channels) None [source]
Indicates WRITE accesses of a specified set of channels on a communication object, and associates these accesses with this task. Associating WRITE accesses with a task allows the Batch service to infer dependencies between subtasks in a compiled task, but has no effect on individual (non-compiled) tasks.
- Parameters:
obj – The communication object being accessed.
*channels –
A tuple of channels on the communcation object that will be written to.
- Returns:
Returns None.
- Return type:
None
- start() None [source]
Start this task by sending its work chunks to the managers. Currently, a task can only be started once and cannot be restarted after it completes. If a task is a subtask of a compiled task, then
startmust be called for the compiled task and not the subtask.- Returns:
Returns None.
- Return type:
None
- wait(timeout: float = 1000000000.0) None [source]
Wait for this Task to complete. This can only be called after
starthas been called. This function does not return the task’s result; instead, usegetfor that purpose.- Parameters:
timeout – The timeout for waiting. Defaults to 1e9.
- Raises:
TimeoutError – If the specified timeout is exceeded.
- Returns:
Returns None.
- Return type:
None
- run(timeout: float = 1000000000.0) Any [source]
Starts a task and waits for it to complete. Currently, a task can only be started once and cannot be restarted after it completes.
- Parameters:
timeout (float ) – The timeout for waiting. Defaults to 1e9.
- Raises:
TimeoutError – If the specified timeout is exceeded.
Exception – If this Task raised an exception while running. The exception raised by the task is propagated back to the host that started the task so it can be raised here.
- Returns:
Returns the result of the operation being waited on.
- Return type:
Any
- get()[source]
Performs a batch fence to guarantee the completion of all tasks batched in the background, and then gets the result for this task.
- Returns:
Returns the result of this task.
- Return type:
Any
- property uid
Provides the unique ID for this task.
- property result
Handle for the task’s result. This should not be accessed until the task is started.
resultonly applies to individual tasks and compiled tasks with a single subtask. The handle has type AsyncDict.
- property stdout
Handle for the task’s stdout. This should not be accessed until the task is started.
stdoutonly applies to individual tasks and compiled tasks with a single subtask. The handle has type AsyncDict.
- property stderr
Handle for the task’s stderr. This should not be accessed until the task is started.
stderronly applies to individual tasks and compiled tasks with a single subtask. The handle has type AsyncDict.