Undocumented
| Class | |
Information about the running workflow. |
| Class | |
Information about the parent workflow. |
| Class | |
Information about the root workflow. |
| Class | |
Information about a workflow update. |
| Function | current |
Info for the current update if any. |
| Function | deprecate |
Mark a patch as deprecated. |
| Function | extern |
External functions available in the workflow sandbox. |
| Function | get |
Get the current details of the workflow which may appear in the UI/CLI. Unlike static details set at start, this value can be updated throughout the life of the workflow and is independent of the static details... |
| Function | get |
Get the result of the last run of the workflow. This will be None if there was no previous completion or the result was None. has_last_completion_result() can be used to differentiate. |
| Function | get |
Get the last failure of the workflow if it has run previously. |
| Function | has |
Gets whether there is a last completion result of the workflow. |
| Function | in |
Whether the code is currently running in a workflow. |
| Function | info |
Current workflow's info. |
| Function | instance |
Current workflow's instance. |
| Function | is |
Checks if the given exception is a workflow failure in the current workflow. |
| Function | memo |
Current workflow's memo values, converted without type hints. |
| Function | memo |
Memo value for the given key, optional default, and optional type hint. |
| Function | metric |
Get the metric meter for the current workflow. |
| Function | new |
Create a Random instance that automatically reseeds when the workflow seed changes. |
| Function | now |
Current time from the workflow perspective. |
| Function | patched |
Patch a workflow. |
| Function | payload |
Get the payload converter for the current workflow. |
| Function | random |
Get a deterministic pseudo-random number generator. |
| Function | random |
Get the current random seed value from core. |
| Function | register |
Register a callback to be notified when the random seed changes. |
| Function | set |
Set the current details of the workflow which may appear in the UI/CLI. Unlike static details set at start, this value can be updated throughout the life of the workflow and is independent of the static details... |
| Async Function | sleep |
Sleep for the given duration. |
| Function | time |
Current seconds since the epoch from the workflow perspective. |
| Function | time |
Current nanoseconds since the epoch from the workflow perspective. |
| Function | upsert |
Adds, modifies, and/or removes memos, with upsert semantics. |
| Function | upsert |
Upsert search attributes for this workflow. |
| Function | uuid4 |
Get a new, determinism-safe v4 UUID based on random. |
| Async Function | wait |
Wait on a callback to become true. |
Info for the current update if any.
This is powered by contextvars so it is only valid within the
update handler and coroutines/tasks it has started.
| Returns | |
UpdateInfo | None |
|
Mark a patch as deprecated.
This marks a workflow that had patched in a previous version of
the code as no longer applicable because all workflows that use the old code
path are done and will never be queried again. Therefore the old code path
is removed as well.
| Parameters | |
id:str | The identifier originally used with patched. |
Get the current details of the workflow which may appear in the UI/CLI. Unlike static details set at start, this value can be updated throughout the life of the workflow and is independent of the static details. This can be in Temporal markdown format and can span multiple lines.
Get the result of the last run of the workflow. This will be None if there was no previous completion or the result was None. has_last_completion_result() can be used to differentiate.
Checks if the given exception is a workflow failure in the current workflow.
| Returns | |
bool | True if the given exception is a workflow failure in the current workflow. |
Current workflow's memo values, converted without type hints.
Since type hints are not used, the default converted values will come back.
For example, if the memo was originally created with a dataclass, the value
will be a dict. To convert using proper type hints, use
memo_value.
| Returns | |
Mapping[ | Mapping of all memo keys and they values without type hints. |
Memo value for the given key, optional default, and optional type hint.
| Parameters | |
key:str | Key to get memo value for. |
default:Any | Default to use if key is not present. If unset, a
KeyError is raised when the key does not exist. |
typetype | None | Type hint to use when converting. |
| Returns | |
Any | Memo value, converted with the type hint if present. |
| Raises | |
KeyError | Key not present and default not set. |
Get the metric meter for the current workflow.
This meter is replay safe which means that metrics will not be recorded during replay.
| Returns | |
temporalio.common.MetricMeter | Current metric meter for this workflow for recording metrics. |
Create a Random instance that automatically reseeds when the workflow seed changes.
This creates a new Random instance that is initially seeded with the current workflow seed, and automatically registers a callback to reseed itself whenever the workflow receives a new seed from core.
| Returns | |
Random | A Random instance that stays synchronized with the workflow's randomness. |
Current time from the workflow perspective.
This is the workflow equivalent of datetime.now with the
timezone.utc parameter.
| Returns | |
datetime | UTC datetime for the current workflow time. The datetime does have UTC set as the time zone. |
Patch a workflow.
When called, this will only return true if code should take the newer path which means this is either not replaying or is replaying and has seen this patch before.
Use deprecate_patch when all workflows are done and will never be
queried again. The old code path can be used at that time too.
| Parameters | |
id:str | The identifier for this patch. This identifier may be used repeatedly in the same workflow to represent the same patch |
| Returns | |
bool | True if this should take the newer path, false if it should take the older path. |
Get the payload converter for the current workflow.
The returned converter has temporalio.converter.WorkflowSerializationContext set.
This is often used for dynamic workflows/signals/queries to convert
payloads.
Get a deterministic pseudo-random number generator.
Note, this random number generator is not cryptographically safe and should not be used for security purposes.
| Returns | |
Random | The deterministically-seeded pseudo-random number generator. |
Get the current random seed value from core.
This returns the seed value currently being used by the workflow's deterministic random number generator.
| Returns | |
int | The current random seed as an integer. |
Register a callback to be notified when the random seed changes.
The callback will be invoked whenever the workflow receives a new random seed from the core. This is useful for maintaining external random number generators that need to stay in sync with the workflow's randomness.
| Parameters | |
callback:Callable[ | Function to be called with the new seed value when it changes. |
Set the current details of the workflow which may appear in the UI/CLI. Unlike static details set at start, this value can be updated throughout the life of the workflow and is independent of the static details. This can be in Temporal markdown format and can span multiple lines.
Current nanoseconds since the epoch from the workflow perspective.
This is the workflow equivalent of time.time_ns.
| Returns | |
int | Nanoseconds since the epoch |
Adds, modifies, and/or removes memos, with upsert semantics.
Every memo that has a matching key has its value replaced with the one specified in updates. If the value is set to None, the memo is removed instead. For every key with no existing memo, a new memo is added with specified value (unless the value is None). Memos with keys not included in updates remain unchanged.
temporalio.common.SearchAttributes | Sequence[ temporalio.common.SearchAttributeUpdate]):
(source)
¶
Upsert search attributes for this workflow.
| Parameters | |
attributes:temporalio.common.SearchAttributes | Sequence[ | The attributes to set. This should be a sequence of updates (i.e. values created via value_set and value_unset calls on search attribute keys). The dictionary form of attributes is DEPRECATED and if used, result in invalid key types on the typed_search_attributes property in the info. |
Callable[ [], bool], *, timeout: timedelta | float | None = None, timeout_summary: str | None = None):
(source)
¶
Wait on a callback to become true.
This function returns when the callback returns true (invoked each loop iteration) or the timeout has been reached.
| Parameters | |
fn:Callable[ | Non-async callback that accepts no parameters and returns a boolean. |
timeout:timedelta | float | None | Optional number of seconds to wait until throwing
asyncio.TimeoutError. |
timeoutstr | None | Optional simple string identifying the timer (created if timeout is present) that may be visible in UI/CLI. While it can be normal text, it is best to treat as a timer ID. |