How-to | Set a code environment#

Once a code environment is created on an instance, many Dataiku objects can be configured to use a code environment other than the built-in environment.

Projects#

By default, projects inherit the code environment according to the global settings of the instance. You can check this in Administration > Settings > Misc. Unless otherwise specified, this is the DSS built-in environment.

In an individual project, you can set a different code environment to be used when processing code within that project.

  1. From the top navigation bar of the project, go to the menu More Options (…) and click on Settings.

  2. In the left panel, select Code env selection.

  3. Under Default Python code env, change the mode to Select an environment. A dropdown will appear that allows you to select a different environment from those already created.

  4. Select a new code environment.

  5. Click Save.

Dataiku screenshot of the project settings page to select a code environment.

Important

If you plan to use visual machine learning, the project-level code environment must include the scipy, scikit-learn, jinja2, and xgboost packages. Adding a visual machine learning package set is the recommended way to account for these dependencies.

Tip

If there is an environment you expect to see that is missing, contact your administrator. They may need to create a new code environment or give you permission to use an existing one.

Code recipes#

By default, Python and R recipes use the project’s code environment. For each recipe, you can set a different code environment to be used when processing code within that recipe.

  1. Navigate to the Advanced tab of a Python or R recipe in your project.

  2. In the environment panel, adjust the Selection behavior to associate a specific code environment with the recipe.

Dataiku screenshot of the advanced tab of a Python recipe to select a code environment.

Code notebooks#

By default, Python and R notebooks use the project’s code environment. For each notebook, you can set a different code environment to be used when processing code within that notebook.

  1. Open the code notebook from the Notebooks page (g + n).

  2. From the notebook tools bar, click on Kernel > Change kernel > <your-code-env>

  3. Click Save.

Dataiku screenshot of a Python notebook choosing a kernel.

Webapps#

Similar to recipes, webapps and other code objects like R Markdown reports inherit the project’s code environment. For each of these objects, you can set a different code environment to be used when processing code within the object.

  1. Navigate to the Settings subtab within the Settings tab of the webapp.

  2. Depending on the type of webapp, you may need to first Enable backend before finding the option to select a code environment.

Dataiku screenshot of the Settings tab of a webapp.

Plugins#

The plugin developer defines the code environment specification as part of the plugin. After installing a plugin that contains a code environment definition, you are prompted to create a code environment for the plugin.

Visual models#

Dataiku Visual Machine Learning allows you to create custom models using Python, in addition to the built-in models. The Python code environment to be used for training those custom models can be set in the Runtime environment panel of the Design tab.

  1. Navigate to the Design tab of a visual model in the Lab.

  2. Select the Runtime environment panel.

  3. In the Code environment section, use the Selection behavior dropdown to change the code environment.

Dataiku screenshot of the Runtime environment panel of a visual model.

Other Dataiku objects#

There are many other places in Dataiku where you can use custom code! For example, you can insert Python code in custom scenario steps and triggers, metrics, checks, data quality rules, as well as custom models.

For Dataiku objects that are not focused on code, but accept custom code, the dropdown list is typically placed near the custom code.

Dataiku screenshot of a code env for a custom Python trigger.