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, credential=None, artifact_resolver=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).
Blob artifact IDs are resolved through a pluggable ArtifactResolver,
defaulting to Azure AI Search; see artifact_resolvers.py.
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 Azure Blob access unless a credential is
provided. Blob URL fetching is available whenever a credential can be
initialized. Blob artifact ID resolution is delegated to an
ArtifactResolver; the default one queries Azure AI Search and so
additionally requires DATA_LAKE_SEARCH_ENDPOINT.
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
|
credential
|
AsyncTokenCredential | None
|
Optional async token credential to use for Azure Blob
Storage and Azure AI Search access. When omitted, the manager
creates the same storage credential chain as before, resolving
|
None
|
artifact_resolver
|
ArtifactResolver | None
|
Optional resolver turning |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
Source code in src/agora_workbench/code_execution/data_access/manager.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
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 |