reports.py
summarize_sales.remote([...]) is
the same call from Python, async_remote() its async form, and a plain
summarize_sales(...) runs locally;
Where a call goes covers previews and
deployments. A function fits batch jobs, background
work, and GPU tasks that your code or a person calls; HTTP callers suit an
endpoint, and recurring runs a
schedule.
Run many inputs at once
.map() submits one call per input and yields results in input order. Each
tuple holds one call’s arguments:
None. When every item must succeed before you use the
batch, spawn_map() returns each outcome to check:
.map() over 1,000 texts now runs on up to 20 containers at once.
max_pending_tasks goes up because .map() submits every input at once. See
Scaling and the
video highlights example.
Submit work in the background
.spawn() returns a FunctionCall right away, and .get() waits for the
value. uv run lazycloud task result <task-id> collects it from anywhere else,
and a pending FunctionCall passed to another function arrives as its result.
Tasks and logs covers looking calls up by ID.
Pass arguments and read results
Calls from the Python SDK carry any serializable Python value, including NumPy arrays, dataclasses, custom class instances, tuples, and bytes:lazycloud run --json, and
exported clients
need JSON, which Pydantic models and dataclasses convert to. Arguments and
results cap at 16 MiB each, so larger output goes in a
volume or an artifact.
Retry a failed call
timeout_seconds caps one attempt and retries, 3 by default, adds attempts
after a failure; see Timeouts and retries.
Load a model once per container
on_start runs once before a container accepts calls, which suits loading a
model or opening a client:
on_running, on_success,
on_error, on_retry, on_failure, and on_finish. lazycloud.current_task_id() returns the
current call’s ID inside the function or a hook.
Stop a function
lazycloud task cancel cancels a pending call and task stop a running one. A
deployed function stays callable until stopped:
stop keeps the definition for deployment start.
--prune removes a function deleted from
the code.
