add sandbox mounts#17
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 17 minutes and 0 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis change introduces comprehensive object storage mount support to the SDK by adding new schemas, models, validators, and CRUD operations (add, update, delete) to both synchronous and asynchronous sandbox clients, alongside updated model definitions and full test coverage. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
leap0/_sync/sandbox.py (1)
488-490: Use_validate_object_storage_mountsdirectly instead of constructingCreateSandboxParams.Going through
CreateSandboxParams(mounts=[mount]).mountsinstantiates the full sandbox-creation pydantic model (re-validating defaults fortemplate_name,vcpu,memory, etc.) just to normalize a single mount. Importing and calling_validate_object_storage_mounts([mount])directly is clearer and cheaper, and avoids couplingadd_mountto unrelated field validation. Same applies to the async client at leap0/_async/sandbox.py:489.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@leap0/_sync/sandbox.py` around lines 488 - 490, The code currently normalizes a single mount by instantiating CreateSandboxParams (CreateSandboxParams(mounts=[mount]).mounts) which triggers full pydantic validation of unrelated fields; replace that with a direct call to _validate_object_storage_mounts([mount]) to normalize/validate mounts only. Update the synchronous add_mount implementation (and the async counterpart in _async/sandbox.py) to import and call _validate_object_storage_mounts with a single-item list, use its return value instead of CreateSandboxParams(...).mounts, and remove the unnecessary dependency on CreateSandboxParams so add_mount no longer revalidates template_name/vcpu/memory.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@leap0/models/sandbox.py`:
- Around line 144-150: The validator _validate_object_storage_mounts currently
treats an empty-string prefix as valid (passes the `if prefix and (...)` check)
then later drops it from the normalized payload, causing inconsistent behavior
versus _validate_object_storage_mount_update; make the behavior explicit by
rejecting empty-string prefixes: after the type check for prefix in
_validate_object_storage_mounts add a guard that raises ValueError when prefix
== "" with the same error message as other invalid forms, and mirror this change
in _validate_object_storage_mount_update so both code paths consistently reject
empty prefixes rather than silently eliding them.
- Line 338: Sandbox.mounts and SandboxStatus.mounts default to None but their
from_dict implementations unconditionally use data.get("mounts", []) which
converts absent fields to an empty list; change the parsing to preserve None
when the key is absent (e.g. if "mounts" in data: mounts =
[ObjectStorageMount.from_dict(m) for m in data["mounts"]] else: mounts = None).
Update Sandbox.from_dict and SandboxStatus.from_dict (and any other similar
fields noted around the same area) to use the presence-check pattern so
programmatically constructed instances (None) and parsed instances (absent ->
None) behave the same.
---
Nitpick comments:
In `@leap0/_sync/sandbox.py`:
- Around line 488-490: The code currently normalizes a single mount by
instantiating CreateSandboxParams (CreateSandboxParams(mounts=[mount]).mounts)
which triggers full pydantic validation of unrelated fields; replace that with a
direct call to _validate_object_storage_mounts([mount]) to normalize/validate
mounts only. Update the synchronous add_mount implementation (and the async
counterpart in _async/sandbox.py) to import and call
_validate_object_storage_mounts with a single-item list, use its return value
instead of CreateSandboxParams(...).mounts, and remove the unnecessary
dependency on CreateSandboxParams so add_mount no longer revalidates
template_name/vcpu/memory.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a632188e-e3e1-4be3-92b2-fb15b1a1cebf
📒 Files selected for processing (8)
leap0/__init__.pyleap0/_async/sandbox.pyleap0/_schemas/sandbox.pyleap0/_sync/sandbox.pyleap0/models/sandbox.pytests/_async/test_sandboxes.pytests/_sync/test_sandboxes.pytests/models/test_sandbox.py
Summary
Summary by CodeRabbit
New Features