Update Local Variable with Python

mwmoren
mwmoren Dataiku DSS Core Designer, Registered Posts: 5

I'm using python code to update variables from a dataset within an Application. When the python code runs it is updating the Global variables by default. Is there a way to specify for python to update the Local Variables and not the Global Variables?

Best Answer

  • Tanguy
    Tanguy Dataiku DSS Core Designer, Dataiku DSS & SQL, Dataiku DSS ML Practitioner, Dataiku DSS Core Concepts, Neuron, Dataiku DSS Adv Designer, Registered, Dataiku DSS Developer, Neuron 2023 Posts: 115 Neuron
    edited July 17 Answer ✓

    Try using dataiku's client api:

    import dataiku

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

    # retrieve your project variables in a json which two first keys are 'standard' (which contains your project global variables) and 'local' (which contains your project local variables)
    project_variables = project.get_variables()

    my_local_variable_value = "foo"
    project_variables['local']["my_local_variable"] = my_local_variable_value
    project.set_variables(project_variables)

Answers

Setup Info
    Tags
      Help me…