From 2fd9fd76ffd297dd67bb9a7fb8dc55f0567ae4ca Mon Sep 17 00:00:00 2001 From: Victor Hall Date: Tue, 4 Jul 2023 17:34:53 -0400 Subject: [PATCH] update plugin doc --- doc/PLUGINS.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/doc/PLUGINS.md b/doc/PLUGINS.md index e69de29..f57fe66 100644 --- a/doc/PLUGINS.md +++ b/doc/PLUGINS.md @@ -0,0 +1,28 @@ +# Plugin support + +This is a very early and evolving feature, but users who have a need to extend behavior can now do so with plugin loading. + +To create a plugin, extend the BasePlugin class and override the methods you want to change. + +For example, lets say we made ExampleLoggingPlugin class, and placed it in a file called `plugins/example_plugin.py`: + + +To activate a plugin, edit your `train.json` and use + +```"plugins": ["plugins.example_plugin.ExampleLoggingPlugin"],``` + +This uses module-path-like to your class. For this example, `plugins/example_plug.py` contains a class `ExampleLoggingPlugin` which extends `BasePlugin`. You can go look at the [example](plugins/example_plugin.py) to see how this one works. + +Everything is passed in as kwargs and the list of variables passed in is not fully defined yet. Consider it an open question what should be passed in, but it should be specific to the context, such as on_epoch_start should not pass in batch data or anything specific to step except for `epoch` and `global_step`. + +You can pass in as many plugins as you want, and each plugin only needs to implement the functions you wish. + +A basic implementation of a plugin that only uses the "end of an epoch" function will look something like this: + +```python +from plugins.plugins import BasePlugin + +class MyPlugin(BasePlugin): + def on_epoch_end(self, **kwargs): + print(f"hello world, this is a plugin at the end of epoch number: {kwargs['epoch']}") +``` \ No newline at end of file