Contribute a Plugin

Pipcook welcomes developers to contribute plugins for us to extend the functions of Pipcook. This document describes how to develop a plugin. The content involved in this article is just a few suggestions, the specific plugin can run successfully in Pipcook as long as it meets our plugin prototype specifications.

We strongly recommend that you first understand the plugin specification that we define. Only plugins that meet the interface that we define can be accepted.

Get Started

To get started with developing a new plugin, Pipcook Tools provides pipcook plugin-dev:

  1. $ pipcook plugin-dev --type <category> --name <plugin>

A plugin script is a TypeScript function that inherits from the corresponding plugin interface, for exmaple, a DataCollectType plugin will look like this:

  1. const collectTextline: DataCollectType = async (args: ArgsType): Promise<void> => {
  2. const { uri, dataDir } = args;
  3. await fs.copy(uri, dataDir + '/my-own-dataset.csv');
  4. return null;
  5. };

For other plugin interfaces, see this list of plugin categories.

Test your plugin

You can prepare the corresponding mocking data based on the interface. For example, if you developed a DataProcessType plugin, create some mock firstly:

  1. const data = {
  2. trainData: tf.data.array([{xs: [1,2,3], ys: [1]},{xs: [4,5,6], ys: [2]}]),
  3. metaData: {
  4. feature: {
  5. name: 'train',
  6. type: 'int32',
  7. shape: [1,3]
  8. },
  9. label: {
  10. name: 'test,
  11. type: 'int32',
  12. shape: [1]
  13. },
  14. }
  15. };

If the DataProcessType plugin needs to double the size of each feature, you can implement your plugin as follows:

  1. const doubleSize: DataProcessType = async (sample: Sample, metadata: Metadata, args?: ArgsType): Promise<void> => {
  2. // double the data
  3. sample.data = sample.data * 2;
  4. };
  5. export default doubleSize;

You need to check the following two before releasing that:

  • a plugin is able to run without any errors.
  • the returned value of your plugin comply with the plugin specfication.

After ensuring the preceding the above, you can run a real pipeline to check whether your plugin is compatible with the corresponding upstream and downstream plugins.

Release

Once you have developed the plugin done, you can create own plugin package on NPM:

  1. $ npm publish

And anyone could try your plugin via the following command:

  1. $ pipcook plugin install your-pipcook-plugin-name

Awesome Pipcook Plugins

Below is the awesome list of Pipcook plugins, we welcome third-party plugin contributors to update this list via GitHub Pull Request.

dataCollect

  • @pipcook/plugins-csv-data-collect
  • @pipcook/plugins-image-classification-data-collect
  • @pipcook/plugins-mnist-data-collect
  • @pipcook/plugins-object-detection-coco-data-collect
  • @pipcook/plugins-object-detection-pascalvoc-data-collect

dataAccess

  • @pipcook/plugins-coco-data-access
  • @pipcook/plugins-csv-data-access
  • @pipcook/plugins-pascalvoc-data-access

dataProcess

  • @pipcook/plugins-image-data-process

modelDefine

  • @pipcook/plugins-bayesian-model-define
  • @pipcook/plugins-detectron-fasterrcnn-model-define
  • @pipcook/plugins-tfjs-mobilenet-model-define
  • @pipcook/plugins-tfjs-simplecnn-model-define

modelTrain

  • @pipcook/plugins-bayesian-model-train
  • @pipcook/plugins-image-classification-tfjs-model-train
  • @pipcook/plugins-detectron-model-train

modelEvaluate

  • @pipcook/plugins-image-data-process
  • @pipcook/plugins-bayesian-model-evaluate
  • @pipcook/plugins-image-classification-tfjs-model-evaluate
  • @pipcook/plugins-detectron-model-evaluate