aiverify icon indicating copy to clipboard operation
aiverify copied to clipboard

[FEATURE] AIVF Plugin Manager

Open timlrx opened this issue 11 months ago • 0 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Description

Currently, it is difficult to installing and maintaining new plugins and their dependencies. One possible approach is to make the system more modular and rely on pip to manage dependencies.

Here's a design document that goes through the various approaches and their pros and cons, paying attention to:

  • User experience of installing plugins
  • Operations and maintenance of the system
  • Developer experience of new plugins

Current approach - custom plugin manager

Currently to install a plugin, 2 steps are required:

  1. Install the requirements associated with the plugin (e.g. requirements.txt for each stock plugin)
  2. Register the path of the plugin with the PluginManager so that it is able to execute the plugin as a Python script This is similar to the approach taken by more UI first applications e.g. automatic1111 since users can just drag and drop the extension to install it via the UI, though they also have a CLI to make installing and maintaining packages a little easier.

Pros:

  • Allows installation via a GUI (though this is not currently done by AIVF)
  • Allows modification of other aspects of AIVF system e.g. UI

Cons:

  • Installation issues especially those that are hardware dependent e.g. PyTorch
  • Duplicates the work of existing package managers (e.g. verification that the library exists), more maintenance work needed
  • Not straight forward to develop and build a plugin - requires a custom approach
  • Hard to specify cross-package dependencies

Alternative 1 - Manage dependencies through pip and venv

This is a common approach among Python based applications (e.g. flask). See https://packaging.python.org/en/latest/guides/creating-and-discovering-plugins/#using-naming-convention

Users can pick and choose which plugin to install via the package manager.

Pros:

  • Dependency resolution is handled natively via pip
  • Easy to create and distribute plugins
  • No need for a custom plugin manager, less to maintain, versioning and other package manager features available out of the box
  • Easy for another developer / user to modify dependencies

Cons:

  • Plugin has to be built and published to pypi (but this also means better discoverability)
  • Might need re-examine the best way to include Python <-> UI dependencies

Alternative 2 - plugin integration as class methods

Relatively common approach taken by libraries e.g. Scikitlearn where there are conventions e.g. train / predict methods and packages that want to implement SKlearn compatible methods, just need to create those methods. Also the approach taken by MAS Veritas.

Maintainers inherit an Abstract Base Class and implement the methods e.g. AIVF_test

Pros:

  • Allow any package to be “AIVF compatible” by implementing methods
  • Simplified plugin method - check that class methods are implemented

Cons:

  • Need to have very clear schema or what is the expected input and output
  • Discovery is more difficulty, users need to register packages at run-time so AIVF is aware what is available

Is your feature request related to a problem/limitation?

No response

Describe the solution you'd like

My preference is to move towards alternative 1, but would also like to hear from other users / maintainers or their preferences or other possible approaches

Alternatives

No response

Additional Context

No response

Related Issues/PRs

No response

timlrx avatar Mar 27 '24 05:03 timlrx