Skip to content

Add drives to the management client and sandbox - #51

Merged
cretz merged 3 commits into
mainfrom
cretz/drives
Dec 3, 2026
Merged

cretz merged 3 commits into
mainfrom
cretz/drives

Conversation

@cretz

@cretz cretz commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

🚀 What

Note, this is waiting on backend impl and should not be merged as is

  • ManagementClient.drives / AsyncManagementClient.drives with create, get, list, update, and delete for drives
  • Sandbox.drives / AsyncSandbox.drives to mount, unmount, and list drive mounts in a running sandbox
  • Management spec synced with Go SDK's (includes drive operations); clients regenerated

💻 How

  • Drive calls use a minted sandbox token, like the sandbox client
  • Drive client is built lazily on first drives access, sharing one cached token

🔬 Testing

  • Unit tests for both clients, sync and async, including token resend on revocation, plus parity checks
  • E2E added (sync client only, one drive)

@cretz
cretz requested review from cploujoux and a balanced review from Copilot December 1, 2026 22:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The drive test can mount before provisioning completes, causing timing-dependent failures, while token-revocation recovery retains the 401 response connection and can fail with PoolTimeout.

2 open issues
What changed in this PR

Adds shared-drive support to the Python SDK’s management and sandbox clients, covering drive lifecycle operations and mounts in running sandboxes. Backend implementation is still pending, as noted in the PR description.

Changes:

  • Adds sync and async drive clients with cached token authentication and paginated listing.
  • Exposes sandbox mount, unmount, and mount-listing operations.
  • Refreshes generated management APIs and adds unit, parity, and end-to-end coverage.
File Description
tests/​sandbox/​test_parity.py Adds drive interface and model parity checks.
tests/​sandbox/​test_e2e.py Exercises drive lifecycle, mounting, and persistence.
tests/​sandbox/​test_drives.py Tests sandbox mount operations and errors.
tests/​client/​test_drive.py Tests drive operations, authentication, and pagination.
baseten/​sandbox/​_sandbox.py Exposes sync and async drives properties.
baseten/​sandbox/​_drives.py Implements sandbox drive mounting APIs.
baseten/​sandbox/​__init__.py Exports sandbox drive types.
baseten/​client/​managementapi/​_models.py Refreshes generated models, including drives.
baseten/​client/​managementapi/​_client.py Refreshes generated endpoints, including drive operations.
baseten/​client/​managementapi/​__init__.py Updates generated model exports.
baseten/​client/​_management.py Lazily initializes management drive clients.
baseten/​client/​_drive.py Implements drive operations and token authentication.
baseten/​client/​__init__.py Exports public drive clients and types.

Review effort: Balanced

Comment thread baseten/client/_drive.py
Comment on lines +428 to +429
if not replayable or retry == _DRIVE_TOKEN_INVALIDATION_MAX_RETRIES:
return

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cretz have you seen this in other clients ?
This might be worth checking

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I am fixing this one. Other SDKs/CLI confirmed does handle this properly

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment thread tests/sandbox/test_e2e.py
labels = {**_LABELS, "step": "update"}
assert drives.update(name=name, labels=labels).labels == labels

mounted = sandbox.drives.mount(name=name, mount_path=first_path)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not waiting is intentional (and e2e tests confirm it), see response to similar at basetenlabs/baseten-js#42 (comment)

@cretz
cretz merged commit f7b24a3 into main Dec 3, 2026
11 of 13 checks passed
@cretz
cretz deleted the cretz/drives branch December 3, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants