# 01 · Hello, local Python

The leaf node. If the SDK is not importable or the decorator is broken,
nothing above this can be green. Two minutes, no infrastructure.

## Exercises

- The Python SDK install path (uv / pip / editable).
- `@dls.udf` semantics — a bare `@udf` (no `queue=`) runs the decorated
  function in-process on a direct call.
- The always-local escape hatch: `train.local(...)` bypasses any queue
  binding, so test code stays stable when the decorator later gains one.

## Requires

- A Python ≥ 3.11 environment with `dreamlake-lakeshore` importable.
- That is it. No control plane, no daemon, no network — the local tier
  does not even import httpx or msgpack.

## Verifies

The SDK as a leaf node. It imports cleanly, the decorator wraps without
error, and the function executes and returns its value verbatim.

## Run

```bash
cd lakeshore-examples/02-hello-local-python
uv run train.py
```

`train.py` carries inline script metadata whose `[tool.uv.sources]` block
pins `dreamlake-lakeshore` to the `../../lakeshore-py` checkout as an
editable install — so this runs the local source tree, not PyPI. To
exercise the published package instead, delete that block from the
script header; the sibling `pyproject.toml` declares
`dreamlake-lakeshore>=0.3.7`.

Plain pip works too:

```bash
pip install -e lakeshore-py     # or: pip install dreamlake-lakeshore
python lakeshore-examples/02-hello-local-python/train.py
```

## Expected output

```text
{'seed': 42, 'loss': 0.6394267984578837}
{'seed': 7, 'loss': 0.32383276483316237}
{'seed': 1, 'loss': 0.13436424411240122}
```

Three dicts, deterministic across runs because the example seeds
`random`. The third line comes from `train.local(seed=1)`.

## If it fails

| Symptom | Likely cause |
| ------- | ------------ |
| `ModuleNotFoundError: No module named 'dreamlake'` | The SDK is not in the active environment. Use `uv run --with-editable lakeshore-py ...` or `pip install -e lakeshore-py`. Note the install name is `dreamlake-lakeshore`, the import path `dreamlake.lakeshore`. |
| `TypeError` on the decorator | An SDK version mismatch — the example declares `dreamlake-lakeshore>=0.3.7`. Bump or pin. |
| Different `loss` values | Check that the example still seeds `random` before each call. The shape is what matters. |

## Status

Runs in the example smoke set; refresh `/test-results.json` via
`uv run lakeshore-examples/test_runner.py`.

## Next

→ [02 · Hello, hosted control plane](/cli/happy-paths/02-hello-hosted-cp.md)
