Discover this year's submissions to the Dataiku Frontrunner Awards and give kudos to your favorite use cases and success stories!READ MORE

Using a user input when running recipe

Ksawery
Level 1
Using a user input when running recipe

Hi,

I have a hardcoded variable in my recipe, a date, that has to be changed whenever I run the recipe. In a regular Python, I would ask a user for an input, using input() function. Is there a way to ask a user for an input in Dataiku whenever a recipe is run? 

0 Kudos
1 Reply
SarinaS
Dataiker
Dataiker

Hi @Ksawery,

One option is to create a variable in DSS and use that variable in your Python recipe, so that the Python recipe will always use the current version of the variable. You can also use a scenario to automatically set the variable prior to running your recipe. This method would work well if you are always running your recipe on a relative date (i.e. "yesterday"). This would allow you to fully automate the workflow. There is a good example of setting project variables from a scenario here and this walkthrough shows how to get project variables from within your Python code. 

Alternatively, it sounds like you might just want to allow the user to select the input parameter(s) for a recipe. If the above doesn't meet your use case, and you want a user to manually set the input parameter, an option that might work well for you is converting your recipe into a development plugin, which will then allow you to add parameters to your plugin that can be used in the plugin recipe. Once you create the custom recipe, the recipe can be selected and run like any plugin recipe in DSS. I would suggest going through this walkthrough for a good example of this workflow.  For example, here are the parameters a user can set when running the "geocoding plugin", which is a development plugin:

Screen Shot 2022-06-29 at 5.08.17 PM.png

So your custom recipe could behave like this as well, taking in some input parameters that you'll use in your Python recipe.

I hope that information is helpful. Please let me know if you have any other questions and some more details on your exact workflow if that would help as well.

Thank you,
Sarina 




0 Kudos