All docs
API Reference
Context
StepContext and Context are what LSD injects into your functions — progress, cancellation, outputs, plus the host, engine, project, and UI slots.
StepContext and Context are injected parameters — annotate one and LSD hands it to your
function. StepContext (inside a step's run) exposes only cache-neutral capabilities —
progress, cancellation, side outputs, scratch dirs — deliberately, so a step can't read state the
resume-cache key cannot see. Context (inside a command, action, or view) is the one discoverable
handle on the running application. Neither is part of the cache key, so touching them never
invalidates a cached result.
Usage#
Python
from lsdtools import Tool, Table, StepContext
tool = Tool("demo")
@tool.shape
def slow(t: Table, ctx: StepContext) -> Table:
ctx.progress(0.5, "halfway")
return t
# → ctx is injected at run time, excluded from the cache key
Where to start#
Learn — Parameters vs ports · Commands & actions
Examples — Live node metrics · A CLI command
Properties
- cancelled true once cancellation is requested for this run
- engine the live engine for the open project
- entity the entity in scope for this call, if any
- entity_id the owning entity's id, or None for a loose step
- events the running app's event bus, to subscribe or emit
- host the package host that mounted the tool
- output_dir the step's durable output directory
- panel the View this call originates from (a location=sidebar form)
- project the open project handle
- scratch_dir a private per-run temporary directory, created lazily
- selection the user's current selection, if any
- step_id the running step's id, for keying emitted events
- ui the ui surface for notify, show, confirm, open_panel
- viewer the 3d/2d viewer surface, if a viewer is open
Class methods
- testing build a fake context for unit tests
Methods
- emit emit a custom, mid-run event on the engine bus as a cache-neutral side effect
- progress reports run progress from 0 to 1 with an optional message
- set_output record a read-only graph-scalar output on the node card
By LSD Team · Last updated Jul 18, 2026
Ask on Discord
View as Markdown