module documentation

Undocumented

Class HandlerUnfinishedPolicy Actions taken if a workflow terminates with running handlers.
Class UpdateMethodMultiParam Decorated workflow update functions implement this.
Exception UnfinishedSignalHandlersWarning The workflow exited before all signal handlers had finished executing.
Exception UnfinishedUpdateHandlersWarning The workflow exited before all update handlers had finished executing.
Function query Decorator for a workflow query method.
Function signal Decorator for a workflow signal method.
Function update Decorator for a workflow update handler method.
def query(fn: CallableType) -> CallableType:
def query(*, name: str, description: str | None = None) -> Callable[[CallableType], CallableType]:
def query(*, dynamic: Literal[True], description: str | None = None) -> Callable[[CallableType], CallableType]:
def query(*, description: str) -> Callable[[CallableType], CallableType]:
(source)

Decorator for a workflow query method.

This is used on any non-async method that expects to handle a query. If a function overrides one with this decorator, it too must be decorated.

Query methods can only have positional parameters. Best practice for non-dynamic query methods is to only take a single object/dataclass argument that can accept more fields later if needed. The return value is the resulting query value. Query methods must not mutate any workflow state.

Parameters
fn:CallableType | NoneThe function to decorate.
name:str | NoneQuery name. Defaults to method __name__. Cannot be present when dynamic is present.
dynamic:bool | NoneIf true, this handles all queries not otherwise handled. The parameters of the method should be self, a string name, and a Sequence[RawValue]. An older form of this accepted vararg parameters which will now warn. Cannot be present when name is present.
description:str | NoneA short description of the query that may appear in the UI/CLI.
def signal(fn: CallableSyncOrAsyncReturnNoneType) -> CallableSyncOrAsyncReturnNoneType:
def signal(*, unfinished_policy: HandlerUnfinishedPolicy = HandlerUnfinishedPolicy.WARN_AND_ABANDON, description: str | None = None) -> Callable[[CallableSyncOrAsyncReturnNoneType], CallableSyncOrAsyncReturnNoneType]:
def signal(*, name: str, unfinished_policy: HandlerUnfinishedPolicy = HandlerUnfinishedPolicy.WARN_AND_ABANDON, description: str | None = None) -> Callable[[CallableSyncOrAsyncReturnNoneType], CallableSyncOrAsyncReturnNoneType]:
def signal(*, dynamic: Literal[True], unfinished_policy: HandlerUnfinishedPolicy = HandlerUnfinishedPolicy.WARN_AND_ABANDON, description: str | None = None) -> Callable[[CallableSyncOrAsyncReturnNoneType], CallableSyncOrAsyncReturnNoneType]:
(source)

Decorator for a workflow signal method.

This is used on any async or non-async method that you wish to be called upon receiving a signal. If a function overrides one with this decorator, it too must be decorated.

Signal methods can only have positional parameters. Best practice for non-dynamic signal methods is to only take a single object/dataclass argument that can accept more fields later if needed. Return values from signal methods are ignored.

Parameters
fn:CallableSyncOrAsyncReturnNoneType | NoneThe function to decorate.
name:str | NoneSignal name. Defaults to method __name__. Cannot be present when dynamic is present.
dynamic:bool | NoneIf true, this handles all signals not otherwise handled. The parameters of the method must be self, a string name, and a *args positional varargs. Cannot be present when name is present.
unfinished_policy:HandlerUnfinishedPolicyActions taken if a workflow terminates with a running instance of this handler.
description:str | NoneA short description of the signal that may appear in the UI/CLI.
Returns
Callable[[CallableSyncOrAsyncReturnNoneType], CallableSyncOrAsyncReturnNoneType] | CallableSyncOrAsyncReturnNoneTypeUndocumented
def update(fn: Callable[MultiParamSpec, Awaitable[ReturnType]]) -> UpdateMethodMultiParam[MultiParamSpec, ReturnType]:
def update(fn: Callable[MultiParamSpec, ReturnType]) -> UpdateMethodMultiParam[MultiParamSpec, ReturnType]:
def update(*, unfinished_policy: HandlerUnfinishedPolicy = HandlerUnfinishedPolicy.WARN_AND_ABANDON, description: str | None = None) -> Callable[[Callable[MultiParamSpec, ReturnType]], UpdateMethodMultiParam[MultiParamSpec, ReturnType]]:
def update(*, name: str, unfinished_policy: HandlerUnfinishedPolicy = HandlerUnfinishedPolicy.WARN_AND_ABANDON, description: str | None = None) -> Callable[[Callable[MultiParamSpec, ReturnType]], UpdateMethodMultiParam[MultiParamSpec, ReturnType]]:
def update(*, dynamic: Literal[True], unfinished_policy: HandlerUnfinishedPolicy = HandlerUnfinishedPolicy.WARN_AND_ABANDON, description: str | None = None) -> Callable[[Callable[MultiParamSpec, ReturnType]], UpdateMethodMultiParam[MultiParamSpec, ReturnType]]:
(source)

Decorator for a workflow update handler method.

This is used on any async or non-async method that you wish to be called upon receiving an update. If a function overrides one with this decorator, it too must be decorated.

You may also optionally define a validator method that will be called before this handler you have applied this decorator to. You can specify the validator with @update_handler_function_name.validator.

Update methods can only have positional parameters. Best practice for non-dynamic update methods is to only take a single object/dataclass argument that can accept more fields later if needed. The handler may return a serializable value which will be sent back to the caller of the update.

Parameters
fn:CallableSyncOrAsyncType | NoneThe function to decorate.
name:str | NoneUpdate name. Defaults to method __name__. Cannot be present when dynamic is present.
dynamic:bool | NoneIf true, this handles all updates not otherwise handled. The parameters of the method must be self, a string name, and a *args positional varargs. Cannot be present when name is present.
unfinished_policy:HandlerUnfinishedPolicyActions taken if a workflow terminates with a running instance of this handler.
description:str | NoneA short description of the update that may appear in the UI/CLI.
Returns
UpdateMethodMultiParam[MultiParamSpec, ReturnType] | Callable[[Callable[MultiParamSpec, ReturnType]], UpdateMethodMultiParam[MultiParamSpec, ReturnType]]Undocumented