Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Hello !
I read on the documentation that global variables can be dynamically modified at project run by auto execution the get_variables() code defined in Administration / Variables Automatic update code.
It seems nice but as I see it is Jython only, is there any way to use some contextual data like custom variables / user property / username / etc from there ?
Thanks in Advance !
Antoine
Hi @agardenat,
You won't be able to access that information using the automatic update code since it uses Jython.
As an alternative, you could use Python code in a scenario to set the global variables. This uses regular Python, so you have full access to Python modules.
Preview of the scenario:
Example code that sets the "my_var" global variable:
from dataiku.scenario import Scenario
scenario = Scenario()
scenario.set_global_variables(
my_var="foo"
)
Reference documentation: Scenarios (in a scenario)
Thanks,
Zach
Hi @ZachM
Thanks for your answer.
I sure can do that, but I will miss the "automatic" part which made it transparent, with no need to add code to scenarios.
Thanks,
Antoine
Hi @agardenat,
You can update the variables automatically by adding a trigger to the scenario. For example, a time-based trigger will cause the variables to be updated on a schedule, such as once every day.
Reference: Scenario Triggers.