Recipes¶
This page lists usage examples for performing various operations with recipes through Dataiku Python API.
In all examples, project is a dataikuapi.dss.project.DSSProject handle,
obtained using get_project() or get_default_project()
Basic operations¶
Listing recipes¶
recipes = project.list_recipes()
# Returns a list of DSSRecipeListItem
for recipe in recipes:
# Quick access to main information in the recipe list item
print("Name: %s" % recipe.name)
print("Type: %s" % recipe.type)
print("Tags: %s" % recipe.tags) # Returns a list of strings
# You can also use the list item as a dict of all available recipe information
print("Raw: %s" % recipe)
Deleting a recipe¶
recipe = project.get_recipe('myrecipe')
recipe.delete()
Recipe creation¶
Please see Flow creation and management
Recipe status¶
You can compute the status of the recipe, which also provides you with the engine information.
Find the engine used to run a recipe¶
recipe = project.get_recipe("myrecipe")
status = recipe.get_status()
print(status.get_selected_engine_details())
Check if a recipe is valid¶
get_status() calls the validation code of the recipe
recipe = project.get_recipe("myrecipe")
status = recipe.get_status()
print(status.get_selected_engine_details())
Find the engines for all recipes of a certain type¶
This example shows how to filter a list, obtain DSSRecipe objects for the list items, and getting their status
for list_item in project.list_recipes():
if list_item.type == "grouping":
recipe = list_item.to_recipe()
engine = recipe.get_status().get_selected_engine_details()["type"]
print("Recipe %s uses engine %s" % (recipe.name, engine))
Recipe settings¶
When you use get_settings() on a recipe, you receive a settings object whose class depends on the recipe type. Please see below for the possible types.
Checking if a recipe uses a particular dataset as input¶
recipe = project.get_recipe("myrecipe")
settings = recipe.get_settings()
print("Recipe %s uses input:%s" % (recipe.name, settings.has_input("mydataset")))
Replacing an input of a recipe¶
recipe = project.get_recipe("myrecipe")
settings = recipe.get_settings()
settings.replace_input("old_input", "new_input")
settings.save()
Setting the code env of a code recipe¶
recipe = project.get_recipe("myrecipe")
settings = recipe.get_settings()
# Use this to set the recipe to inherit the project's code env
settings.set_code_env(inherit=True)
# Use this to set the recipe to use a specific code env
settings.set_code_env(code_env="myenv")
settings.save()
Reference documentation¶
List and status¶
|
A handle to an existing recipe on the DSS instance. |
An item in a list of recipes. |
|
Status of a recipe. |
|
Handle on a set of required updates to the schema of the outputs of a recipe. |
Settings¶
Settings of a recipe. |
|
Settings of a code recipe. |
|
Settings of a Sync recipe. |
|
Settings of a Prepare recipe. |
|
Settings of a sampling recipe. |
|
Settings of a grouping recipe. |
|
Settings of a Sort recipe. |
|
Settings of a TopN recipe. |
|
Settings of a Distinct recipe. |
|
Settings of a Pivot recipe. |
|
Settings of a Window recipe. |
|
Settings of a join recipe. |
|
Settings of a download recipe. |
|
Settings of a split recipe. |
|
Settings of a stack recipe. |
Creation¶
|
Helper to create new recipes. |
Create a recipe that has a single output. |
|
|
Create a recipe that has a single output and several inputs. |
Create a recipe running a script. |
|
Create a Python recipe. |
|
Create a SQL query recipe. |
|
Create a Prepare recipe |
|
Create a Sync recipe |
|
Create a Sample/Filter recipe |
|
Create a Distinct recipe |
|
Create a Group recipe. |
|
Create a Pivot recipe |
|
Create a Sort recipe |
|
Create a TopN recipe |
|
Create a Window recipe |
|
Create a Join recipe. |
|
Create a FuzzyJoin recipe |
|
Create a GeoJoin recipe |
|
Create a Split recipe |
|
Create a Stack recipe |
|
Create a Download recipe |
|
Create a new Prediction scoring recipe. |
|
Create a new Clustering scoring recipe,. |
|
Create a new Evaluate recipe. |
|
|
Create a new Standalone Evaluate recipe. |
Create a continuous Sync recipe |
Utilities¶
Helper class to build filter objects for use in visual recipes. |
|
