uhd-urz / elAPI

An extensible API client for eLabFTW
GNU Affero General Public License v3.0
5 stars 0 forks source link

Local third-party plugins with virtual environment support #114

Closed mhxion closed 1 month ago

mhxion commented 1 month ago

Extending from merge request #111, we introduce third-party plugin with virtual environment support. Before, third-party plugins could not use any packages that were not part of elAPI (e.g. requests package). With this PR, a third-party plugin can use any Python package given that they provide the following plugin metadata file in ~/.local/share/elapi/plugins/<plugin name>/elapi_plugin_metadata.yml:

# elapi_plugin_metadata.yml

plugin_name: test
cli_script: ~/my-project/cli.py
venv_dir: ~/my-project/.venv

elAPI will give the information found on this metadata file elapi_plugin_metadata.yml higher priority. E.g., if a plugin name conflict occurs, the conflicting plugin can be easily renamed by the user just by giving a new name to plugin_name key in elapi_plugin_metadata.yml.

An elAPI plugin running numpy (numpy.random.randint)

Screenshot 2024-07-02 at 11 08 14 PM