By global variables,
I assume you mean instance-level variables correct? These can be set using the dssclient.set_variables. This requires admin permissions.
import dataiku from dataiku import pandasutils as pdu import pandas as pd client = dataiku.api_client() global_variables = client.get_variables() global_variables["today_year"] = "2021" client.set_variables(global_variables) #validate for testing only global_variables = client.get_variables() print(global_variables)
For project global variables these need to be set with the following and global variables which are referred to as "standard" variables there are also local variables, which are not included in bundles.
import dataiku from dataiku import pandasutils as pdu import pandas as pd client = dataiku.api_client() project = current_project = client.get_project(dataiku.default_project_key()) project_variables = project.get_variables() #set global project variables project_variables ['standard']['new_var_name'] = 'value' #set local project variables project_variables ['local']['new_var_name'] = 'value' project.set_variables(project_variables) #validate for testing only variables = project.get_variables() print(variables)
Yes, you can also add global variables, project and scenario variables via a scenario step. As seen below. Visual recipe would not set global variables but they can be used by visual recipes see :