Metadata-Version: 2.5
Name: 3lc-compute-plugin-jupyter
Version: 0.1.1
Summary: JupyterLab with the 3LC Python package for the 3LC compute service — on this machine or a GPU node.
License: Apache-2.0
License-File: LICENSE
Classifier: License :: OSI Approved :: Apache Software License
Requires-Python: >=3.10
Requires-Dist: 3lc-compute-plugin-sdk<0.6.0,>=0.5.0
Requires-Dist: 3lc<4.0.0,>=3.5.0.dev149866
Provides-Extra: jupyter
Requires-Dist: 3lc[pacmap,pandas,umap]<4.0.0,>=3.5.0.dev149866; extra == 'jupyter'
Requires-Dist: ipykernel>=6.29; extra == 'jupyter'
Requires-Dist: ipywidgets>=8; extra == 'jupyter'
Requires-Dist: jupyterlab<5,>=4.4; extra == 'jupyter'
Requires-Dist: matplotlib>=3.8; extra == 'jupyter'
Requires-Dist: pillow>=10; extra == 'jupyter'
Requires-Dist: pip>=24; extra == 'jupyter'
Description-Content-Type: text/markdown

# 3lc-compute-plugin-jupyter

JupyterLab with the 3LC Python package, as a plugin for the 3LC compute service.

The plugin's provisioned environment is the JupyterLab environment: JupyterLab, a Python kernel,
`tlc` (with pandas and the dimensionality reducers) and a multi-root file browser. From the Hub's
**JupyterLab** page (AI Tools) you start the server on your machine or on the GPU node chosen in
"Run on", and open it in a new tab.

## What you get

- **The 3LC environment as a notebook.** `TLC_API_KEY`, the project root URL and the cloud
  credentials are already in the environment, so `import tlc` opens tables and logs runs next to
  your other work. The card names the workspace's project root: that is where tables and runs go.
- **A plain working folder.** A folder on the machine the server runs on, with a README and a
  `Welcome to 3LC.ipynb`. It goes with a GPU node, so people keep notebooks in git; the lab has a
  terminal for `git` and `pip`. No bucket browser: git is how files come and go.
- **The 3LC tutorials in one click.** `github.com/3lc-ai/3lc-examples` cloned (`--depth 1`) into
  the working folder; "Update" pulls. Without git the archive of `main` is unpacked instead.
- **Billing-aware lifecycle.** The server shuts down after the chosen time without a running kernel
  (JupyterLab's own idle shutdown plus a watchdog), which ends the job, frees the node and lets
  the node's idle timer tear it down as usual. Stop in the Hub or the Queue does the same at once.
- **VS Code and Cursor.** The card shows the server URL with its token: paste it into
  *Jupyter: Specify Jupyter Server for Connections* and your editor's notebooks run in this
  environment.

## How it reaches the browser

JupyterLab needs WebSockets for its kernels, which the compute service's plugin proxy does not
carry, so the browser opens the server directly:

| Where the job ran | URL the Hub opens |
|---|---|
| this machine | `http://<compute host>:8888/lab?token=…` (first free port from 8888) |
| a GPU node | the node's worker URL template with port 8888 (AWS: `http://<ip>:8888`; RunPod: `https://<pod>-8888.proxy.runpod.net`) |

Port 8888 is opened on new nodes by the providers (`NODE_APP_PORTS` in the compute service). On
AWS the security group admits the controller's IP, which is the browser's IP when the controller
is your own machine.

## Layout

- `src/tlc_plugin_jupyter/plugin.toml` — manifest (`remote_capable = true`, `node_routes = ["/server"]`).
- `src/tlc_plugin_jupyter/server.py` — port choice, working folder, launch, status, stop, the tutorials clone.
- `src/tlc_plugin_jupyter/routes.py` — `GET /server/status`, `POST /server/stop`, `POST /server/tutorials`.
- `src/tlc_plugin_jupyter/ui.html` — the launcher card.

## Develop

```bash
uv sync --extra jupyter
uv run pytest
uvx --from 'ruff>=0.15,<0.16' ruff check . && uvx --from 'ruff>=0.15,<0.16' ruff format --check .
```

The integration test starts a real JupyterLab on a free port when the `jupyter` extra is installed.

## POC development and publishing

Staged 3LC builds (the 3lc core and SDK 0.5) resolve from the private staging index
(`pypi.3lc.ai/repositories/prereleases`), declared as the explicit `staging` index in
`pyproject.toml`; everything else comes from PyPI. Set only the index credentials in your shell
(keep them out of source files):

```bash
export UV_INDEX_STAGING_USERNAME="<staging index username>"
export UV_INDEX_STAGING_PASSWORD="<staging index token>"
uv sync --locked --group dev --extra jupyter
uv run --no-sync pytest
```

The Release workflow builds verified artifacts on manual runs. `publish=true` uploads them
to the private staging index (`prereleases`) using the `CLOUDREPO_USERNAME` /
`CLOUDREPO_PASSWORD` secrets; publishing is
disabled by default. The timestamp, run and
attempt suffix stamps the distribution and manifest together.

The separate `v*` tag path provides PyPI Trusted Publishing plumbing. Configure the PyPI
project's trusted publisher before using that path; no public release is needed during POC.
