ubccr / coldfront

HPC Resource Allocation System
https://coldfront.readthedocs.io
GNU General Public License v3.0
104 stars 83 forks source link

Feature: Enhanced plugin system #627

Open cc-a opened 2 days ago

cc-a commented 2 days ago

Description

Coldfront's current plugin mechanism is based on creating standalone Django apps and then requires the following modifications to the coldfront codebase:

The need to edit files within the coldfront codebase presents challenges for both development of plugins and for deployment of coldfront instances with third party plugins. For instance see ImperialCollegeLondon/coldfront_development_environment for an example of the additional infrastructure required to create a reproducible development environment.

Improving the above boils down to improving the handling of settings and url patterns for plugins.

Settings

A fundamental question here is why include settings from plugins at all? The current scheme promotes a pattern of plugins having access to the global settings which is not modular. It should be possible to set configuration for plugins from the global settings but I'd argue plugins in general shouldn't be changing global settings as this could lead to conflicts and unexpected behaviour.

A model to recommend to plugins for handling settings might be how django-debug-toolbar does things. It is a standalone app that has an internal settings module. Settings are accessed within the app via settings.get_config which loads a set of default app settings and overrides them based on values from the global settings.

URL Patterns

As there is a standard location (urls.py) for apps to define urlpatterns, their discovery and loading could be automated relatively easily via some importlib magic and (in the case of pip installed plugins) via entrypoints. Loading could be predicated on whether an app has been added to INSTALLED_APPS.

Component

Other

Additional information

No response

cc-a commented 2 days ago

Should add if you'd like to see a mockup for the urlpattern loading I'd be happy to knock together a PR.

aebruno commented 1 day ago

@cc-a Thanks for the detailed write up. Related to this, we're currently evaluating using DJP as it seems to be well polished and checks a lot of boxes in terms of providing an enhanced plug system. Perhaps we can use this issue to discuss pros/cons and other options for improving the way ColdFront can be extended.