-
-
Notifications
You must be signed in to change notification settings - Fork 526
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
External Plugins v2 #1216
External Plugins v2 #1216
Conversation
9eb9990
to
f50b430
Compare
234e1f3
to
de17222
Compare
Check column widths update gitignore throw error when linewrap too small simply check for large enough linewrap value
make exception more informative update check_linewrap signature in src and test make check_linewrap a free function
test for unimplemented method
delete unused imports
6c91245
to
86177be
Compare
1595d5e
to
ab3b235
Compare
OK, tests work and they pass! Hallelujah! I won't claim that it's beautiful, but it works, and I'm happy with that.
I think this is a combination of the plugins being namespace plugins and the main jrnl source being locally importable from the project root folder. Namespace plugins work be creating a "virtual" module out of several physical locations on disk; when importing the jrnl module from the project root (rather than from the site-packages folder where it's installed by pip), these namespace modules aren't recognized as namespace modules, and instead come up as empty. To test this: # navigate to the project root folder
# create a virtual environment and activate it
python -m venv .venv-test-plugins
source .venv-test-plugins/bin/activate
# on Windows: .\.venv-test-plugins\Scripts\activate
# install jrnl
pip install .
# install the test plugins
pip install ./tests/external_plugins_src/
# install behave
pip install behave
# run behave; note the number of steps completed
behave --format progress2
# 1738 steps passed, 0 failed, 163 skipped, 0 undefined
# now change up a folder and rerun behave
cd ..
behave --format progress2 ./jrnl/features
# 1664 steps passed, 0 failed, 237 skipped, 0 undefined In any case, I think we're ready to merge! @micahellison |
Thanks @minchinweb! I see this is ready for review, and I'll plan on diving into this in a week. Also, we won't merge anything big in before that so there won't be any more major merge conflicts to deal with. |
# Conflicts: # poetry.lock # pyproject.toml
Hi @minchinweb, I'm reviewing this while educating myself on namespace packages here and I see that there are three different approaches for namespace packages, but I can't tell which is being used in this PR. Or is there a completely different approach that it's using, and if so, what's the advantages of it? |
Hi @micahellison These are "native namespace packages" (the first option mentioned on the page you link to). Why this way? It seems to be the most "modern" option, and beyond getting the plugin files in the right place, there should be no packaging boilerplate for plugin authors. |
Got it, thanks. I agree that it makes sense -- I was just confused that the form of the sample plugin looked a little different from the documentation I linked. Then I learned more about Along those lines, I'm chatting about this with @wren and we think we have a solution to this folder issue you documented, by removing the two |
Actually, we're going to merge this into a feature branch so we can work on it a bit more asynchronously. |
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.
✨🔌✨
@micahellison I'm curious about what more needs to be done/what else you want in place before merging this to master... |
cc: #1006 |
Hi @minchinweb sorry for the slowness on this -- it's been a busy month. I just put my notes in the linked issue. |
@minchinweb Quick note: jrnl doesn't have a branch named |
* behavior outline * FIrst pass at allow external plugins * remove template exporter * Add listing of active plugins to '--version' output * Documentation for plugins * [Docs] add custom imports and exporters to site TOC * [Docs] better linewrapping * enforce positive initial linewrap Check column widths update gitignore throw error when linewrap too small simply check for large enough linewrap value * delete unused error message * PR feedback make exception more informative update check_linewrap signature in src and test make check_linewrap a free function * delete unused function * delete else..pass block * newline for make format * Include dates_exporter * Use Base classes for importer and exporters. * [Docs] improve documentation of custom Importers and Exporters * [Testing] separate run with external plugin! * basic behavior test * prototype unittest for JSON Exporter test for unimplemented method * make format delete unused imports * Remove 'importer' or 'exporter' from filenames where not needed * [Test] run different tests with or without the external plugins installed * [Test] move test rot13 plugin into git tree from minchinweb/jrnl-rot13-exporter@0dc912a * consolidate demo plugins to common package * [Docs] name page for plugins * [Docs] include the sample plug in code files directly * style fixes * [test] determine whether to run external plug in tests based on installed packages * improved code documentation * style fixes for GitHub actions * Convert "short" and "pretty" (and "default") formaters to plugins further to #1177 * more code clean up tests pass locally...now for GitHub... * [tests] dynamically determine jrnl version for plugin tests * [GitHub Actions] direct install of testing plugins * Remove template code * [plugins] meta --> collector * [Docs] create scripted entries using an custom importer * (closer to) being able to run behave tests outside project root directory * We already know when exporter to use Don't re-calculate it! * [Tests] don't name test plugin 'testing" If so named, pip won't install it. * [Test] run behave tests with test plugins outside project root * [Test] behave tests pass locally * [Docs] fix typo * [GitHub Actions] run test commands from poetry's shell * black-ify code * [GitHub Actions] move downstream (rather than up) to run tests * [GitHub Actions] set shell to poetry * [GitHub Workflows] Manually activate virtual environment * [GitHub Actions] Skip Windows & Python 3.8 Can't seem to find Python exe? * [GiotHub Actions] explicitly use virtual env * [GitHub Actions] create virutal env directly * [GitHub Actions] better activate of Windows virtual env * [GitHub Actions] create virtual env on Mac * [Github Actions] install wheel and upgrade pip * [GitHub Actions] skip virtual environments altogether * [GitHub Actions] change directory for behave test * Remove Windows exclusions from CI as per note -- they should be working now Co-authored-by: Suhas <[email protected]> Co-authored-by: Micah Jerome Ellison <[email protected]>
* behavior outline * FIrst pass at allow external plugins * remove template exporter * Add listing of active plugins to '--version' output * Documentation for plugins * [Docs] add custom imports and exporters to site TOC * [Docs] better linewrapping * enforce positive initial linewrap Check column widths update gitignore throw error when linewrap too small simply check for large enough linewrap value * delete unused error message * PR feedback make exception more informative update check_linewrap signature in src and test make check_linewrap a free function * delete unused function * delete else..pass block * newline for make format * Include dates_exporter * Use Base classes for importer and exporters. * [Docs] improve documentation of custom Importers and Exporters * [Testing] separate run with external plugin! * basic behavior test * prototype unittest for JSON Exporter test for unimplemented method * make format delete unused imports * Remove 'importer' or 'exporter' from filenames where not needed * [Test] run different tests with or without the external plugins installed * [Test] move test rot13 plugin into git tree from minchinweb/jrnl-rot13-exporter@0dc912a * consolidate demo plugins to common package * [Docs] name page for plugins * [Docs] include the sample plug in code files directly * style fixes * [test] determine whether to run external plug in tests based on installed packages * improved code documentation * style fixes for GitHub actions * Convert "short" and "pretty" (and "default") formaters to plugins further to #1177 * more code clean up tests pass locally...now for GitHub... * [tests] dynamically determine jrnl version for plugin tests * [GitHub Actions] direct install of testing plugins * Remove template code * [plugins] meta --> collector * [Docs] create scripted entries using an custom importer * (closer to) being able to run behave tests outside project root directory * We already know when exporter to use Don't re-calculate it! * [Tests] don't name test plugin 'testing" If so named, pip won't install it. * [Test] run behave tests with test plugins outside project root * [Test] behave tests pass locally * [Docs] fix typo * [GitHub Actions] run test commands from poetry's shell * black-ify code * [GitHub Actions] move downstream (rather than up) to run tests * [GitHub Actions] set shell to poetry * [GitHub Workflows] Manually activate virtual environment * [GitHub Actions] Skip Windows & Python 3.8 Can't seem to find Python exe? * [GiotHub Actions] explicitly use virtual env * [GitHub Actions] create virutal env directly * [GitHub Actions] better activate of Windows virtual env * [GitHub Actions] create virtual env on Mac * [Github Actions] install wheel and upgrade pip * [GitHub Actions] skip virtual environments altogether * [GitHub Actions] change directory for behave test * Remove Windows exclusions from CI as per note -- they should be working now Co-authored-by: Suhas <[email protected]> Co-authored-by: Micah Jerome Ellison <[email protected]>
c.f. jrnl-org/jrnl@e64ca2d This should fully merge jrnl-org/jrnl#1216
(This is a follow up to #1115 because in that one I pushed directly to develop, plus it's been squashed and rebased, and it proved easier in my head to make a new branch.)
The open "issues" from #1115:
jrnl --version
will show you the list of active plugins, include where they came from.jrnl --version
Sample
jrnl --version
output:For documentation, I would love to take insert the sample plugins from external files, and use those same external files as a base for the testing. Is the first part (inserting an external file) possible to MkDocs?
Also, the template exporter got dropped because I couldn't figure out how to make it work with displaying the version numbers... Is that okay?