Survey banner
The Dataiku Community is moving to a new home! We are temporary in read only mode: LEARN MORE

Update Local Variable with Python

Solved!
mwmoren
Level 2
Update Local Variable with Python

I'm using python code to update variables from a dataset within an Application.  When the python code runs it is updating the Global variables by default.  Is there a way to specify for python to update the Local Variables and not the Global Variables?  

0 Kudos
1 Solution
tanguy

Try using dataiku's client api:

import dataiku

client = dataiku.api_client()
project = client.get_default_project()

# retrieve your project variables in a json which two first keys are 'standard' (which contains your project global variables) and 'local' (which contains your project local variables)
project_variables = project.get_variables()

my_local_variable_value = "foo"
project_variables['local']["my_local_variable"] = my_local_variable_value
project.set_variables(project_variables)

 

View solution in original post

2 Replies
tanguy

Try using dataiku's client api:

import dataiku

client = dataiku.api_client()
project = client.get_default_project()

# retrieve your project variables in a json which two first keys are 'standard' (which contains your project global variables) and 'local' (which contains your project local variables)
project_variables = project.get_variables()

my_local_variable_value = "foo"
project_variables['local']["my_local_variable"] = my_local_variable_value
project.set_variables(project_variables)

 

mwmoren
Level 2
Author

I've not seen the 'standard' vs 'local' documented anywhere else.  This was exactly what I needed. Thank you!!