Skip to content

Adding a Parameter Type

Jonathan Stray edited this page Apr 1, 2019 · 10 revisions

Parameters have two aspects: data (DType) and field format (FType). data is what is passed to a module's render(): it loosely follows JSON. field format is what is displayed to the user: it loosely follows our React components.

For instance: if we're displaying a checkbox: FType=checkbox, DType=boolean.

To add an FType:

Server side:

  • Add the type to properties.parameters.items.properties.type in server/models/module_spec_schema.yaml
  • Add the type to the ParamField.FType enum in server/models/param_field.py
  • Add a case in def dtype(self) for the new FType, mapping it to an existing DType
  • Test the new conversion in server/tests/models/test_param_field.py

Client side:

  • Create a new React component in a new file that renders the UI for the component
  • Add a case to the lookup on component type in Params.js
  • Jest tests for the above