Build an image, upload a local script, run it in a sandbox, and terminate the sandbox when the work is complete:

import chalkcompute

if __name__ == "__main__":
    image = (
        chalkcompute.Image.debian_slim("3.12")
        .pip_install(["requests"])
        .add_local_file("./script.py", "/app/script.py")
        .workdir("/app")
    )

    sandbox = chalkcompute.Sandbox(
        image=image,
        name="hello-sandbox",
        cpu="1",
        memory="2Gi",
    ).run()

    result = sandbox.exec("python", "/app/script.py")
    print(result.stdout_text)

    sandbox.terminate()

chalkcompute.Sandbox(...).run() builds the Image, reuses a cached build when possible, creates the sandbox, and waits for it to become ready. Local files declared with add_local_file or add_local_dir are uploaded as part of the image setup.