Add a recipe to the dataset

Prerequisites to add a recipe to the dataset

You should create the following:

Requests.setRootHost("http://staging.dev.rapidcanvas.net/api/")
AuthClient.setToken(token="")  #you can find your token in RapidCanvas UI under tools/token

..Note: If you are launching the Notebook from the UI, you do not have to pass the token.

The below is an example to add a transform/template called, “Add Prefix” to the dataset and run this transform on the dataset to generate the output.

template=TemplateV2.get_template_by('Add Prefix')

recipe_Add_Prefix= project.addRecipe([employee], name='Add Prefix')

transform=Transform()
transform.templateId = template.id
transform.name='Add Prefix'
transform.variables = {
'input_dataset':'employee',
'output_dataset':'car_prefixed',
'value_1':"A"}
recipe_Add_Prefix.add_transform(transform)
recipe_Add_Prefix.run()

Example response:

INFO:Creating new recipe
INFO:Adding new transform
INFO:Transform added Successfully
INFO:Started running
INFO:You can look at the progress on UI at https://test.dev.rapidcanvas.net/#/projects/bd45aabe-891e-4588-9056-0171158e1e44
INFO:No errors and warnings found

Add another recipe to the dataset

You must use the following code to fetch the output dataset of the preceding recipe to use this as an input for another recipe.

car_prefixed=recipe_Add_Prefix.getChildrenDatasets()['car_prefixed']
car_prefixed.getData(10)

Below is an example to run another recipe (Add Suffix) on the output dataset of the prior transform/template.

template=TemplateV2.get_template_by('Add Suffix')

recipe_Add_Suffix= project.addRecipe([car_prefixed], name='Add Suffix')

transform=Transform()
transform.templateId = template.id
transform.name='Add Suffix'
transform.variables = {
'input_dataset':'car_prefixed',
'output_dataset':'car_suffixed',
'value_1':"new"}
recipe_Add_Suffix.add_transform(transform)
recipe_Add_Suffix.run()