How-to | Set a code environment#

Let’s learn how to set Python or R code environments for plugins, projects, and recipes (or other objects within a project).

Note

Your Dataiku administrator, or any user in a group with the proper permissions, can create different code environments , which are then available for you to use.

Set a project-level code environment#

By default, projects inherit the code environment according to the global settings of the instance (Administration > Settings > Misc.). Unless otherwise specified, this is the Dataiku builtin environment.

  1. From the top navigation bar, go to … > Settings > Code env selection.

  2. For the default Python or R code env:

    • Change the mode to Select an environment.

    • A dropdown appears that allows you to select a different environment from those already created.

../../_images/code-env-project.png

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.

Tip

If you plan to use visual machine learning, the project-level code environment must include the scipy, scikit-learn, jinja2 and xgboost packages.

Set a recipe’s code environment#

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. On the Advanced tab of a recipe, find the Python or R environment panel.

  2. Adjust the “Selection behavior” to select an environment as needed.

../../_images/code-env-recipe.png

Set a notebook’s code environment#

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.

You can set the code environment at notebook creation time, or by changing the kernel (Kernel > Change kernel from the notebook menus).

../../_images/code-env-notebook.png

Set a webapp or R markdown report’s code environment#

By default, Python Bokeh webapps, R Shiny webapps, and R Markdown reports use 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.

While in Edit mode, on the Settings tab, you can set the code environment using the Code env dropdown.

../../_images/code-env-webapp.png

Set a plugin’s code environment#

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.

Set a visual model’s code environment#

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.

../../_images/code-env-ml.png

Set a code environment in 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.

../../_images/code-env-scenario.png