Display a template on the UI

When creating a transform, you can display it on the UI. You can use this to expose parameters inside of the UI so that your transform can be used by non-technical users and work across projects.

Displaying the transformation using DataApp v3

To expose parameters on the UI, you must define each parameter and their properties in the second code block of your transform notebook. Each parameter makes a call to a call or create a function that takes a name which is the name can be used inside the flow file to pass variables into your transformation, metadata which is a dictionary that defines how the parameter will be used and displayed, and a local_context which will always be equal to locals().

Creating an input dataset

To add an input dataset to be used in your transformation, use the get_or_create_input_dataset method. Here is an example:

inputDatasetParameter = Helpers.get_or_create_input_dataset(
  name="inputDataset",
  metadata=Metadata(input_name='Input Dataset', is_required=True, tooltip='Dataset to apply the transformation'),
  local_context=locals()
)

The input dataset can then be used in your transform by using inputDatasetParameter.value

We recommend getting the input dataset value and assigning it to a variable, like the following:

inDF = Helpers.getEntityData(context, inputDatasetParameter.value)

Required metadata fields: input_name, is_required, tooltip

Creating an input variable

To add an input variable to be used in your transformation, use the get_or_create_input_var method. Here is an example:

start_dateParameter = Helpers.get_or_create_input_var(
    name="start_date",
    metadata=Metadata(input_name="Start Date", is_required=True, tooltip="Initial date to do the diff", multiple=False, datatypes=['TIMESTAMP'], options=['FIELDS', 'CONSTANT'], dataset=['inputDataset']),
    local_context=locals()
)

Then, the variable can be used in your transform by using start_dateParameter.value

Required metadata fields: input_name, is_required, tooltip, multiple, datatypes, options

Creating an output dataset parameter

To give users the ability to define the name of an output dataset, use the get_or_create_output_dataset method. Here is an example:

outputDatasetParameter = Helpers.get_or_create_output_dataset(
  name="outputDataset",
      metadata=Metadata(input_name='Output Dataset', is_required=True, tooltip='Dataset name to be created after the transformation'),
      local_context=locals()
)

The output dataset name given by the user can then be accessed by using outputDatasetParameter.value Required metadata fields: input_name, is_required, tooltip

Creating an output chart

To give users the ability to name the output charts, use the get_or_create_output_chart method. Example:

outputChartParameter=Helpers.get_or_create_output_chart(
    name="outputChart",
    metadata=Metadata(input_name='Output Chart Name', is_required=True, tooltip='Name of the output chart'),
    local_context=locals()
)

The name of the output chart given by the user is then accessed inside the transform notebook using outputChartParameter.value

Required metadata fields: input_name, is_required, tooltip

| Field            | Description                                                                                                                                                                                                                                                                                                                                                                                                                    |
|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| default_value    | Value that will be used if the user does not enter any input for the parameter.                                                                                                                                                                                                                                                                                                                                                |
| input_name       | Name of the parameter to be displayed on the UI                                                                                                                                                                                                                                                                                                                                                                                |
| datatypes        | List that limits the datatypes accepted by the parameter to any of STRING LONG DOUBLE BOOLEAN TIMESTAMP or ALL                                                                                                                                                                                                                                                                                                                 |
| options          | List that defines what the data input options are. They can be FIELDS or CONSTANT or both. Fields allows a user to select a column/field from the dataset defined by the datasets . If you choose FIELDS for options, you must define the datasets from which the user can select the columns. If CONSTANT is used, you can add a list of the possible options that users can choose from by defining the constant_options |
| constant_options | List of options that you want presented to the user. See options above                                                                                                                                                                                                                                                                                                                                                         |
| datasets         | List of datasets that will be used to populate field/column options. See options above                                                                                                                                                                                                                                                                                                                                         |
| tooltip          | Description of the input parameter. This will be displayed to the user when they click on a �” icon. Here is where you should clearly and concisely describe the parameter and how it will be used. It is best to keep it to a sentence or two.                                                                                                                                                                            |
| is_required      | Boolean value that defines whether or not the value is needed for your transformation                                                                                                                                                                                                                                                                                                                                          |
| multiple         | Boolean value that defines whether or not a user can select multiple values for the input parameter.                                                                                                                                                                                                                                                                                                                           |