DreamLake

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:

1. Install the SDK

Use Python 3.11 or newer:

bash
pip install dreamlake-lakeshore

This example uses the SDK's local SQLite queue. In the shell where you will run it, unset any remote server setting:

bash
unset LAKESHORE_URL

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:

hello_udf.pypython
import dreamlake.lakeshore as dls

@dls.udf(queue="quickstart-hello")
def add(a: int, b: int) -> int:
    return a + b

if __name__ == "__main__":
    q = dls.SyncQueue("quickstart-hello")
    inv = add.submit(2, 3)
    print("invocation:", inv)

    dls.run_worker(q, once=True)
    print("result:", q.result(inv, timeout=30.0))
bash
python 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:

bash
export LAKESHORE_URL="https://lakeshore.example.com"
export LAKESHORE_NAMESPACE="lab"
export LAKESHORE_CLIENT_TOKEN="your-client-token"

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