5 Minutes Hands on¶
The only thing you need to do is to write a python class that inherits from @evaluation_system.api.plugin.PluginAbstract and overwrites one method and a couple of arguments.
This is a minimal working plugin, we will describe more interesting examples later on.
from evaluation_system.api import plugin, parameters class MyPlugin(plugin.PluginAbstract): tool_developer = {'name':'Max Mustermann', 'email':'max.musterman@fu-berlin.de'} __short_description__ = "MyPlugin short description (just to know what it does)" __version__ = (0,0,1) __parameters__ = parameters.ParameterDictionary(parameters.Integer(name='solution', default=42)) def runTool(self, config_dict=None): print "MyPlugin", config_dict
The plugin itself is not doing much, just printing out the name and the configuration provided when it's being called.
But you have a full configurable plugin with a lot of functionality by just inheriting from the abstract class.
So how do we test it? Very, very simply... Here the steps:
- Activate the system as described in Using the system
module load miklip-ces
- Create a directory where the plugin will be created
mkdir /tmp/myplugin
- Copy the plugin from above in a file ending in '.py' in the mentioned dyrectory
#Use your preferred method of writing the contents to /tmp/myplugin/something.py $ cat /tmp/myplugin/something.py from evaluation_system.api import plugin, parameters class MyPlugin(plugin.PluginAbstract): __short_description__ = "MyPlugin short description (just to know what it does)" __version__ = (0,0,1) __parameters__ = parameters.ParameterDictionary(parameters.Integer(name='solution', default=42)) def runTool(self, config_dict=None): print "MyPlugin", config_dict # Setup the environmental variable EVALUATION_SYSTEM_PLUGINS=<path>,<package>[:<path>,<package>] (that's a colon separated list of comma separated pairs which define the location (path) and package of the plugin.
#for bash export EVALUATION_SYSTEM_PLUGINS=/tmp/myplugin,something
- Test it
$ freva --plugin [...] MyPlugin: MyPlugin short description (just to know what it does) $ freva --plugin myplugin MyPlugin {'solution': 42} $ freva --plugin myplugin --help MyPlugin (v0.0.1): MyPlugin short description (just to know what it does) Options: solution (default: 42) No help available. $ plugin --tool myplugin solution=777 MyPlugin {'solution': 777}
That's it!
To properly develop a plug-in you'll need some python knowledge, but we have already post some examples that should get you through.
Just check the [[wiki|main page]].