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()

Modifying tags for a recipe

recipe = project.get_recipe('myrecipe')
settings = recipe.get_settings()

print("Current tags are %s" % settings.tags)

# Change the tags
settings.tags = ["newtag1", "newtag2"]

# If we changed the settings, we must save
settings.save()

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

dataikuapi.dss.recipe.DSSRecipe(client, ...)

A handle to an existing recipe on the DSS instance.

dataikuapi.dss.recipe.DSSRecipeListItem(...)

An item in a list of recipes.

dataikuapi.dss.recipe.DSSRecipeStatus(...)

Status of a recipe.

dataikuapi.dss.recipe.RequiredSchemaUpdates(...)

Handle on a set of required updates to the schema of the outputs of a recipe.

Settings

dataikuapi.dss.recipe.DSSRecipeSettings(...)

Settings of a recipe.

dataikuapi.dss.recipe.CodeRecipeSettings(...)

Settings of a code recipe.

dataikuapi.dss.recipe.SyncRecipeSettings(...)

Settings of a Sync recipe.

dataikuapi.dss.recipe.PrepareRecipeSettings(...)

Settings of a Prepare recipe.

dataikuapi.dss.recipe.SamplingRecipeSettings(...)

Settings of a sampling recipe.

dataikuapi.dss.recipe.GroupingRecipeSettings(...)

Settings of a grouping recipe.

dataikuapi.dss.recipe.SortRecipeSettings(...)

Settings of a Sort recipe.

dataikuapi.dss.recipe.TopNRecipeSettings(...)

Settings of a TopN recipe.

dataikuapi.dss.recipe.DistinctRecipeSettings(...)

Settings of a Distinct recipe.

dataikuapi.dss.recipe.PivotRecipeSettings(...)

Settings of a Pivot recipe.

dataikuapi.dss.recipe.WindowRecipeSettings(...)

Settings of a Window recipe.

dataikuapi.dss.recipe.JoinRecipeSettings(...)

Settings of a join recipe.

dataikuapi.dss.recipe.DownloadRecipeSettings(...)

Settings of a download recipe.

dataikuapi.dss.recipe.SplitRecipeSettings(...)

Settings of a split recipe.

dataikuapi.dss.recipe.StackRecipeSettings(...)

Settings of a stack recipe.

Creation

dataikuapi.dss.recipe.DSSRecipeCreator(type, ...)

Helper to create new recipes.

dataikuapi.dss.recipe.SingleOutputRecipeCreator(...)

Create a recipe that has a single output.

dataikuapi.dss.recipe.VirtualInputsSingleOutputRecipeCreator(...)

Create a recipe that has a single output and several inputs.

dataikuapi.dss.recipe.CodeRecipeCreator(...)

Create a recipe running a script.

dataikuapi.dss.recipe.PythonRecipeCreator(...)

Create a Python recipe.

dataikuapi.dss.recipe.SQLQueryRecipeCreator(...)

Create a SQL query recipe.

dataikuapi.dss.recipe.PrepareRecipeCreator(...)

Create a Prepare recipe

dataikuapi.dss.recipe.SyncRecipeCreator(...)

Create a Sync recipe

dataikuapi.dss.recipe.SamplingRecipeCreator(...)

Create a Sample/Filter recipe

dataikuapi.dss.recipe.DistinctRecipeCreator(...)

Create a Distinct recipe

dataikuapi.dss.recipe.GroupingRecipeCreator(...)

Create a Group recipe.

dataikuapi.dss.recipe.PivotRecipeCreator(...)

Create a Pivot recipe

dataikuapi.dss.recipe.SortRecipeCreator(...)

Create a Sort recipe

dataikuapi.dss.recipe.TopNRecipeCreator(...)

Create a TopN recipe

dataikuapi.dss.recipe.WindowRecipeCreator(...)

Create a Window recipe

dataikuapi.dss.recipe.JoinRecipeCreator(...)

Create a Join recipe.

dataikuapi.dss.recipe.FuzzyJoinRecipeCreator(...)

Create a FuzzyJoin recipe

dataikuapi.dss.recipe.GeoJoinRecipeCreator(...)

Create a GeoJoin recipe

dataikuapi.dss.recipe.SplitRecipeCreator(...)

Create a Split recipe

dataikuapi.dss.recipe.StackRecipeCreator(...)

Create a Stack recipe

dataikuapi.dss.recipe.DownloadRecipeCreator(...)

Create a Download recipe

dataikuapi.dss.recipe.PredictionScoringRecipeCreator(...)

Create a new Prediction scoring recipe.

dataikuapi.dss.recipe.ClusteringScoringRecipeCreator(...)

Create a new Clustering scoring recipe,.

dataikuapi.dss.recipe.EvaluationRecipeCreator(...)

Create a new Evaluate recipe.

dataikuapi.dss.recipe.StandaloneEvaluationRecipeCreator(...)

Create a new Standalone Evaluate recipe.

dataikuapi.dss.recipe.ContinuousSyncRecipeCreator(...)

Create a continuous Sync recipe

Utilities

dataikuapi.dss.utils.DSSComputedColumn()

dataikuapi.dss.utils.DSSFilter()

Helper class to build filter objects for use in visual recipes.

dataikuapi.dss.utils.DSSFilterOperator(*values)