Discover this year's submissions to the Dataiku Frontrunner Awards and give kudos to your favorite use cases and success stories!READ MORE

How to set recipe container through dataikuapi

Solved!
fmonari
Level 2
How to set recipe container through dataikuapi

Hi,

I would like to change dynamically the container for the execution of a recipe through the dataikuapi-external-client. I could not find any referenece in the documentation.

How can I achieve that (if possible)?

Regards,

Filippo

0 Kudos
1 Solution
HarizoR
Developer Advocate
Developer Advocate

Hi again,

In that case you will need to use the get_settings() method of the Recipe API, retrieve the existing parameters for container configuration, modify the dictionary in-place and finally call the save() method on the recipe settings handle. Here is a simplified example:

import dataikuapi
client = dataikuapi.DSSClient(host=HOST, api_key=API_KEY)
project = client.get_project(PROJECT_KEY)
recipe_settings = project.get_recipe(RECIPE_ID).get_settings()
recipe_advanced_params = recipe_settings.raw_params
recipe_advanced_params["containerSelection"]["containerMode"] = "EXPLICIT_CONTAINER"
recipe_advanced_params["containerSelection"]["containerConf"] = YOUR_CONTAINER_CONF_NAME

 

Of course this assumes that you already have an existing functioning containerized execution configuration in your instance's administration settings. 

Best,

Harizo

View solution in original post

0 Kudos
3 Replies
HarizoR
Developer Advocate
Developer Advocate

Hi Filippo,

Do you mean to programmatically change the "container configuration" settings for a given recipe ?

Best,

Harizo

0 Kudos
fmonari
Level 2
Author

Exactly. How can I do that? What methods in the DSSRecipe or DSSRecipeSettings classes should I use?

Thanks!

0 Kudos
HarizoR
Developer Advocate
Developer Advocate

Hi again,

In that case you will need to use the get_settings() method of the Recipe API, retrieve the existing parameters for container configuration, modify the dictionary in-place and finally call the save() method on the recipe settings handle. Here is a simplified example:

import dataikuapi
client = dataikuapi.DSSClient(host=HOST, api_key=API_KEY)
project = client.get_project(PROJECT_KEY)
recipe_settings = project.get_recipe(RECIPE_ID).get_settings()
recipe_advanced_params = recipe_settings.raw_params
recipe_advanced_params["containerSelection"]["containerMode"] = "EXPLICIT_CONTAINER"
recipe_advanced_params["containerSelection"]["containerConf"] = YOUR_CONTAINER_CONF_NAME

 

Of course this assumes that you already have an existing functioning containerized execution configuration in your instance's administration settings. 

Best,

Harizo

0 Kudos