Plugin Presentation
When a plugin is displayed in the CDAP UI, its properties are represented by widgets in the Pipeline Studio. Each property of a plugin is represented, by default, as a simple textbox in the user interface. By including an appropriate plugin widget JSON file, you can customize that presentation to use a different interface, as desired.
The available widgets that can be used are described below. Note that some of the plugins available for CDAP may include use of additional widgets that are not listed here. We recommend only using the list of plugins shown here, as these other widgets are internal to CDAP and may not be supported in a future release.
This document describes version 1.5 of the plugin specification. Changes to the specification are described in the Specification Changes and should be checked if you are using a version of the specification earlier than the current.
Plugin Widget JSON
To customize the plugin display, a plugin can include a widget JSON file that specifies the particular widgets and the sets of widget attributes used to display the plugin properties in the CDAP UI.
The widget JSON is composed of:
a map of metadata
a list of property configuration groups
a map of inputs
a list of outputs
a map of dataset jumps
Each configuration group consists of a list of the individual properties and the widgets to be used. For example:
{
"metadata": {
...
},
"display-name": "Plugin Display Name",
"icon": {
"type": "builtin|link|inline",
"arguments": {
"url": "http://localhost/myicon.png",
"data": "data:image/png;base64,..."
}
},
"configuration-groups": [
{"label": "Group 1",
"properties": [
...
]
},
{"label": "Group 2",
"properties": [
...
]
},
...
],
"inputs": {
...
},
"outputs": [
{"output-property-1"},
{"output-property-2"},
...
],
"jump-config": {
...
}
}
Metadata
Metadata refers to the top-level information about a plugin. The only information required is the a map consisting of the spec-version
, the version of the specification which the JSON follows.
Current version: 1.5. For example:
{
"metadata": {
"spec-version" : "1.5"
},
...
}
Display Name
The display-name
field specifies the name of the plugin as it is displayed on the CDAP UI. A display name can be different from the plugin name, and is not guaranteed to be unique. A display name can contain whitespace. If not specified, the plugin name is used as the display name.
Icon
The icon
field allows users to specify custom icons for their plugins. Users can specify icons for their plugins in three different ways, depending on the value of the type
field contained inside the icon
field:
builtin
: The icon typebuiltin
indicates that the icon for the plugin is defined in CDAP, and is not specified in the plugin's widget JSON file. This is the default icon type, if an icon is not specified. If such an icon is not found, the CDAP UI will use a default icon type.link
: The icon typelink
indicates that the icon for the plugin should be fetched from a URL specified in thearguments
map. When the type of icon islink
, the user is expected to provide a link to the icon image in aurl
attribute inside thearguments
map.inline
: The icon typeinline
indicates that the icon for the plugin should be decoded from a base64 encoded image specified in thearguments
map. When the type of icon isinline
, the user is expected to provide a base64 encoded image in adata
attribute inside thearguments
map.
Icon Image Specification - The image used for an icon for a CDAP plugin should be in PNG format (http://www.libpng.org/pub/png/). The size of the image should be 50 X 50 pixels. The image background should be transparent.
Configuration Groups
Configuration groups are a simple grouping of properties of a plugin. A configuration group is represented as a JSON object with a label and an ordered list of plugin properties for that group.
For example, in a Batch Source plugin, properties such as name
, basePath
, duration
, and delay
could be grouped into a Batch Source Configuration.
Setting the hideByDefault
property of a configuration group results in the group properties to be hidden by default.
In the case of a Batch Source plugin, it could look like this:
{
"configuration-groups": [
{
"label": "Batch Source Configuration",
"properties": [
{
"name": "name",
...
},
{
"name": "basePath",
...
},
{
"name": "duration",
...
},
{
"name": "delay",
...
}
]
}
]
...
}
Once a group is established, you can configure how each of the individual properties inside the group is represented in the CDAP UI.
Property Configuration
Each individual property of the plugin is represented by a configuration, composed of:
name: Name of the field (as supplied by the CDAP server for the artifact).
label: Text string displayed in the CDAP UI beside the widget.
widget-type: The type of widget to be used to represent this property.
widget-attributes: A map of attributes that the widget type requires to be defined in order to render the property in the CDAP UI. The attributes required depend on the widget type used.
plugin-function: An optional map of plugin method and its widget attributes that can be applied to a particular plugin property.
Note: All properties and property values are case-sensitive.
To find the available field names, you can use the Artifact Microservices to retrieve plugin details for an artifact, which will include all the available field names. (If the artifact is your own, you will already know the available field names from your source code.)
In this example of a Batch Source plugin and its configuration-groups
, four different properties are defined; three use a textbox widget, while one uses a dataset-selector. The groupByFields property includes a plugin function, used to fetch an output schema for the widget:
Plugin Widgets
A widget in the CDAP UI represents a component that will be rendered and used to set the value of a property of a plugin. These are the different widgets, their type, their attributes (if any), their output data type, a description, sample JSON, that we support in CDAP pipelines as of version 6.2.0.
Widget Type | Widget Attributes | Output Data Type | Description | Example Widget JSON |
---|---|---|---|---|
|
| Comma-separated | Comma-separated values; each value is entered in a separate box | |
| No attributes |
| Selector for a date and time range using graphical calendar | |
| No attributes |
| Selector for a single date and time using graphical calendar | |
| No attributes |
| A type-ahead textbox with a list of datasets from the CDAP instance | |
|
|
| A delimiter-separated values widget that allows specifying lists of values separated by delimiters | |
|
| Delimiter-separated | Delimiter-separated values; each value is entered in a separate box | |
|
|
| This "hidden" widget allows values to be set for a property but hidden from users. A default can be supplied that will be used as the value for the property. | |
| No attributes
|
| A dropdown widget with a list of columns taken from the input schema. Selecting sets the input column for that plugin property. | |
|
|
| An editor to write JavaScript code as a value of a property | |
|
|
| A JSON editor that pretty-prints and auto-formats JSON while it is being entered | |
|
|
| A key-value editor for constructing maps of key-value pairs | |
|
|
| Multi-select dropdown to choose one or more from a list of available options. |
|
|
|
| A group of radio buttons to choose one among a list of available options. | |
|
|
| Similar to keyvalue widget, but with a drop-down value list | |
|
|
| A non-editable widget for displaying a schema | |
|
|
| Default HTML number textbox that only accepts valid numbers | |
| No attributes |
| Default HTML password entry box | |
|
|
| A drop-down with a list of plugins | |
|
|
| An editor to write Python code as a value of a property | |
|
|
| A four-column, editable table for representing the schema of a plugin | |
|
|
| An HTML drop-down with a list of values; allows one choice from the list | |
|
|
| An HTML | |
|
|
| An HTML | |
|
|
| An HTML textbox, used to enter any string, with a default value attribute | |
|
|
| A toggle widget that allows toggling between 'on' and 'off' states |
Plugin Function
A plugin function is a method exposed by a particular plugin that can be used for a specific task, such as fetching an output schema for a plugin.
These fields need to be configured to use the plugin functions in the CDAP UI:
method: Type of request to make when calling the plugin function from the CDAP UI (for example: GET or POST)
widget: Type of widget to use to import output schema
plugin-method: Name of the plugin method to call (as exposed by the plugin)
required-fields: Fields required to call the plugin method
missing-required-fields-message: A message for the user as to why the action is disabled in the CDAP UI, displayed when required fields are missing values
The last two properties (required-fields and missing-required-fields-message) are solely for use by the CDAP UI and are not required for all widgets. However, the first four fields are required fields to use a plugin method of the plugin in the CDAP UI.
With plugin functions, if the widget is not supported in the CDAP UI or the plugin function map is not supplied, the user will not see the widget in the CDAP UI.
Widget Type | Widget attributes | Description | Example Widget JSON |
---|---|---|---|
|
| Widget to populate output schema for a plugin. This is specifically used to populate output schema and not any other property. | |
|
| Widget to populate any property in a plugin. This widget should be used in the property which needs to fetch its value from a plugin function implemented in the plugin backend |
Example Plugin
In the case of a Batch Source plugin example, the configuration-groups
, with additional widgets to show the groupByFields
and aggregates
properties and using a plugin-function, could be represented by:
Inputs
Beginning with version 1.2 of the specification, a plugin can accept multiple input schemas and from them generate a single output schema. Using the field multipleInputs
and setting it to true
tells the CDAP UI to show the multiple input schemas coming into a specific plugin, instead of assuming that all of the schemas coming in from different plugins are identical.
This is an optional object, and if it is not present, it is assumed that all of the schemas coming in from any connected plugins are identical. Currently, only one value (multipleInputs
) is accepted.
For example:
Outputs
The outputs is a list of plugin properties that represent the output schema of a particular plugin.
The output schema for a plugin can be represented in two different ways, either:
via an explicit schema using a named property; or
via an implicit schema
Output properties are configured in a similar manner as individual properties in configuration groups. They are composed of a name and a widget-type, one of either schema
(for an explicit schema) or non-editable-schema-editor
(for an implicit schema).
With the schema
widget type, a list of widget attributes can be included; with the non-editable-schema-editor
, a schema to be displayed is added instead.
An explicit schema using a property can be defined as the output schema and then will be editable through the CDAP UI.
For example, a "Batch Source" plugin could have a configurable output schema named data-format
, displayed for editing with the schema
widget-type, with a default type of string
, and a list of the types that are available:
An implicit schema is a pre-determined output schema for a plugin that the plugin developer enforces. The implicit schema is not associated with any properties of the plugin, but instead shows the output schema of the plugin, to be used for visual display only.
An example of this is from the KeyValueTable Batch Source plugin:
Widget types for output properties are limited to ensure that the schema that is propagated across different plugins in the CDAP UI is consistent. For output properties, CDAP uses use either schema-editor
for editable schemas and non-editable-schema-editor
for non-editable schemas.
Dataset Jumps
Beginning with version 1.3 of the specification, a plugin can be specified (using jump-config
) with a map of dataset "jumps". They specify which plugin property names are either a dataset that can be used, in the CDAP UI, to directly jump to a detailed view of the dataset.
This is an optional object, and if it is not present, no jump links will be created in the CDAP UI. Jump links are not active in the Pipeline Studio.
For example:
In this example, the datasetName
field of the dataset-selector
will have a "jump" link added in the CDAP UI.
Example Widget JSON
Based on the above specification, we can write a widget JSON for a Batch Source plugin (with the properties of name, basePath, duration, delay, groupByFields, aggregates, and an editable output explicit schema) as:
Dynamic Plugin Filters
The CDAP plugin UI allows plugin developers to accompany logic to show/hide plugin properties based on the plugin configuration. For instance, if the developer of a plugin has “Authentication method” as one of the plugin properties, and based on the authentication method the developer wants only a specific set of properties to be configured (say service account or authentication token or oauth token), they can add filters to widget json to add logic to show/hide specific properties based on the value of the Authentication method.
Filters to plugin’s widget json can be added under filters
property:
Each filter under the filters
contains three required properties.
name
- Name of the filter. This is solely added here to name every filter for easy readability.condition
- This specifies the condition to be evaluated when plugin properties change to show/hide specific properties.show
- Properties/Groups to show in plugin UI.
Note: The property show
is named intentionally that it will show the properties/groups only if the condition is true. So, by default those properties will be hidden in UI. Each time a plugin property is changed the conditions are evaluated. When the condition evaluates to true, the UI shows the properties. The property to show or hide needs to be nullable (with @Nullable when defining the java attribute).
The condition
property under the filter can be of two formats: simple operator
and jexl expression
.
Simple operator
: The CDAP UI provides some basic operators for use when specifying filter conditions. Those include:
exists
does not exist
equal to
not equal to.
A simple operator has two required properties and an optional property:
operator
- name of the operator (mentioned above)property
- name of the property to apply the operatorvalue
- If the the operator is binary, the value to compare it against. (greater than, less than etc.,)
jexl expression
: Is a javascript expression that evaluates to true/false.
The javascript expression will only consider numbers, strings, and boolean while evaluating conditions. Since context for evaluating the expression will be the plugin properties, we expect the condition to be composed of numbers, boolean, and strings. This requires that we convert the values of the plugin properties to appropriate types instead of having everything as string.
The expression is represented in javascript expression language. This is not to be confused with Jexl defined as part of the Apache foundation for java language. For more information about the javascript expression language, see Jexl Github repo.
A jexl expression has one required property:
expression
: Any valid javascript expression
Every time an expression is evaluated, the plugin properties are provided as context for evaluating the expression. This allows plugin developers to use plugin properties in expressions. Say for instance the plugin properties look like this:
The plugin developer could add a filters section that could use one of the properties to evaluate the expression:
Based on the above filter, if numSplits
property is set to a value greater than 1
, the UI will show boundingQuery
and splitBy
properties.
Macros: Even though the plugin developer can specify filters to show/hide properties, when the pipeline developer starts to use macros for plugin properties, all the filter logic will be ignored. Since the UI cannot resolve the macros during development time, it is not possible for the UI to evaluate the expressions.
Error validation (Required property): Since the plugin developer can configure multiple filters as part of the widget json, there could be a case where the plugin developer hides a plugin property that is a required for plugin’s functionality. Since the UI knows that a specific plugin property is annotated as required by the plugin developer, it, by default, gets shown when rendered. Even though the plugin developer has hidden it under a filter condition, the UI has to show as it is required.
Specification Changes
These changes describe changes added with each version of the specification.
1.1: Initial version of the specification.
1.2: Added multiple inputs for a plugin.
1.3: Added jump-config to specify which property names are to be connected in the CDAP UI to a detailed view of a dataset.
1.4: Added
widget-type: hidden
.
Created in 2020 by Google Inc.