datarobot_genai.drmcputils.files.store
store
Block storage for drtools, backed by the DataRobot Files API (v3.10+).
Defines a minimal :class:BlobStore Protocol and a Files-API-backed
implementation. Higher-level domains (e.g. panels) depend on the Protocol, not
the concrete backend, so storage stays swappable (a local/in-memory backend can
satisfy the same contract for tests) and the Files API is the production
default.
The DataRobot Files SDK (datarobot.models.Files) is synchronous; its calls
are dispatched to a worker thread via :func:asyncio.to_thread, which copies
the current context so the per-request client configured by
:func:request_user_dr_sdk remains in effect inside the thread.
BlobRef
dataclass
A lightweight, serializable handle to a stored blob.
Every field is durably round-tripped by the Files API, so a ref returned by
:meth:BlobStore.put and the same blob's ref returned by
:meth:BlobStore.list compare equal:
files_id— the durable handle (the DataRobot Files container id).name— the stored container name.tags— the stored tags (atupleso the ref stays hashable).
Note: byte size and MIME content-type are intentionally not fields. The
Files API does not persist them on the container (and search_catalog
never returns them), so they could not be populated symmetrically by
list. Callers that need a content-type should record it themselves
(e.g. a panel manifest); see content_type on :meth:BlobStore.put.
Source code in datarobot_genai/drmcputils/files/store.py
BlobStore
Bases: Protocol
Storage seam for opaque byte payloads. Implementations must be async-safe.
Source code in datarobot_genai/drmcputils/files/store.py
put
async
put(data: bytes, *, name: str, content_type: str | None = None, tags: list[str] | None = None, timeout: int = DEFAULT_PUT_TIMEOUT_SECONDS) -> BlobRef
Store data and return a handle to it.
content_type is advisory: the Files backend does not persist it, so
it is not reflected on the returned :class:BlobRef. Callers that need
it should record it alongside their own metadata.
timeout bounds the upload (seconds); raise it for very large blobs.
Source code in datarobot_genai/drmcputils/files/store.py
get
async
delete
async
DataRobotFilesBlobStore
:class:BlobStore backed by the DataRobot Files API (datarobot.models.Files).
Each blob is stored as its own single-file Files container; the container id
is the durable handle (:attr:BlobRef.files_id). Scoped to the requesting
user's DataRobot token; blocking SDK calls run in a worker thread.
Source code in datarobot_genai/drmcputils/files/store.py
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 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | |