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

@morph.variables(
    var_name: str,
	default: Optional[Any] = None,
	required: Optional[bool] = False,
    type: Optional[Literal["str", "bool", "int", "float", "dict", "list"]] = 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.

required
bool
default:"False"

You can specify whether the item is required.

If it is set to required, an error will occur if it is not specified.

type
string
default:"None"

You can specify the type of the variable.

If not specified, the type will be inferred automatically.

How to Use

@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({})