Ops
API for implementing LynxKite operations.
LongStr
module-attribute
¤
LongStr is a string type for parameters that will be displayed as a multiline text area in the UI.
Op
¤
Parameter
¤
Bases: BaseConfig
Defines a parameter for an operation.
ParameterGroup
¤
Bases: BaseConfig
Defines a group of parameters for an operation.
Position
¤
Bases: str
, Enum
Defines the position of an input or output in the UI.
Result
dataclass
¤
Represents the result of an operation.
The output
attribute is what will be used as input for other operations.
The display
attribute is used to send data to display on the UI. The value has to be
JSON-serializable.
input_metadata
is a list of JSON objects describing each input.
get_optional_type
¤
For a type like int | None
, returns int
. Returns None
otherwise.
input_position
¤
Decorator for specifying unusual positions for the inputs.
Example usage:
@input_position(a="bottom", b="bottom")
@op("test", "maybe add")
def maybe_add(a: list[int], b: list[int] | None = None):
return [a + b for a, b in zip(a, b)] if b else a
load_user_scripts
¤
Reloads the *.py in the workspace's directory and higher-level directories.
make_async
¤
Decorator for slow, blocking operations. Turns them into separate threads.
matplotlib_to_image
¤
Decorator for converting a matplotlib figure to an image.
op
¤
Decorator for defining an operation.
op_registration
¤
Returns a decorator that can be used for registering functions as operations.
output_position
¤
Decorator for specifying unusual positions for the outputs.
Example usage:
@output_position(output="top")
@op("test", "maybe add")
def maybe_add(a: list[int], b: list[int] | None = None):
return [a + b for a, b in zip(a, b)] if b else a
parse_doc
cached
¤
Griffe is an optional dependency. When available, we return the parsed docstring.
passive_op_registration
¤
Returns a function that can be used to register operations without associated code.
register_executor
¤
Decorator for registering an executor.
The executor is a function that takes a workspace and executes the operations in it.
When it starts executing an operation, it should call node.publish_started()
to indicate
the status on the UI. When the execution is finished, it should call node.publish_result()
.
This will update the UI with the result of the operation.
register_passive_op
¤
A passive operation has no associated code.