wove¶
Most application code should import from wove. The package-level API names the stable entrypoints for declaring a weave, configuring execution environments, handling public exceptions, and using the helper functions that are meant to sit inside task code.
Primary Entrypoints¶
weave: the context manager factory used aswith weave() as w:.Weave: base class for reusable and inheritable workflow definitions.config: process-wide runtime configuration function.merge: runs external callables from inside a weave task, with the same execution options as@w.do(...).
Public Runtime Types¶
WoveResult: result object returned by completed weaves.EnvironmentExecutor: executor interface for custom execution environments.BackendAdapterEnvironmentExecutor: executor wrapper used by built-in backend adapters.HttpEnvironmentExecutor: direct HTTP/HTTPS network executor.GrpcEnvironmentExecutor: generic unary gRPC network executor.WebSocketEnvironmentExecutor: bidirectional WebSocket network executor.NetworkExecutorSecurity: request signing and verification helper for network executors.BackendAdapter: base interface for backend-specific adapters.
Public Exceptions¶
MissingDispatchFeatureError: dispatch-only feature was used withoutwove[dispatch].DeliveryTimeoutError: backend delivery or heartbeat timeout.DeliveryOrphanedError: pending backend work became orphaned during shutdown handling.
Helpers¶
Import common data-shaping helpers from the package root when glue code would otherwise distract from the task graph: sync_to_async, flatten, fold, batch, undict, redict, and denone.
API Details¶
Wove.
Inline task orchestration for Python code that needs concurrent work without restructuring the surrounding function around an event loop. Wove keeps the workflow in ordinary Python: define tasks where the result is needed, let dependencies come from function signatures, and route selected work through named environments when it belongs in another process or service.
- class wove.BackendAdapterEnvironmentExecutor(name, adapter_class=None, required_modules=None)[source]¶
Bases:
EnvironmentExecutorExecutor that submits Wove task payloads to a backend adapter and receives worker frames over a callback server.
- Parameters:
name (str)
adapter_class (Type[BackendAdapter] | None)
- exception wove.DeliveryOrphanedError[source]¶
Bases:
RuntimeErrorRaised when a backend run becomes orphaned during runtime shutdown/failure handling.
- exception wove.DeliveryTimeoutError[source]¶
Bases:
RuntimeErrorRaised when backend delivery does not complete within configured delivery_timeout.
- class wove.EnvironmentExecutor[source]¶
Bases:
ABCCGI-like stream transport contract for environment executors.
- class wove.GrpcEnvironmentExecutor[source]¶
Bases:
EnvironmentExecutorNetwork executor that sends Wove frames through a generic gRPC method.
- class wove.HttpEnvironmentExecutor(*, require_https=False)[source]¶
Bases:
EnvironmentExecutorNetwork executor that sends Wove frames to a worker service over HTTP or HTTPS.
- Parameters:
require_https (bool)
- exception wove.MissingDispatchFeatureError(reason)[source]¶
Bases:
RuntimeErrorRaised when a dispatch feature is used without optional dispatch dependencies.
- Parameters:
reason (str)
- Return type:
None
- class wove.NetworkExecutorSecurity(*, mode='none', secret=None, key='default', token=None, clock_skew_seconds=300.0, remember_nonces=True)[source]¶
Bases:
objectAuthentication helper for Wove network executors.
- Parameters:
- classmethod from_config(config)[source]¶
Build network executor security from an executor
securityconfig value.- Parameters:
config (Any)
- Return type:
- headers_for(*, transport, target, body)[source]¶
Return HTTP/WebSocket headers for one outbound network executor request.
- metadata_for(*, transport, target, body)[source]¶
Return lowercase gRPC metadata pairs for one outbound network executor request.
- class wove.Weave[source]¶
Bases:
objectA base class for creating inheritable, reusable workflows.
Tasks are defined as methods using the @Weave.do decorator. These workflows can then be passed to the weave context manager and customized inline.
- static do(arg=None, *, retries=None, timeout=None, workers=None, limit_per_minute=None, environment=None, delivery_timeout=None, delivery_idempotency_key=None, delivery_cancel_mode=None, delivery_heartbeat_seconds=None, delivery_max_in_flight=None, delivery_orphan_policy=None)[source]¶
A decorator for defining a task within a Weave class.
This is the class-based equivalent of the @w.do decorator used inside a weave block. It accepts the same parameters.
- Parameters:
retries (int | None)
timeout (float | None)
workers (int | None)
limit_per_minute (int | None)
environment (str | None)
delivery_timeout (float | None)
delivery_idempotency_key (object | None)
delivery_cancel_mode (str | None)
delivery_heartbeat_seconds (float | None)
delivery_max_in_flight (int | None)
delivery_orphan_policy (str | None)
- Return type:
- class wove.WebSocketEnvironmentExecutor[source]¶
Bases:
EnvironmentExecutorNetwork executor that exchanges Wove frames with a worker service over WebSocket.
- class wove.WoveResult(error_mode='raise')[source]¶
Bases:
objectA container for the results of a weave block. Supports dictionary-style access by task name, unpacking in definition order, and a .final shortcut to the last-defined task’s result.
- Parameters:
error_mode (str)
- wove.config(*, config_file=None, default_environment=None, environments=None, max_workers=None, background=None, fork=None, retries=None, timeout=None, workers=None, limit_per_minute=None, max_pending=None, error_mode=None, delivery_timeout=None, delivery_idempotency_key=None, delivery_cancel_mode=None, delivery_heartbeat_seconds=None, delivery_max_in_flight=None, delivery_orphan_policy=None)[source]¶
Configure process-wide Wove runtime behavior.
Calling wove.config() with no args attempts to autoload wove_config.py from the current working directory or one of its parents.
- Parameters:
config_file (str | None)
default_environment (str | None)
max_workers (int | None)
background (bool | None)
fork (bool | None)
retries (int | None)
timeout (float | None)
workers (int | None)
limit_per_minute (int | None)
max_pending (int | None)
error_mode (str | None)
delivery_timeout (float | None)
delivery_idempotency_key (Any | None)
delivery_cancel_mode (str | None)
delivery_heartbeat_seconds (float | None)
delivery_max_in_flight (int | None)
delivery_orphan_policy (str | None)
- Return type:
- wove.merge(callable, iterable=None, *, retries=None, timeout=None, workers=None, limit_per_minute=None, environment=None, delivery_timeout=None, delivery_idempotency_key=None, delivery_cancel_mode=None, delivery_heartbeat_seconds=None, delivery_max_in_flight=None, delivery_orphan_policy=None)[source]¶
Execute a callable from within a running Wove task.
Parameters¶
- callable
The async or sync callable to execute.
- iterable
Optional iterable. When provided,
callableis executed for each item (similar to@w.do(iterable)behavior).- retries, timeout, workers, limit_per_minute, environment, delivery_*
The same execution options accepted by
@w.do.
Returns¶
- Any
The callable result, or a list of results when
iterableis provided.
Raises¶
- RuntimeError
If called outside of an active
weavecontext.
- Parameters:
retries (int | None)
timeout (float | None)
workers (int | None)
limit_per_minute (int | None)
environment (str | None)
delivery_timeout (float | None)
delivery_idempotency_key (Any | None)
delivery_cancel_mode (str | None)
delivery_heartbeat_seconds (float | None)
delivery_max_in_flight (int | None)
delivery_orphan_policy (str | None)
- Return type:
- wove.sync_to_async(func)[source]¶
Wraps a synchronous function to run in an executor.
By default, it uses asyncio’s default thread pool, but if called from within a weave context, it will use the dedicated executor for that context. This prevents deadlocks when a weave block is used inside another system that also manages the default executor (like Quart).
- wove.weave¶
alias of
WoveContextManager