You can declare variables passed from outside with the @morph.variables annotation.

@morph.variables(
    var_name: str, default: Optional[Any] = None
)
def func_name(context):
	# write your code here

Parameters

var_name
string
required

You can add arguments when executing the function.

You can pass arguments from the mdx file or specify arguments when executing the command.

default
any

You can set a default value.

If not specified, the default value will be None.

使用例

@morph.func
@morph.variables("var1")
def get_data_from_database(context):
	var1_data = context.vars["var1"]
    # write your code here using var1_data
	return pd.DataFrame({})