tiledb.cloud.taskgraphs.executor.Node

class tiledb.cloud.taskgraphs.executor.Node(uid: UUID, owner: _ET, name: str | None)

Bases: FutureLike[_T], Generic[_ET, _T]

An abstract type specifying the operations on a Node of a task graph.

Executor implementations will return instances of implementations of these Nodes when executing a task graph. If a caller uses only the methods here when manipulating task graph nodes, the actions they take will work (to the extent that they are supported) no matter the specifics of the executor itself (client-side, server-side, etc.).

The external-facing API matches that of futures.Future, with some added niceties (like status), and without the internal methods that are only “meant for use in unit tests and Executor implementations”: set_running_or_notify_cancel, set_result, and set_exception.

The generic types on this (which are really only of concern to Executor implementors) represent the Executor type and the type the Node yields:

Node[MyExecutor, int]
# A Node subtype that is executed by a MyExecutor
# and whose .result() is an int.
__init__(uid: UUID, owner: _ET, name: str | None)

Methods

__init__(uid, owner, name)

add_done_callback(fn)

Adds a callback that will be called when this Node completes.

cancel()

If possible, cancels execution of this node.

cancelled()

Returns True if the Node was cancelled.

done()

Returns True if this Node has completed or been cancelled.

exception([timeout])

If this node failed, the exception that was raised.

result([timeout])

The value resulting from executing this node.

retry()

Attempts to submit this node for retry, if possible.

running()

Returns True if the Node is currently executing.

task_id([timeout])

The task ID that was returned from the server, if applicable.

wait([timeout])

Waits for the given amount of time for this Node to complete.

Attributes

display_name

The name for this node that should show up in UIs.

fallback_name

A fallback name for this node if unnamed.

status

The current lifecycle state of this Node.

id

The client-generated UUID of this node.

owner

The executor which this node belongs to.

name

The name of the node, if present.

add_done_callback(fn: Callable[[_NSelf], None]) None

Adds a callback that will be called when this Node completes.

While the current behavior is similar to the way add_done_callback on a regular Future works, we don’t guarantee that it will remain the same (e.g. will it be called immediately, on what thread). A callback may be called back multiple times if the Node completes multiple times.

abstract cancel() bool

If possible, cancels execution of this node.

Returns True if cancellation succeeded, False if we could not cancel.

cancelled() bool

Returns True if the Node was cancelled.

property display_name: str

The name for this node that should show up in UIs.

done() bool

Returns True if this Node has completed or been cancelled.

abstract exception(timeout: float | None = None) Exception | None

If this node failed, the exception that was raised.

If the Node succeeded, returns None. If the Node was cancelled, a futures.CancelledError will be raised rather than returned.

property fallback_name: str

A fallback name for this node if unnamed.

id

The client-generated UUID of this node.

name

The name of the node, if present.

owner

The executor which this node belongs to.

abstract result(timeout: float | None = None) _T

The value resulting from executing this node.

Returns the result if present, or raises an exception if execution raised an exception.

retry() bool

Attempts to submit this node for retry, if possible.

running() bool

Returns True if the Node is currently executing.

property status: Status

The current lifecycle state of this Node.

abstract task_id(timeout: float | None = None) UUID | None

The task ID that was returned from the server, if applicable.

If this was executed on the server side, this should return the UUID of the actual execution of this task. If it was purely client-side, or the server did not return a UUID, this should return None.

abstract wait(timeout: float | None = None) None

Waits for the given amount of time for this Node to complete.