Using Application variables in Application-as-recipe

sylvyr3
sylvyr3 Registered Posts: 21 ✭✭✭✭
edited July 16 in Using Dataiku

Hi,

I created a flow and converted it to an application-as-recipe. The application designer creates some default variables such as 'variable1'. How do I access these variables in my python recipes so that they can be used in the flow?

My typical approach to accessing project global variables is as such:

client = dataiku.api_client()
projectKey = dataiku.default_project_key()
proj = client.get_project(projectKey)
projVars = proj.get_variables()['standard']
thing1 = projVars['thing1']
thing2 = projVars['thing2']

After I figure out how to access, my next problem will be how do I incorporate it into my flow and still run my entire flow to test it if 'variable1' is supposed to be user input when they use the application as a recipe?

Best Answers

  • fchataigner2
    fchataigner2 Dataiker Posts: 355 Dataiker
    edited July 17 Answer ✓

    Hi,

    the "edit project variables" tile will add the values entered in the UI in the 'local' section of the project variables. This means:

    - you can put a value in the 'global' section of the variables in the project where you design the template, to have a default value to develop the app with

    - you can access the value in the app with

    v = dataiku.get_custom_variables()["variable1"]
    # or
    proj = dataiku.api_client().(dataiku.default_project_key())
    v = proj.get_variables()["local"]["variables1"]
    
  • AndrewS
    AndrewS Dataiker Posts: 3 Dataiker
    Answer ✓
    When creating applications, you have two general approaches for designing your interface - Visual Application and Application-As-Recipe. The two interfaces serve different purposes depending on how you want the end users to interact with your application.
    C9EAC0F3-E374-4DA0-842B-500F96BA4257.jpeg

    The Visual Applications is the one that uses tiles. It's a great option if you want others to be able to copy and use your project, but with a nicer UI. This option allows users to run the entire project, from beginning to end by clicking simple buttons and filling out fields (these are the tiles) instead of poking though a flow. One of these tiles allows users to 'edit project variables'. You can access these variables normally with python. This is available in DSS V8.
    64CF0013-6608-4F97-9B89-81970D7A5316.jpeg
    Application-As-Recipe allows you to turn your project into a recipe. It looks like this is what you are currently using. The interface and use of these applications is very similar to plugins. All of the parameters that the user enters automatically become project variables and can be accessed normally with python. This approach does not use tiles. 
    DEC6F371-9293-4E1B-99F3-3D304D6F38D3_4_5005_c.jpeg
    You can always change which type of interface you want to use in the 'Advanced' tab of your Application Designer.
    841A10B7-75EA-4689-A30D-DB1E88B19C19_4_5005_c.jpeg

Answers

Setup Info
    Tags
      Help me…