Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Hi,
How can we create global variable in prepare recipe or scenarios ?
Thanks
Hi,
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)
Thanks Alex for response.
Could you please help let me if we can create global variable at scenario (schedule the job) or at visual receipe level
Thanks
Dheerendra
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 :
https://doc.dataiku.com/dss/latest/variables/index.html
Many Thanks Alex!!!