When you configure components in Machine Learning Platform for AI (PAI), you can use global variables to reduce the workload of repeat parameter configurations. You can create and delete global variables. You can also use the configuration copy feature to obtain the reference methods of global variables. This topic describes how to configure and use global variables.
Scenarios
Multiple components in a pipeline use the same parameters.
For more information, see Example 1: Configure the parameters that are used by all the components in a pipeline.
You want to replace scheduling parameters.
For more information, see Example 2: Replace scheduling parameters.
Prerequisites
A pipeline is created. For more information, see Overview.
Go to the global variable configuration page
Go to the Visualized Modeling (Designer) page.
Log on to the PAI console.
In the left-side navigation pane, click Workspaces. On the Workspaces page, click the name of the workspace in which you want to configure global variables.
In the left-side navigation pane, choose
to go to the Visualized Modeling (Designer) page.
On the Pipelines tab, double-click the created pipeline. The configuration tab of the pipeline appears.
On the Global Variables tab in the right-side pane of the canvas, click Add Global Variable and add global variables in sequence. You must specify the name and value for each global variable.
Example 1: Configure the parameters that are used by all the components in a pipeline
The Heart Disease Prediction pipeline is used in this example. You can use global variables to replace parameter settings when you configure parameters. Global variables can also be used for the components that use the same parameters.
Configure a global variable.
Set the Variable Name and Variable Value parameters.
In this example, Variable Name is set to param, and Variable Value is set to cp,fbs. Then, the system automatically generates the ${param} reference method. If you replace a parameter with ${param}, you can reference this variable.
Use the global variable.
Replace a parameter with the reference method of the variable to use the variable. The reference method is generated based on the value of the Variable Name parameter for this variable.
Check whether the parameter value is automatically replaced with the value of the variable.
Example 2: Replace scheduling parameters
Global variables can also be used to schedule pipelines associated with dates. In a PAI pipeline, the configured values for global variables can only be used to run the pipeline online. If scheduling is performed offline, the parameter values that you configured for scheduling are used. In this example, the source data of the pipeline contains the data of two partitions.
Prepare source data.
Configure a global variable.
For more information, see Example 1: Configure the parameters that are used by all the components in a pipeline. In this example, Variable Name is set to date, and Variable Value is set to 20190520.
Use the global variable in the SQL Script component.
Run the pipeline online to obtain the generated results.
Use the global variable to configure offline scheduling.
NoteFor more information, see Use DataWorks tasks to schedule pipelines in Machine Learning Designer.
Go to the offline scheduling page.
When you go to the offline scheduling page, you are asked to configure a parameter that has the same name as the global variable that you want to use.
Use the global variable in an offline scheduling task.
Run the scheduling task and view the results.
The scheduling results show that the scheduling task replaces the parameter value with 20190519.