Create plugin recipe between existing dataset and folder

Tomas
Tomas Registered, Neuron 2022 Posts: 121 ✭✭✭✭✭

Hi,

does anybody has an experience with creating plugin recipes using PythonAPI?

According to the docs many different types of recipes can be created using Builder classes but cannot find plugin there.

https://doc.dataiku.com/dss/latest/python-api/recipes.html

Created manually the recipe and then tried to create a new recipe with the same type, but this approach does not work

builder = prj.new_recipe("CustomCode_csv-exporter")
! fails here, builder is None
builder.with_input("abt_dataset")
builder.with_output("5CHNNNwg")
builder.create()

Best Answer

  • Vitaliy
    Vitaliy Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer Posts: 102 Dataiker
    Answer ✓
    There are no special methods available to create a custom plugin-type recipe, and as you already noted project.new_recipe() method can't be used.
    With below code example, you will be able to create a plugin's recipe:
    import dataiku
    client = dataiku.api_client()
    project = client.get_default_project()
    from dataikuapi.dss.recipe import SingleOutputRecipeCreator

    class MyRecipeCreator(SingleOutputRecipeCreator):
    def __init__(self, name, project):
    SingleOutputRecipeCreator.__init__(self, "CustomCode_to-excel", name, project) #replace recipe type with yours

    builder = MyRecipeCreator('my_new_custom_recipe_1', project)
    recipe = builder.build()
    Then add inputs/outputs. You may need to add more settings based you your recipe. You can create one recipe via UI, and refer to the settings from there.
    settings = recipe.get_settings()
    settings.add_input(role="input_dataset",ref="us_50")
    settings.add_output(role="folder",ref="YdXfMUzM")
    settings.save()
    Below is the screenshot of creating the "Multisheet excel export" plugin's recipe programmatically:
    Screenshot 2022-11-04 at 13.40.24.png

    Best,

    Vitaliy

Setup Info
    Tags
      Help me…