Submit your innovative use case or inspiring success story to the 2023 Dataiku Frontrunner Awards! LET'S GO

Create plugin recipe between existing dataset and folder

Solved!
tomas
Create plugin recipe between existing dataset and folder

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

 

 

0 Kudos
1 Solution
VitaliyD
Dataiker
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

View solution in original post

0 Kudos
1 Reply
VitaliyD
Dataiker
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

0 Kudos