Concept | Plugin development#

Watch the video

In this lesson, we’ll explore the structure of a plugin and the steps involved in creating a development plugin.

There are three ways to create a development plugin by:

  • Writing code to define a new one.

  • Converting certain Dataiku elements, such as a code recipe or a webapp, into a development plugin.

  • Cloning and modifying the remote git repository that stores the source code for an existing plugin.

Write code to define a new development plugin#

To create a new, empty development plugin:

  1. Go to the plugin store.

  2. Select Add Plugin > Write your own.

  3. Name your plugin and begin adding components to it.

../../_images/plugin_dev_concept_add_new_plugin.png

Add a preparation processor component#

An example use case for developing a plugin is to extend the capabilities of the Prepare recipe. You can do this by writing a custom processor that will be available as a step in the Prepare recipe. To create the custom processor:

  1. Go to your Plugin’s Summary page.

  2. Click + New Component.

  3. Select the Preparation Processor.

../../_images/plugin_dev_concept_add_processor.png

By adding the processor component, Dataiku updates the plugin’s directory structure with two main elements that define the processor component:

  • A JSON file that defines allowable parameters such as the input and output for the processor.

  • A Python file that defines the plugin’s functionality.

You can then modify the contents of these files to customize the processor’s user interface and functionality.

Convert a Dataiku element to a development plugin#

You can also create a development plugin by converting a Dataiku code-based element, such as a code recipe, to a plugin.

Add a recipe component#

To add a recipe component to the development plugin:

  1. Open a code recipe and click the Convert to plugin action from the sidebar.

    ../../_images/plugin_dev_concept_convert_to_plugin.png

    This action allows us to either create a new plugin that consists of the plugin recipe or to add the recipe component to an existing plugin.

  2. Add the recipe component to the existing development plugin.

By adding the recipe component to the existing development plugin, Dataiku makes the appropriate additions to the plugin’s directory structure, along with some starter code that you can modify as needed.

../../_images/plugin_dev_concept_components.png

Modify the plugin component’s starter code#

To create a good quality plugin, you should follow good coding practices when modifying the starter code. Some practices to consider include:

  • Using good naming conventions

  • Writing clear descriptions

  • Checking for errors in user inputs

Note

It is not recommended to import dataiku into your library. With few exceptions, a plugin will not depend on Dataiku unless it is an administrative plugin.

Clone a remote Git repository that contains a plugin’s code#

The third option for creating plugins is by cloning and modifying the remote git repository that stores the source code for an existing plugin.

  1. Click Add Plugin from the plugin store’s homepage.

  2. Select Fetch From Git Repository.

When cloning the repository, you can clone in “development mode” which allows you to modify the code and later push back changes to the repository, provided that you have “write” privileges on the remote repository. You can also clone the entire repository or clone a subfolder (if the repository contains multiple plugins).

../../_images/plugin_dev_concept_clone_repo.png

Create a dedicated code environment for a plugin#

Every plugin needs a code environment. By default, the plugin will use the Dataiku built-in code environment. However, it is good practice to create a dedicated code environment that includes dependencies, such as all the required code libraries (or packages) for the plugin to work.

To create the code environment:

  • Click +Create a Code Environment from the plugin’s Summary page.

You can define the dedicated code environment within the plugin’s directory structure with files that contain the specifications for the desired packages and the code environment’s characteristics.

../../_images/plugin_dev_concept_code_env_files.png

Note

The code-based components in a plugin will use its associated code environment. However, there are some exceptions, such as in the case of custom algorithm components. Custom algorithms use the code environment that you specify in the visual ML tool.

What’s next?#

Now that you’ve seen the steps involved in creating a development plugin, continue your learning by exploring the Git integration for plugins lesson.