Writing Local Project Variables from a Senario

Options
tgb417
tgb417 Dataiku DSS Core Designer, Dataiku DSS & SQL, Dataiku DSS ML Practitioner, Dataiku DSS Core Concepts, Neuron 2020, Neuron, Registered, Dataiku Frontrunner Awards 2021 Finalist, Neuron 2021, Neuron 2022, Frontrunner 2022 Finalist, Frontrunner 2022 Winner, Dataiku Frontrunner Awards 2021 Participant, Frontrunner 2022 Participant, Neuron 2023 Posts: 1,595 Neuron

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

Tagged:

Answers

  • Zach
    Zach Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 153 Dataiker
    edited July 17
    Options

    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

  • tgb417
    tgb417 Dataiku DSS Core Designer, Dataiku DSS & SQL, Dataiku DSS ML Practitioner, Dataiku DSS Core Concepts, Neuron 2020, Neuron, Registered, Dataiku Frontrunner Awards 2021 Finalist, Neuron 2021, Neuron 2022, Frontrunner 2022 Finalist, Frontrunner 2022 Winner, Dataiku Frontrunner Awards 2021 Participant, Frontrunner 2022 Participant, Neuron 2023 Posts: 1,595 Neuron
    Options

    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.

Setup Info
    Tags
      Help me…