Change a recipes engine using the API

NN
NN Neuron, Registered, Neuron 2022, Neuron 2023 Posts: 145 Neuron

Hi Everyone,
I know we can get the selected engine details of a recipe using the API.
but is there a way to change the engine of the recipe as well using the API ?

Any suggestions are welcome Thanks..

Tagged:

Best Answer

  • MikeG
    MikeG Dataiker, Registered Posts: 15 Dataiker
    edited July 17 Answer ✓

    Hi @NN
    ,

    It is possible to change the engine used by a recipe by changing the value of `engineType` in that recipe's settings.

    Here's an example (assume the `engineType` is 'DSS' and I want to change it to 'SQL' via the API):

    import dataikuapi
    
    host = DSS_HOST
    apiKey = DSS_API_KEY
    client = dataikuapi.DSSClient(host, apiKey)
    
    proj = client.get_project("COMMUNITY_24974")
    recipe = proj.get_recipe("compute_orders_copy_filtered")
    
    settings = recipe.get_settings()
    settings.raw_params['engineType']='SQL'
    settings.save()

    Note: a recipe may be able to use only a subset of engines. To determine which engines are eligible to be used by a recipe check the output of `recipe.get_status().get_engines_details()`. If an engine has `'isSelectable': True` then that engine can be used for that recipe.

    Thank you,
    Mike

Answers

  • NN
    NN Neuron, Registered, Neuron 2022, Neuron 2023 Posts: 145 Neuron

    Thanks @MikeG
    That works..

  • Mali
    Mali Dataiku DSS Core Designer, Registered Posts: 6 ✭✭
    edited July 17

    Hi Dataiku Team,

    I am able to change the engine of prepare recipes using the code. But it fails for other recipes like join and group. The error I get is shown below:

    ---------------------------------------------------------------------------
    KeyError                                  Traceback (most recent call last)
    <ipython-input-99-f75ef26b38e9> in <module>
          1 settings = recipe.get_settings()
    ----> 2 settings.raw_params['engineType'] = 'DSS'
          3 settings.save()
    
    /opt/dataiku-dss-12.5.1/python/dataikuapi/dss/recipe.py in raw_params(self)
        527         :rtype: dict
        528         """
    --> 529         return self.recipe_settings["params"]
        530 
        531     def _payload_to_str(self):
    
    KeyError: 'params'

    Can anyone help me resolve this issue?

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,088 Neuron

    Hi @mallisundaresan
    this thread has been marked as solved. Please start a new thread.

  • Vitaliy
    Vitaliy Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer Posts: 102 Dataiker
    edited July 17

    Hi,

    For join recipes, you should use the below:

    settings.get_json_payload()['engineType'] = 'DSS'
    settings.save()

    Best.

Setup Info
    Tags
      Help me…