Skip to content

feat(snapshots): wait for a snapshot to be Ready - #55

Merged
mayur-tolexo merged 1 commit into
mainfrom
feat/snapshot-wait
Oct 16, 2026
Merged

mayur-tolexo merged 1 commit into
mainfrom
feat/snapshot-wait

Conversation

@mayur-tolexo

@mayur-tolexo mayur-tolexo commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Why

A snapshot starts as Pending and is only usable for rollback, fork or restore once it is Ready. The JS SDK can wait for that with snapshot({ waitUntilReady: true }) and sandboxes.waitForSnapshot, but in Python you had to write the polling loop yourself, so the docs could only say "wait until the status is Ready".

What

  • client.sandboxes.wait_for_snapshot(snapshot_id, timeout_ms=300000, poll_interval_ms=2000) polls until the snapshot is Ready and returns it. A Failed snapshot raises NeevAIError with its reason, and so does a snapshot that is not Ready in time. A zero, negative or non-finite timing is rejected before any request; with wait_until_ready=True that check runs before the snapshot is created, so a bad timing leaves no snapshot behind.
  • sandbox.snapshot(params, wait_until_ready=True) takes the snapshot and waits in one call; without it, behaviour is unchanged.
  • Both work on the sync and async clients, with the same defaults as the JS SDK.

Example

from neevai import NeevAI

with NeevAI() as client:
    sandbox = client.sandboxes.create({"sandbox_template_id": "sb-ubuntu-26-04-dev"})
    try:
        sandbox.wait_until_ready()
        snap = sandbox.snapshot({"name": "checkpoint"}, wait_until_ready=True)
        print(snap.status)  # Ready
        sandbox.rollback(snap.id)
    finally:
        sandbox.delete()

Testing

ruff, ruff format, pyright, mypy and 698 tests pass. The new tests cover Ready after polling, Ready at once, Failed with its reason, timeout, rejected timings (including that a bad timing creates no snapshot), and the handle's wait on the sync and async clients. Not run against a live API.

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f4a9abe4-a12c-448b-a03c-e8d5d4000c16
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

sandboxes.wait_for_snapshot polls a snapshot until it is Ready, raising on
Failed (with its reason) or on timeout, and sandbox.snapshot takes
wait_until_ready=True to snapshot and wait in one call. Sync and async,
matching the JS SDK's waitForSnapshot and snapshot({ waitUntilReady }).

Signed-off-by: Mayur Das <mayur.das@neevcloud.com>
@mayur-tolexo
mayur-tolexo merged commit e4f58f8 into main Oct 16, 2026
5 checks passed
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.

1 participant