Custom Python snapshot
Bake a python:3.12 image with pandas / numpy / requests preinstalled.
A fully custom snapshot using defineSnapshot. No preset, no convention — you describe what you want.
import { buildSnapshot, defineSnapshot } from "@beamhop/lightbox";
const pythonDataSnapshot = defineSnapshot({
name: "py-data",
image: "python:3.12",
resources: { cpus: 2, memory: "1G" },
workdir: "/work",
setup: [
"pip install --no-cache-dir numpy pandas requests",
],
labels: { team: "data" },
});
await buildSnapshot(pythonDataSnapshot);
console.log(`Snapshot "${pythonDataSnapshot.name}" ready.`);
Once built, run code in an ephemeral sandbox with runInSandbox — it boots, runs your callback, and tears down even if you throw:
import { runInSandbox } from "@beamhop/lightbox";
const out = await runInSandbox(
{ snapshot: "py-data", name: "analysis-1" },
(sb) => sb.shell(`python -c "import pandas as pd; print(pd.__version__)"`),
);
console.log(out.stdout());