Comparing two recipes to determine if one is different?

Solved!
info-rchitect
Level 6
Comparing two recipes to determine if one is different?

Hi,

We create Dataiku project templates which give the user known-good recipes and flow zones to accomplish a certain task.  The project has variables we use in the recipes to parameterize the usage such that it can be run using different settings.  My question is if there is a way I could loop through the recipes in the users' project and get a boolean result if a recipe has been edited in any way.

Perhaps, there is some recipe text definition I could create a hash ID I could use to do the boolean diff?

thx


Operating system used: Windows 10

0 Kudos
1 Solution
Turribeach

The power of the Dataiku API! Here you go:

import dataiku

client_handle = dataiku.api_client()
project_handle = client_handle.get_project('some project key')
# Or you use client_handle.list_project_keys() 
# to get all project keys

python_recipes = [i for i in project_handle.list_recipes() if i['type'] in ['python']]

for python_recipe in python_recipes:
    recipe_name = python_recipe['name']
    recipe_handle = project_handle.get_recipe(recipe_name)
    recipe_script = recipe_handle.get_settings().get_payload()
    # Do something with it

View solution in original post

3 Replies
Turribeach

The power of the Dataiku API! Here you go:

import dataiku

client_handle = dataiku.api_client()
project_handle = client_handle.get_project('some project key')
# Or you use client_handle.list_project_keys() 
# to get all project keys

python_recipes = [i for i in project_handle.list_recipes() if i['type'] in ['python']]

for python_recipe in python_recipes:
    recipe_name = python_recipe['name']
    recipe_handle = project_handle.get_recipe(recipe_name)
    recipe_script = recipe_handle.get_settings().get_payload()
    # Do something with it
info-rchitect
Level 6
Author

@Turribeach What do you think of a native recipe boolean comparison function between two recipes?

0 Kudos

Too niche to be a built-in feature. But you have the API so you leverage that. You can also use the recipe modified date compared to the creation date to see if the recipe was changed. 

0 Kudos

Labels

?
Labels (2)

Setup info

?
A banner prompting to get Dataiku