tutor plugins enable xxx
does not update the environment
#989
Labels
bug
Bugs will be investigated and fixed as quickly as possible.
Bug description
Enabling a plugin should properly update the environment.
How to reproduce
When running:
I would expect that the environment is updated, as per this new feature. But it turns out it's not the case. The following command does not output anything:
Additional context
This is a caching issue. The
ENV_PATCHES_DICT
variable is a cache that is filled once all plugins are loaded -- but not when a new plugin is loaded. This is an issue that was discussed before here: #917 (comment)Turns out, cache management is even more difficult that we anticipated. This issue also shows up in the MFE plugin, which has to manually implement, cache management, which is ugly: https://github.com/overhangio/tutor-mfe/blob/de526369f0a882c459ac9d20575f8c23ea0f7fab/tutormfe/plugin.py#L93
Still, we do want to preserve caching features for performance reasons. So here's what I suggest:
hooks.Actions.PLUGINS_CACHE_CLEAR
action.tutor/hooks/utils.py
module, with Apache 2.0 license.@plugins_cache
decorator that will be a wrapper on top offunctools.lru_cache
.@plugins_cache
, a callback to the PLUGINS_CACHE_CLEAR must be added, such that the cache is cleared when that action is called.hooks.utils.plugins_cache
inhooks/__init__.py
such that the function is available in plugins.plugins_cache
decorator is documented in https://docs.tutor.edly.io/reference/api/hooks/index.htmlENV_PATCHES_DICT
to a_env_patches_dict
function that is decorated withhooks.plugins_cache
.The text was updated successfully, but these errors were encountered: