Plugin Configuration
Often, plugins require some configuration before running. For example you might want to run plugin on data from a specific service, or run a specific version of your machine learning model. To configure your plugin when running it from the front-end, plugins require a config.json
in the root of the plugin repository. This file contains a declarative definition, which our front-end app uses to display a configuration screen.
This module contains utilities to directly generate this config file from the plugin definition, by inferring all arguments from the plugin __init__
method. All configuration fields are textboxes by default, which can be changed to different types in the future. For a full example, see our guide on building plugins.
Usage:
create_plugin_config
As example, we create a test plugin with various configuration arguments. The create_config
method is called on the plugin, and generates a declarative configuration field for each plugin argument. Note that arguments that start with a _
, and untyped arguments are skipped in the annotation.
class MyPlugin(PluginBase):
def __init__(
self,
my_arg: str,
my_str: str = None,
my_int: int = None,
my_float: float = None,
my_bool: bool = None,
unannotated=None,
_private=None,
**kwargs
):
super().__init__(**kwargs)
def run(self):
pass
def add_to_schema(self):
pass
config = create_config(MyPlugin)
for c in config:
print(f'{c["display"]} ({c["data_type"]})')