pynenc.invocation.base_invocation¶
Module Contents¶
Classes¶
Immutable identity of an invocation |
|
Base class for representing an invocation of a task call in a distributed system. |
|
Abstract base class for grouping multiple invocations of a specific task. |
Data¶
API¶
- pynenc.invocation.base_invocation.T¶
‘TypeVar(…)’
- class pynenc.invocation.base_invocation.InvocationIdentity[source]¶
Bases:
typing.Generic[pynenc.types.Params,pynenc.types.Result]Immutable identity of an invocation
- call: pynenc.call.Call[pynenc.types.Params, pynenc.types.Result]¶
None
- parent_invocation: BaseInvocation | None¶
None
- class pynenc.invocation.base_invocation.BaseInvocation(call: pynenc.call.Call[pynenc.types.Params, pynenc.types.Result], parent_invocation: pynenc.invocation.base_invocation.BaseInvocation | None = None, invocation_id: str | None = None, workflow: pynenc.workflow.identity.WorkflowIdentity | None = None)[source]¶
Bases:
abc.ABC,typing.Generic[pynenc.types.Params,pynenc.types.Result]Base class for representing an invocation of a task call in a distributed system.
In the context of the system, the following concepts are key:
Function: A standard Python function.
Task: A Pynenc object encapsulating a function, enabling it to run in a distributed environment. Tasks are unique by module and function name and cannot be nested.
Call: A specific call to a task with a set of arguments, unique per function and argument set.
Invocation: A specific execution instance of a call.
A single task can be called with different arguments, and each call can be executed multiple times. This distinction is crucial for orchestration and cycle control within the system.
The
BaseInvocationclass serves as a template for two key types of invocations:DistributedInvocation: The primary invocation type used in the system for distributed execution.ConcurrentInvocation: Used for local execution, primarily in testing environments without a runner.
Important
Sync invocations cannot be used in production environments, only for testing in sync mode.
- Parameters:
call (Call[Params, Result]) – The specific call instance that this invocation represents.
Initialization
Initialize the invocation with its identity.
- property call: pynenc.call.Call[pynenc.types.Params, pynenc.types.Result]¶
- property parent_invocation: pynenc.invocation.base_invocation.BaseInvocation | None¶
- property app: pynenc.app.Pynenc¶
- property task: pynenc.task.Task[pynenc.types.Params, pynenc.types.Result]¶
- property arguments: pynenc.arguments.Arguments¶
- abstract classmethod from_json(app: pynenc.app.Pynenc, serialized: str) pynenc.invocation.base_invocation.T[source]¶
- Returns:
a new invocation from a serialized invocation
- abstract property status: pynenc.invocation.status.InvocationStatus¶
- abstract property result: pynenc.types.Result¶
- class pynenc.invocation.base_invocation.BaseInvocationGroup[source]¶
Bases:
abc.ABC,typing.Generic[pynenc.types.Params,pynenc.types.Result,pynenc.invocation.base_invocation.T]Abstract base class for grouping multiple invocations of a specific task.
This class is designed to aggregate a collection of invocations, each represented by a
BaseInvocationor its subclasses. It is useful in scenarios where multiple invocations of a task need to be managed or processed together.Subclasses of
BaseInvocationGroup, such asConcurrentInvocationGroupandDistributedInvocationGroup, provide specific implementations for synchronous and distributed environments, respectively.- Parameters:
task (Task) – The task associated with the invocations.
invocations (list[BaseInvocation]) – A list of invocations, each an instance of a
BaseInvocationsubclass.
- task: pynenc.task.Task¶
None
- property app: pynenc.app.Pynenc¶
- __iter__() collections.abc.Iterator[pynenc.invocation.base_invocation.T][source]¶
- abstract property results: collections.abc.Iterator[pynenc.types.Result]¶
Provide an iterator over the results.
- Return Iterator[Result]:
An iterator over the results of the invocations.
- abstract async_results() collections.abc.AsyncGenerator[pynenc.types.Result, None][source]¶
An async iterator over the results of the invocations in the group.
This method asynchronously iterates over the
ConcurrentInvocationinstances, yielding the result of each invocation using their async_result method.- Returns:
An async iterator over the results of each invocation in the group.
- Return type:
AsyncIterator[Result]