Create plugin recipe between existing dataset and folder
![tomas](https://us.v-cdn.net/6038231/uploads/lithium_attachments/n5261i79DA1BFFD65C0DD1.png)
tomas
Registered, Neuron 2022 Posts: 120 ✭✭✭✭✭
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
-
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()Best,
Vitaliy