Using Application variables in Application-as-recipe

Solved!
sylvyr3
Level 3
Using Application variables in Application-as-recipe

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?  

0 Kudos
2 Solutions
fchataigner2
Dataiker

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"]

View solution in original post

0 Kudos
AndrewS
Dataiker
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
 

View solution in original post

0 Kudos
6 Replies
fchataigner2
Dataiker

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"]
0 Kudos
sylvyr3
Level 3
Author

Is the 'edit project variables' tile a DSS 9.0 feature?  I'm on DSS 8 so may not have access to that feature.

0 Kudos
AndrewS
Dataiker
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
 
0 Kudos
krillin
Level 2

how to do it in R programming?

 

0 Kudos
krillin
Level 2

Can i get the solution R language?

 

 

0 Kudos
krillin
Level 2

I have created a global variable i want to update the value of variable in the R recipe how can i do that?

 

0 Kudos