-
Notifications
You must be signed in to change notification settings - Fork 728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the CLI --pythonpath parameter #12874
Conversation
Build Artifacts
|
10d198b
to
2d41d55
Compare
2d41d55
to
6d7d6a0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this in #12879 and
kolibri shell --pythonpath integration_testing/development_plugin
seems to work.
Not sure if this is a proper error or expected for trying to import this in the shell though?
In [4]: from integration_testing.development_plugin.kolibri_plugin import *
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Cell In[4], line 1
----> 1 from integration_testing.development_plugin.kolibri_plugin import *
File ~/LE/krakens/kolibri.worktrees/snake_like_path/integration_testing/development_plugin/kolibri_plugin.py:7
4 from magicbus.plugins import SimplePlugin
5 from magicbus.plugins.tasks import Autoreloader
----> 7 from kolibri.core.content.hooks import ShareFileHook
8 from kolibri.core.device.hooks import CheckIsMeteredHook
9 from kolibri.core.device.hooks import GetOSUserHook
ImportError: cannot import name 'ShareFileHook' from 'kolibri.core.content.hooks' (/home/jacob/LE/krakens/kolibri.worktrees/basic-layout-for-lesson-resources/kolibri/core/content/hooks.py)
However, when I run it while enabling plugins, I get errors - tried putting the flag in a couple places but the error persists.
kolibri --pythonpath integration_testing/development_plugin/ plugin integration_testing/development_plugin enable integration_testing.development_plugin
Usage: kolibri [OPTIONS] COMMAND [ARGS]...
Try 'kolibri --help' for help.
Error: No such option: --pythonpath
kolibri plugin enable integration_testing.development_plugin --pythonpath integration_testing/development_plugin
Usage: kolibri plugin enable [OPTIONS] [PLUGIN_NAMES]...
Try 'kolibri plugin enable --help' for help.
Error: No such option: --pythonpath
OK, this is working with the currently correct invocation:
As at the moment, the pythonpath parameter is only accepted by the plugin command, not any of the subcommands. I am going to update it now, to allow for this as well:
Note that when setting the pythonpath, you set it to the folder that the module is in, so that the module is discoverable. |
Ensure we validate pythonpath option before settings option. Set python path for all CLI commands so that it can be used for plugins too.
6d7d6a0
to
4a905a3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested again and everything worked great for plugin enable/disable and in the shell.
Summary
References
Fixes #10296
Reviewer guidance
Create a dummy plugin or settings file in a completely different folder. Pass the (can be relative) path to that folder using the the
--pythonpath
CLI option when invokingkolibri shell
kolibri plugin enable
or the like, and ensure that the settings file or plugin can take effect.