10 · Code mount
The "your local imports just work on the worker" story. On submit, the SDK archives the current git tree, uploads it under a content-addressed key, and stamps the archive onto the envelope. A worker that cannot import your module fetches and extracts the archive, then retries the import.
Exercises
HttpDispatch.push_code()— called automatically byUDF.submitfor reference-transport functions when the plane has a code channel.code_archive.push_if_needed—git archive HEAD→ presigned PUT on thecode-stagingstorage → register onPOST /v1/namespaces/:ns/code-repos.lakeshore code push/lakeshore code list— the same channel, by hand.- Worker-side: fetch by
archiveKey, extract under$LAKESHORE_HOME/code/<commit>, prepend tosys.path, re-import. - Dedup: a
(remote, commit)already registered on the control plane is never re-uploaded, and the worker reuses an already-extracted commit.
Requires
- Everything in 05 · Hello, queue-bound UDF,
against a control plane (
--url/LAKESHORE_URL). The local SQLite plane has no code channel — it assumes a shared filesystem. - Everything in 09 · Storage round-trip:
a storage entry named
code-stagingfor the archives. - A git repository with a clean working tree.
git archive HEADships committed content only;push_if_neededreturnsNoneon a dirty tree unless it is called withallow_dirty=True(lakeshore code push --dirty).
Verifies
A @udf whose module is not installed on the worker still runs there:
the worker's ImportError triggers a fetch of the submitted archive and
the import succeeds on the retry.
Run
Push the archive explicitly and confirm it registered:
Then submit against the control plane, from inside the repo:
with a worker running on the same plane:
lakeshore-examples/_legacy/11-code-mount exercises the archive channel
through lakeshore exec, not through @udf. It is still a valid check
of the upload half; the worker-side import path is exercised by the SDK
submit above.
Expected output
The UDF's return value comes back, and the worker imported a module it did not have on disk when it started. The first submit on a new commit uploads (slow); a second submit on the same commit skips the upload entirely — that is the dedup signal.
If it fails
| Symptom | Likely cause |
|---|---|
WorkerError: cannot import module ... | No archive was stamped on the envelope. Dirty working tree, not a git repo, or the plane is the local SQLite one (no code channel). Commit, then resubmit. |
| Your edits do not take effect on the worker | git archive HEAD ships committed content only — uncommitted changes never travel. |
WorkerError: ... source differs from the submitted version | The worker resolved a different revision of the function. Update its checkout, or pass --runtime-policy off for same-machine dev. |
| Upload fails or hangs | The code-staging storage entry is missing or its credentials are wrong. lakeshore code push shows the raw failure. |
| Slow on every run (no dedup) | The commit changed every run (amend/rebase loop), or the worker's LAKESHORE_HOME/code cache is not persistent. |
Status
Manual.