datarobot_genai.drmcputils.files.file_system_store
file_system_store
Hierarchical filesystem seam for drtools, backed by the DataRobot Files API.
Unlike the flat :class:~datarobot_genai.drmcputils.files.store.BlobStore (one
blob == one Files container), this store exposes DataRobot's hierarchical
filesystem: files live inside a catalog item addressed as
dr://<catalog_item_id>/path/to/file. It is a thin async wrapper around
:class:datarobot.fs.DataRobotFileSystem (an fsspec implementation).
Design mirrors :mod:datarobot_genai.drmcputils.files.store:
- A minimal :class:
FileSystemStoreProtocol so higher layers depend on the contract, not the concrete backend (an in-memory backend can satisfy it in tests). - The fsspec filesystem 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_sdkstays in effect inside the thread. - DataRobot/fsspec errors are normalised to :class:
ToolErrorso tool code never leaks SDK or OS exception types.
DirectoryNotEmptyError
Bases: Exception
Raised by :meth:FileSystemStore.delete for a non-recursive delete of a non-empty directory.
Distinct from the silent no-op for an already-missing path: that case has nothing to signal, while this one represents a real guard rejecting the request, which callers should surface rather than report as a successful deletion.
Source code in datarobot_genai/drmcputils/files/file_system_store.py
FileEntry
dataclass
A serializable description of a file or directory in the DataRobot filesystem.
Built from the fsspec FileInfo mapping the backend returns. name is
the path without the dr:// protocol prefix (e.g.
<catalog_id>/data/file.csv); directories carry type == "directory"
and size == 0.
Source code in datarobot_genai/drmcputils/files/file_system_store.py
from_info
classmethod
Build a :class:FileEntry from an fsspec FileInfo mapping.
Source code in datarobot_genai/drmcputils/files/file_system_store.py
to_dict
Return a plain JSON-serializable dict for tool responses.
Source code in datarobot_genai/drmcputils/files/file_system_store.py
FileSystemStore
Bases: Protocol
Read seam over the DataRobot hierarchical filesystem. Implementations must be async-safe.
Source code in datarobot_genai/drmcputils/files/file_system_store.py
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 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | |
ls
async
List the immediate children of path (catalog items at dr:// root).
find
async
Recursively list everything under path (posix find semantics, no globs).
glob
async
List entries matching a glob pattern (e.g. dr://<id>/**/*.csv).
tree
async
tree(path: str, *, recursion_limit: int = 2, max_display: int = 25, display_size: bool = False) -> str
Return a compact, indented tree view of path.
info
async
read
async
sign
async
Return a temporary signed download URL for the file at path.
write
async
Write data to the file at path ('overwrite' or 'create' if absent).
upload
async
upload(local_path: str | list[str], dest: str | list[str], *, recursive: bool = False, maxdepth: int | None = None, overwrite: OverwriteStrategyName = 'rename') -> None
Upload local file(s)/director(ies) into the filesystem.
Content is streamed in chunks (no inline size cap) and multiple files are batched into a single optimized request when possible.
Source code in datarobot_genai/drmcputils/files/file_system_store.py
create_dir
async
delete
async
Delete file(s) or director(ies) at path (silent if absent).
Raises :class:DirectoryNotEmptyError if recursive is False and path is
an existing, non-empty directory (nothing is deleted in that case).
Source code in datarobot_genai/drmcputils/files/file_system_store.py
copy
async
copy(source: str, dest: str, *, recursive: bool = False, maxdepth: int | None = None, overwrite: OverwriteStrategyName = 'rename') -> None
Copy source to dest within the filesystem.
Source code in datarobot_genai/drmcputils/files/file_system_store.py
move
async
move(source: str, dest: str, *, recursive: bool = False, maxdepth: int | None = None, overwrite: OverwriteStrategyName = 'rename') -> None
Move/rename source to dest within the filesystem.
Source code in datarobot_genai/drmcputils/files/file_system_store.py
clone
async
Clone a catalog item directory and return the new catalog item id.
import_from_url
async
import_from_url(path: str, url: str, *, unpack_archive: bool = True, overwrite: OverwriteStrategyName = 'rename') -> str
Start a URL import and return the async status id.
Source code in datarobot_genai/drmcputils/files/file_system_store.py
import_from_data_source
async
import_from_data_source(path: str, data_source_id: str, *, credential_id: str | None = None, unpack_archive: bool = True, overwrite: OverwriteStrategyName = 'rename') -> str
Start a data-source import and return the async status id.
Source code in datarobot_genai/drmcputils/files/file_system_store.py
get_status
async
DataRobotFileSystemStore
:class:FileSystemStore backed by :class:datarobot.fs.DataRobotFileSystem.
Scoped to the requesting user's DataRobot token; blocking fsspec calls run in
a worker thread. A fresh filesystem is built per call inside the thread — it
holds no client state (the Files SDK resolves the request-scoped client
from the context configured by :func:request_user_dr_sdk).
Source code in datarobot_genai/drmcputils/files/file_system_store.py
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | |
normalize_status_location
Return a relative API route for status/<id>/ from a bare id, route, or URL.
Source code in datarobot_genai/drmcputils/files/file_system_store.py
extract_status_id
Extract the bare status id from an async Location header or route.