Skip to content

Work in JupyterLab

After opening a notebook, use the injected environment to talk to your project.

On each JupyterLab start, Labelty’s lifecycle script sets:

Variable Meaning
LABELTY_API_URL API base including /api/v1
LABELTY_API_KEY Project-scoped lty_… key for this space

LABELTY_PROJECT_ID is intentionally not set. Resolve the project from the key:

client.project # or client.projects.current()

Values are written into:

  • ~/.bashrc (terminals)
  • IPython startup script (notebook kernels)
  • Conda activate hook when writable

Run in a notebook cell:

import os
for k in ("LABELTY_API_URL", "LABELTY_API_KEY"):
value = os.environ.get(k)
print(f"{k}: {'set' if value else 'MISSING'}")

Expected output: both variables report set.

If either is missing, restart the notebook (Stop → Open in Labelty) so lifecycle runs again. Ops can check CloudWatch /aws/sagemaker/studio with filter labelty-lifecycle.

The lifecycle script lazy-installs labelty-sdk if import labelty_sdk fails.

import os
from labelty_sdk import LabeltyClient
with LabeltyClient(
api_url=os.environ["LABELTY_API_URL"],
api_key=os.environ["LABELTY_API_KEY"],
) as client:
project = client.project
print(project.id, project.name)
schema = project.schema.get()
assets = project.assets.list(limit=20, offset=0)
print("assets", len(assets))

Why pass env vars explicitly: the SDK client does not auto-read LABELTY_*; notebooks (and scripts) must pass them.

Follow the SDK guides from inside the notebook:

  • One shared space per project — collaborators share the same files; coordinate edits.
  • No direct AWS data APIs from the locked-down notebook role — use the Labelty SDK/API.
  • Tags for URL/key are set at first space creation; rotating keys in the UI may not refresh the space until ops/product support exists.
  • Lifecycle script updates need infra apply + Stop → Open to take effect.
  • EBS persists after stop; compute billing stops, but storage may still incur cost (confirm with your cloud bill / ops).

In the Labelty notebook modal, click Stop. This deletes the JupyterLab app (compute) while keeping the space volume.