async_manager
async_manager ¶
AsyncResultsManager ¶
AsyncResultsManager(
base_dir: Union[str, Path] = None,
create_if_missing: bool = True,
backend: Optional[AsyncResultsBackend] = None,
)
Bases: Generic[T]
Async version of ResultsManager for managing results from parallel processes.
Provides an asynchronous interface for storing and retrieving pydantic models.
Initialize the AsyncResultsManager.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_dir
|
Union[str, Path]
|
Base directory for file storage (used only if backend is None) |
None
|
create_if_missing
|
bool
|
Whether to create the directory if it doesn't exist |
True
|
backend
|
Optional[AsyncResultsBackend]
|
Optional custom async backend to use. If None, uses AsyncFileBackend. |
None
|
Source code in src/results_manager/async_manager.py
clear
async
¶
delete
async
¶
exists
async
¶
Asynchronously check if a result exists for the given ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
result_id
|
Union[str, List[str]]
|
Unique identifier or hierarchical path for the result |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the result exists, False otherwise |
Source code in src/results_manager/async_manager.py
get
async
¶
get(
result_id: Union[str, List[str]],
model_class: Optional[Type[T]] = None,
namespace: Optional[str] = None,
) -> T
Asynchronously retrieve a result by ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
result_id
|
Union[str, List[str]]
|
Unique identifier or hierarchical path for the result |
required |
model_class
|
Optional[Type[T]]
|
Optional model class to validate against |
None
|
namespace
|
Optional[str]
|
Optional namespace to look in |
None
|
Returns:
Type | Description |
---|---|
T
|
Pydantic model instance |
Source code in src/results_manager/async_manager.py
list_ids
async
¶
set
async
¶
set(
result_id: Union[str, List[str]],
data: BaseModel,
behavior: SetBehavior = RAISE_IF_EXISTS,
namespace: Optional[str] = None,
strict_namespace: bool = False,
) -> bool
Asynchronously store a result with the given ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
result_id
|
Union[str, List[str]]
|
Unique identifier or hierarchical path for the result |
required |
data
|
BaseModel
|
Pydantic model instance to store |
required |
behavior
|
SetBehavior
|
How to handle existing data with the same ID |
RAISE_IF_EXISTS
|
namespace
|
Optional[str]
|
Optional namespace to store the model in |
None
|
strict_namespace
|
bool
|
If True, raises an error if model is in multiple namespaces |
False
|
Returns:
Type | Description |
---|---|
bool
|
True if data was written, False if skipped |