Code Options

Customize your Mito generated code by converting it to a function, selecting parameters and more.

Configuring Code Options

Adding code options allows you to configure the code to be generated in a way that works for your specific use-case. This includes options for generating the code as a function, and for including the imports from your code when adding custom python code.

Parameter
Type
Description

as_function

bool

If True, Mito generates a function. If False, Mito generates a script.

function_name

str

The name of the function Mito generates.

call_function

bool

If True the Mito generated code's last line will call the generated function.

function_params

Union[Dict[ParamName, ParamValue], ParamSubtype, List[ParamSubtype]]

A mapping from function parameter name to the original value used in the script.

import_custom_python_code

bool

If True, the Mito generated function will import custom importers and spreadsheet functions.

For example, if you want to generate a function named "my_function" that receives one input called file_path, you could use the following code options:

{
    'as_function': True, 
    'call_function': True, 
    'function_name': 'my_function', 
    'function_params': {'file_path': "original_data.csv"},
    'import_custom_python_code': False, 
}

Last updated

© Mito