Data Access¶
Data Manager¶
agora_workbench.code_execution.data_access.manager
¶
DataLakeDataManager for fetching and caching data assets.
This module provides the core manager that handles fetching assets from DataLake-cataloged sources and caching them to disk for tool access.
DataLakeDataManager(allowed_local_roots=None, extra_fetchers=None)
¶
Manages data asset retrieval and caching for code execution sessions.
Fetches data assets from DataLake-cataloged sources and caches them to disk in their original format. Tools receive Path objects and handle loading the data as needed.
Authentication uses a credential chain (create_storage_credential):
the mounted az login MSAL cache for local development, falling back to
managed identity in production, for downstream Azure resources
(Storage, AI Search).
Supports: - Azure Blob Storage (abfss://, az://, https://) - Local filesystem (absolute paths, relative paths, file:// URIs)
Initialize the data manager.
Uses a credential chain (az login MSAL cache locally, managed
identity in production) for downstream resource access when Azure
services are configured. Falls back to local-only mode when
DATA_LAKE_SEARCH_ENDPOINT is not set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
allowed_local_roots
|
list[str] | None
|
Optional list of directory paths the local
file fetcher is allowed to read from. If |
None
|
extra_fetchers
|
list[AssetFetcher] | None
|
Optional list of additional |
None
|
Source code in src/agora_workbench/code_execution/data_access/manager.py
get_cache_path(qualified_name)
async
¶
Get the filesystem path where the asset is cached.
Ensures the asset is fetched and cached to disk in its original format, then returns the path. This allows kernel subprocesses to load the asset directly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
qualified_name
|
AssetId
|
Type-tagged artifact format |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Path to the cached file |
Raises:
| Type | Description |
|---|---|
ValueError
|
If not in tagged format, unsupported type, or artifact not found |
Source code in src/agora_workbench/code_execution/data_access/manager.py
get_asset_info(qualified_name)
¶
Get information about a cached asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
qualified_name
|
str
|
Asset identifier |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Dict with asset metadata |
Source code in src/agora_workbench/code_execution/data_access/manager.py
list_available()
¶
List assets available in this session's cache.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of qualified names currently cached |
cleanup()
¶
Clean up cache directory, credentials, and resources.
Removes the temporary cache directory if it was created by this manager. Call this when the session is ending to free up disk space.
Source code in src/agora_workbench/code_execution/data_access/manager.py
aclose()
async
¶
Async cleanup — preferred over sync cleanup() when inside an event loop.
Source code in src/agora_workbench/code_execution/data_access/manager.py
__del__()
¶
Asset Resolution¶
agora_workbench.code_execution.data_access.resolution
¶
Utilities for detecting and resolving DataLake-cataloged asset references.
AssetResolutionMiddleware(server)
¶
Bases: Middleware
FastMCP middleware that resolves DataLake asset references before Pydantic validation.
When the agent sends a tool call with tagged asset references like
<blob>base64_id</blob>, this middleware intercepts the arguments,
resolves each reference to a local cache path via the session's data
manager, and replaces the argument value with the path string. This
happens before FastMCP/Pydantic coerces arguments against the function
signature, so parameters with their natural types (Path, bool,
int, etc.) receive properly typed values instead of being mangled by
premature coercion.
Resolution metadata (qualified name, cache path, parameter name) is stored
in a ContextVar so that the tool callback can inject the asset into the
kernel for the generated execution code.
Source code in src/agora_workbench/code_execution/data_access/resolution.py
looks_like_qualified_name(value)
¶
Check if a string looks like a DataLake qualified name.
Recognizes type-tagged artifact format:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
String to check |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if value matches the type-tagged artifact pattern |
Source code in src/agora_workbench/code_execution/data_access/resolution.py
should_resolve_as_asset(value)
¶
Determine if a parameter value should be resolved as a DataLake asset.
Detection is purely value-based: any string matching the type-tagged
format <type>id</type> will be resolved.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Parameter value to check |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if value is a type-tagged asset reference |