[WEBAPP] How to run a scenario with a local variable

Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 4

I have a python recipe in my scenario working with a local variable.

I have succesfully executed my scenario within the webapp but :

How can I change the local variable from the webapp's code (in the Python back-end) ?

Welcome!

It looks like you're new here. Sign in or register to get started.

Best Answer

  • Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 319 Dataiker
    edited July 2024 Answer ✓

    Hi @Redouxne
    ,

    Are you using a scenario variable or a project variable? Indeed, for scenario variables, it's only possible to set them from within the context of a scenario.

    So, if you want to set a variable that will be used in a scenario but set it from a Webapp, you'll probably want to use a project variable instead. You can see the following code example for how to set a variable from the Python API, which can be run in the Python backend.

    import dataiku 
    client = dataiku.api_client()
    project = client.get_default_project()
    
    variables = project.get_variables()
    variables['standard']['some_variable'] = 'some_value'    
    project.set_variables(variables)


    Then, from your scenario you can obtain this variable in a Python step:

    import dataiku 
    client = dataiku.api_client()
    project = client.get_default_project()
    
    variables = project.get_variables()
    some_variable_value = variables['standard']['some_variable']


    Let me know if this approach doesn't work for you!

    Thank you,
    Sarina

Answers

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.