Skip to content
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

plugin complement #409

Merged
merged 42 commits into from
Jan 24, 2022
Merged

plugin complement #409

merged 42 commits into from
Jan 24, 2022

Conversation

christophe-david
Copy link
Contributor

@christophe-david christophe-david commented Jan 13, 2022

This PR implements an enhanced plugin system and closes #393.

It contains following modifications:

  • Documentation has been updated. Preview is here.
  • Plugin declaration now uses fastoad.plugins as group name instead of fastoad_model
    • The previous group name fastoad_model is still usable, though not mentioned anymore in RTD documentation. It works the same as before, i.e. it expects to have only FAST-OAD modules in the declared plugin package.
    • When using the new group name, configuration files and notebooks can be part of the plugin, and a certain folder structure is expected in the plugin package (see doc).
  • The implemented modifications make that models are loaded only at first instantiation of the new class FastoadLoader. Then the loading is not made anymore at startup, which greatly speeds up commands like fastoad -h or fastoad -v.
  • CLI and API have been updated (see doc):
    • modified configuration file generation to allow to choose which plugin to use to generate a configuration file
    • modified notebook creation to possibly limit the generated notebooks to the one from a specified plugin. Also, fastoad.api now contains a create_notebooks() method.
    • added a command to get plugin information.
  • Modified and added commands in CLI are now unit-tested. It starts the resolution of Testing CLI #407.
  • The test of the plugin mechanism has been made independent of actual declared plugins using fixtures in contest.py. It has been rather painful to achieve that 😅.
  • Usage of pkg_resources has been removed to use importlib.metadata as it is now recommended.
  • tests/testing_utilities.py has been moved to src/fastoad/_utils/testing.py so that there shouldn't be anymore warning when importing copied models in other projects.

@christophe-david christophe-david force-pushed the issue-393_plugin-complement branch 2 times, most recently from bbef8ab to 3feba43 Compare January 14, 2022 14:41
@codecov
Copy link

codecov bot commented Jan 14, 2022

Codecov Report

Merging #409 (61cab9d) into master (4213a19) will increase coverage by 1.00%.
The diff coverage is 89.37%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #409      +/-   ##
==========================================
+ Coverage   90.89%   91.90%   +1.00%     
==========================================
  Files         201      203       +2     
  Lines        8153     8409     +256     
  Branches      854      915      +61     
==========================================
+ Hits         7411     7728     +317     
+ Misses        586      504      -82     
- Partials      156      177      +21     
Impacted Files Coverage Δ
src/fastoad/api.py 100.00% <ø> (ø)
src/fastoad/exceptions.py 75.00% <0.00%> (-10.72%) ⬇️
src/fastoad/__init__.py 60.00% <57.14%> (-17.78%) ⬇️
src/fastoad/module_management/_bundle_loader.py 94.26% <70.58%> (-1.87%) ⬇️
src/fastoad/_utils/resource_management/contents.py 76.47% <76.47%> (ø)
src/fastoad/cmd/exceptions.py 84.61% <77.77%> (-15.39%) ⬇️
src/fastoad/module_management/_plugins.py 90.66% <90.41%> (-9.34%) ⬇️
src/fastoad/cmd/api.py 91.00% <92.06%> (+0.25%) ⬆️
src/fastoad/_utils/resource_management/copy.py 96.55% <94.11%> (-3.45%) ⬇️
src/fastoad/_utils/testing.py 83.33% <100.00%> (ø)
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4213a19...61cab9d. Read the comment docs.

@christophe-david christophe-david force-pushed the issue-393_plugin-complement branch 2 times, most recently from 90237d7 to c42545f Compare January 17, 2022 20:24
Copy link
Contributor

@ScottDelbecq ScottDelbecq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR!
This is really what I had in mind for the plugin features.
I have a small suggestion for the documentation (c.f. my only comment).

The command :code:`poetry build` will create a :code:`dist` folder with two files:

:code:`ST_drive_models-1.0.0.tar.gz` and :code:`ST_drive_models-1.0.0-py3-none-any.whl`
(or something like this).

You may then have sent any of those two files to another user, who may then install your models
using :code:`pip` with:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the section "Publishing" I would underline that to publish on PyPi the package name will be the one provided in the field name in the pyproject.toml. Therefore, the publisher shall check that the chosen package name is not already taken on PyPi.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Done in a64d130.

@christophe-david christophe-david merged commit b9c242e into master Jan 24, 2022
@christophe-david christophe-david deleted the issue-393_plugin-complement branch January 24, 2022 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom configuration files could be associated to custom modules
2 participants