It can be registered as a function that can be executed in morph by annotating it with @morph.func.

@morph.func(
    name: str | None = None,
    description: str | None = None,
    output_paths: list[str] | None = None,
    output_type: Optional[
        Literal["dataframe", "csv", "visualization", "markdown", "json"]
    ] = None,
    **kwargs: dict[str, Any],
)
def func_name(context):
	# write your code here

Parameters

name
string
default: "function name"

Process name, can also be used as an alias when calling from another file.

description
string

Can describe the process

output_paths
array: string
default: "['_private/{name}/{now()}{ext()}']"

Output paths for the result files.

See here for description.

output_type
string

Specification of the format of the output results. If not specified, the system automatically estimates the result.

Values: dataframe, visualization, markdown, json

Example

@morph.func(
    name="example_python_cell",
    description="Example Python cell",
)
def get_data_from_database(context):
    # write your code here
	return pd.DataFrame({
        "name": ["John", "Doe"],
        "age": [20, 30],
    })