Migrate from Modal

Move Modal Sandboxes to Sandal: call-by-call mapping (Python), a before/after, and what Sandal does not have yet.


Modal Sandboxes are defined next to a Modal app and an image built in code. On Sandal there is no app object: a sandbox starts from the default template of your project (Debian with Python 3, Node.js and git), and you customise it with a setup script, an environment or a template build. Sandal has no GPUs.

1. Install and sign in#

Follow the quickstart steps 1 and 2: install the CLI and SDK, then sandal login. The SDKs read that profile; in CI set SANDAL_API_KEY (the key alone is enough; organization and project ids are optional overrides).

2. API mapping#

ModalSandal
modal.App.lookup(...) + modal.Sandbox.create(app=app, image=img)await sandal.create_sandbox() (no app; template= for a custom image)
modal.Image.debian_slim().pip_install(...)a setup script (sandal create --setup-file setup.sh), an environment (sandal env), or a template build
modal.Sandbox.from_id(id)sandal.sandbox(id)
sb.exec("python", "-c", code) + p.wait() / p.stdout.read()await sb.exec(...) returns exit_code, stdout, stderr when it ends
a long-running sb.exec(...)await sb.start_command(cmd); CLI sandal exec --detach
sb.open(path, "w") / "r"await sb.write_text(path, text) / await sb.read_text(path)
encrypted_ports=[8000] + sb.tunnels()[8000].urlawait sb.expose(8000) (needs your key) or await sb.share(8000) (link, no key)
sb.snapshot_filesystem()await sb.snapshot() and fork, or sandal snapshot save + sandal create --from <name>
timeout=hard expiry on create (--ttl, CLI default 24 h) and extend
sb.terminate()await sb.delete()
gpu=...not offered

3. Before and after#

Before

import modal

app = modal.App.lookup("demo", create_if_missing=True)
sb = modal.Sandbox.create(app=app, image=modal.Image.debian_slim(), encrypted_ports=[8000])
try:
    p = sb.exec("python", "-c", "print(6 * 7)")
    p.wait()
    print(p.returncode, p.stdout.read())
    sb.exec("python", "-m", "http.server", "8000")
    print(sb.tunnels()[8000].url)
finally:
    sb.terminate()

After

import asyncio
from sandal import Sandal

async def main() -> None:
    sandal = Sandal()
    try:
        async with await sandal.create_sandbox() as sb:
            r = await sb.exec("python3 -c 'print(6 * 7)'")
            print(r.exit_code, r.stdout)
            await sb.start_command("python3 -m http.server 8000")
            print((await sb.share(8000)).url)
    finally:
        await sandal.close()

asyncio.run(main())

A blocking client with the same methods is SandalSync, closer to the synchronous Modal style.

What Sandal does not have yet#

Said plainly, so you can plan around it (no dates promised):

  • Root in the guest. On the default template commands run as uid 2000 without sudo; exec as root (sandal exec --root, user="root") is refused with 422 capability_unavailable. A root + FUSE template is in preview; no root-capable template is generally offered yet.
  • FUSE and S3 mounts. The default template has no /dev/fuse, so s3fs / mountpoint-s3 cannot run there, and there is no native bucket mount. Use persistent volumes or copy objects in and out, or ask for the root + FUSE preview template.
  • Memory snapshots. Not offered: pause/resume keeps memory on the same sandbox only; snapshots and forks are disk-only.
  • Region choice. Sandal runs in the EU only (Germany, Finland, Luxembourg).
  • Outbound IPv6. IPv4 only today.
  • Volume snapshots and OpenTelemetry export are not offered yet.