Skip to content

feat(arena): add CoreWeave Sandboxes workshop notebook#77

Open
ntnadkarni wants to merge 6 commits into
mainfrom
nnadkarni/arena-sandboxes-workshop
Open

feat(arena): add CoreWeave Sandboxes workshop notebook#77
ntnadkarni wants to merge 6 commits into
mainfrom
nnadkarni/arena-sandboxes-workshop

Conversation

@ntnadkarni

@ntnadkarni ntnadkarni commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Adds arena/notebooks/sandboxes-workshop.py — a hands-on Arena notebook that walks through the full lifecycle of a CoreWeave Sandbox: author a profile → deploy a managed runner → launch a sandbox via the Python SDK → run a parallel reward-evaluation batch → trace every reward call to W&B via Weave → clean up.

ntnadkarni and others added 2 commits June 2, 2026 15:59
Adds a hands-on Arena notebook that walks through the full Sandboxes
lifecycle: author a profile, deploy a managed runner on a CKS cluster,
launch a sandbox via the cwsandbox Python SDK, run a parallel
reward-evaluation batch (the canonical RL-with-verifiable-rewards
pattern), and trace each reward call to W&B via Weave.

- Single self-contained file, follows arena-staging guidelines
- Verified deps install cleanly in marimo --sandbox mode
- Hardware-agnostic (talks to Sandboxes API, no GPU dependency)
- Idempotent: re-running Step 1/2 reuses existing profile/runner
- Optional W&B token gates Weave tracing without breaking the flow

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drop the marketing-flavored "canonical pattern that drives this product"
lead-in and the extract_xml_answer / TRL-GRPO follow-on paragraph.
Reads more neutrally.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment thread arena/notebooks/sandboxes-workshop.py Outdated
Comment thread arena/notebooks/sandboxes-workshop.py
Comment thread arena/notebooks/sandboxes-workshop.py
Comment thread arena/notebooks/sandboxes-workshop.py Outdated
Comment thread arena/notebooks/sandboxes-workshop.py Outdated
Comment thread arena/notebooks/sandboxes-workshop.py Outdated
Comment thread arena/notebooks/sandboxes-workshop.py Outdated
Comment thread arena/notebooks/sandboxes-workshop.py Outdated
Comment thread arena/notebooks/sandboxes-workshop.py
Comment thread arena/notebooks/sandboxes-workshop.py Outdated
…extra fields

Move kubernetes imports inside detect_cw_token so callers that don't
need kubeconfig parsing can use lib.coreweave (e.g. cw_token_input)
without pulling in the kubernetes dep chain. ImportError on the
kubernetes import is caught and falls through to the "Not Found"
path, so the lib stays usable in environments that don't have
kubernetes installed at all.

cw_token_input now accepts an optional extra_fields mapping. With no
args the rendered form is byte-identical to before. With extra_fields,
the form renders all fields together so a notebook can collect the CW
token plus auxiliary credentials in a single submit.
…auth

- Auto-detect a CoreWeave access token via detect_cw_token() (Arena
  pod identity → CW_TOKEN env var → kubeconfig). Form falls back when
  nothing is found, and the W&B field is offered in either path.
- Switch sandbox SDK auth from os.environ["CWSANDBOX_API_KEY"] to
  the SDK's set_auth_mode hook, with the token captured in a lambda
  closure. The token stays in memory only — never enters the process
  environment, never inherited by child processes.
- Replace free-text cluster zone / name inputs with a dropdown
  populated from GET /v1beta1/cks/clusters (filtered to STATUS_RUNNING).
  Invalid combinations are no longer possible.
- Prerequisites bullet updated to describe the auto-detect path.
Replace the manual "Poll runner state" button with an auto-poll loop
that fires as soon as a runner is submitted. Progress lines stream
into the cell output every 3 seconds via mo.output.append() so the
user can watch installStatus / connectionStatus evolve in real time.

The loop exits cleanly on three outcomes:
- READY + CONNECTED — green success callout with elapsed seconds
- HTTP error from the runner GET — red callout with the response body
- 180-second timeout — yellow warning callout suggesting a re-run
- Expand Step 1's intro with a bullet-list field reference for the
  profile form (display name, namespace strategy, egress mode,
  runtime class, CPU/memory limit) linking to the docs.
- Mark every remaining chrome cell with hide_code=True so the
  rendered app view shows no Python source.
- Tighten a few inline copy edits.
@@ -0,0 +1,970 @@
# /// script
# requires-python = ">=3.12"
# dependencies = [

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add new dependencies to the project pyproject.toml


To access the token in your code, use token_form.value.get("cw_token")
Args:
extra_fields: Optional mapping of {name: widget} for additional

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is appropriate to include in a function called cw_token_input(). You changed a 15 line function into a 50 line one to avoid adding a "wandb_token_input" function. Two options I see to help here:

  1. Generalize this function to just be "token_input()" and make sure it keeps working in the other 2 existing notebooks.
  2. Add a new reusable wandb_token_input() function to this library

container image, runtime class, namespace strategy, network policy, and
pod placement.

Field reference (full schema in the [Profile reference docs](https://docs.coreweave.com/products/sandboxes/reference/profile)):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, very helpful

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.

2 participants