Quick start
Submit a Python function, run a worker, and read the result. Start with a local queue so your first run needs only Python; then connect the SDK to a service.
Choose the guide for what you want to do:
- Run a function: continue below.
- Host a server: Setting Up Lakeshore Service.
- Add an existing service to DreamLake: Connect Lakeshore to DreamLake.
1. Install the SDK
Use Python 3.11 or newer:
This example uses the SDK's local SQLite queue. In the shell where you will run it, unset any remote server setting:
No server, access token, or CLI is needed for this first run. Queue state is stored under ~/.lakeshore by default.
2. Submit, execute, and read the result
Save this complete example as hello_udf.py:
Expect an invocation ID followed by result: 5.
The worker runs in the same process for this first example. The order matters: submit the work, let a worker execute it, then read the result. Waiting for a result with no worker running will time out.
While developing the function itself, add.local(2, 3) calls it directly without a queue or worker.
3. Use an existing Lakeshore service
Get the HTTPS URL, namespace, and client token from the service administrator. If you are the administrator, set up the service first.
Set these values before starting your Python process:
Submissions now go to that service. Arrange for a Python worker to drain the same queue, using the same server, namespace, and token. Worker machines also need the function's code and dependencies. See Simple functions for function transport and execution patterns.
The example above runs its worker in the submitting process; changing the URL alone does not move execution to another machine.
The SDK reads these environment variables for dispatch, independently of the Lakeshore CLI's saved login. Connecting the service to DreamLake is a separate step for viewing the service through DreamLake.
Next steps
- Simple functions: function bodies, submission, and results.
- Queues: scheduling and workers.
- Local dev loop: run the full stack for development.