Writing Local Project Variables from a Senario

tgb417
Writing Local Project Variables from a Senario

Is it possible to write a local project variable (rather than a global project variable) from within a Scenario? 

I have variable values which are calculated during a scenario run that are only useful for a particular project on a particular instance of Dataiku DSS.  These are needed outside the scope of a Scenario in case a user wants to open a visual recipe outside of the context of a Scenario.  These variables need to exist for that use case.

I'd prefer to make these local project variables rather than local project variables.  However, from within a project scenario when I set project variables they are set as global project variables.  Is there a special syntax for setting local project variables?


Operating system used: Mac OS Ventura 13.0.1

--Tom
0 Kudos
2 Replies
ZachM
Dataiker

Hi @tgb417,

You can set local project variables in a scenario by using an "Execute Python code" step with the below code:

import dataiku

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

project.update_variables({"my_local_var": "foo"}, type="local")

 

Thanks,

Zach

0 Kudos
tgb417
Author

This little bit being the "magic" to get it into a local variable.

type="local"

 Thanks.

Now all I have to do is also figure out how to get dataset metrics in Python.  I've worked this out in the formula language so far.

--Tom
0 Kudos