By adding the @morph.func annotation, you can register the function to be executed with morph.

@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,
    result_cache_ttl: int = 0,
)
def func_name(context):
	# write your code here

Parameters

name
string
default:
"Function name"

The name of the process, which can also be used as an alias when called from other files.

description
string

A description of the process can be written.

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

The output destination of the result file.

Refer to here for the description method.

output_type
string

Specifies the format of the output result. If not specified, the system will automatically infer it.

Values: dataframe, visualization, markdown, json

result_cache_ttl
integer
default:
"0"

Specifies the cache expiration time of the data pipeline execution result in seconds.

使用例

@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],
    })