New to Dataiku DSS? Try out our NEW Quick Start Programs today and get onboarded on the product in just one hour! Let's go

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
Dataiker
Dataiker

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

3 Replies
Clément_Stenac
Dataiker
Dataiker

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

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
New User

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

0 Kudos
A banner prompting to get Dataiku DSS