Submit your innovative use case or inspiring success story to the 2023 Dataiku Frontrunner Awards! LET'S GO

Writing Local Project Variables from a Senario

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

0 Kudos
2 Replies

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")




0 Kudos

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



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.

0 Kudos