global variable update

Solved!
alepicca
Level 2
global variable update

Hi,

I need to set an automatic update of some date variables (the update is going to be recursive; each month it is going to add a month), which then will be used in a SQL receipts flow.

At the moment my solution is to create a date variable (dictionary containing the desired dates) and a Python script (inside a Python Notebook) that perform the update of the element of the dictionary, giving as output a dictionary of updated dates (formatted as unicode and so which can be used in the SQL receipt). I will then run the script and the SQL flow in a scenario, running each month.

The only thing I am missing is how to save back the dictionary into a project variable, inside the Python script.

Does such a function exist? Am I using a correct strategy?

Thank you very much for your help.

Regards,

 

Alessandro

1 Solution
Clรฉment_Stenac

Hi,

Assuming that you want to update the variable "stuff" in your project, use the following code:

import dataiku

client = dataiku.api_client()
project = client.get_project("MYPROJECT")

variables = project.get_variables()
variables["standard"]["stuff"] = "my new value for stuff variable"
project.set_variables(variables)

View solution in original post

4 Replies
Clรฉment_Stenac

Hi,

Assuming that you want to update the variable "stuff" in your project, use the following code:

import dataiku

client = dataiku.api_client()
project = client.get_project("MYPROJECT")

variables = project.get_variables()
variables["standard"]["stuff"] = "my new value for stuff variable"
project.set_variables(variables)
alepicca
Level 2
Author

Thank you very much; it worked and I got the update I was looking for.

 

Kind regards,

Alessandro

0 Kudos
psvnm
Level 2

Hi, your solution works in python recipe. Can you please suggest me the same solution in SQL recipe?

0 Kudos
Arnabg_ab
Level 1

how can i find the value of  "my new value for stuff variable"?

0 Kudos