pynenc.call¶
Task call representations with optimized argument handling.
This module defines the core call abstractions for Pynenc tasks, optimized for different construction contexts:
Call: Standard client-side construction with raw arguments
LazyCall: State backend construction with deferred deserialization
PreSerializedCall: Batch construction with shared pre-serialized arguments
Key components:
CallId: Structured identifier combining task and argument identity
CallDTO: Serialization-ready data transfer object
compute_args_id: Deterministic hashing from serialized arguments
Module Contents¶
Classes¶
Standard task call with raw arguments. |
|
Task call with deferred argument deserialization. |
|
Task call optimized for batch operations with shared arguments. |
Functions¶
Compute deterministic argument hash from serialized form. |
API¶
- pynenc.call.compute_args_id(serialized_args: dict[str, str]) str[source]¶
Compute deterministic argument hash from serialized form.
- class pynenc.call.Call(task: Task[Params, Result], arguments: pynenc.arguments.Arguments | None = None, _serialized_arguments: dict[str, str] | None = None)[source]¶
Bases:
typing.Generic[pynenc.types.Params,pynenc.types.Result]Standard task call with raw arguments.
Created client-side when invoking tasks. Arguments are stored as Python objects and serialized on-demand for distribution.
- Parameters:
Initialization
- property app: pynenc.app.Pynenc¶
- property arguments: pynenc.arguments.Arguments¶
Get the arguments for this call. This property allows subclasses to override argument handling.
- Returns:
Arguments object containing call arguments
- property serialized_arguments: dict[str, str]¶
Serialize arguments with external storage for large values.
- Returns:
Mapping of argument names to serialized values or storage keys
- Raises:
SerializationError – If an argument cannot be serialized, enriched with task context.
- property call_id: pynenc.identifiers.call_id.CallId¶
Compute composite call identifier.
- Returns:
CallId combining task and argument identity
- property serialized_args_for_concurrency_check: dict[str, str] | None¶
Determines the call arguments required for the task concurrency check.
- Returns:
A dictionary of serialized argument strings required for concurrency control, or None if concurrency control is disabled.
- to_dto() pynenc.models.call_dto.CallDTO[source]¶
Create serialization-ready DTO.
- Returns:
CallDTO with pre-serialized data
- class pynenc.call.LazyCall(task: Task[Params, Result], _serialized_arguments: dict[str, str], _call_id: pynenc.identifiers.call_id.CallId)[source]¶
Bases:
pynenc.call.Call[pynenc.types.Params,pynenc.types.Result]Task call with deferred argument deserialization.
Created by state backends when loading persisted invocations. Arguments remain serialized until accessed, avoiding deserialization cost for identity-only operations (concurrency checks, status queries).
Must be constructed via from_dto factory method - do not instantiate directly.
- Parameters:
Initialization
- property arguments: pynenc.arguments.Arguments¶
Lazily deserialize arguments on first access.
- classmethod from_dto(app: pynenc.app.Pynenc, dto: pynenc.models.call_dto.CallDTO) LazyCall[Params, Result][source]¶
Construct LazyCall from DTO without deserialization.
Primary factory method for state backend usage.
- class pynenc.call.PreSerializedCall(task: Task[Params, Result], common_args: dict[str, Any] | None = None, common_serialized_args: dict[str, str] | None = None, other_args: dict[str, Any] | None = None)[source]¶
Bases:
pynenc.call.Call[pynenc.types.Params,pynenc.types.Result]Task call optimized for batch operations with shared arguments.
Used when distributing many similar tasks with large common arguments. Common arguments are pre-serialized once; unique arguments serialized per-call. Enables efficient batch routing without redundant serialization.
- Parameters:
Initialization