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

New Plugin definition #2074

Merged
merged 513 commits into from Dec 4, 2021
Merged

New Plugin definition #2074

merged 513 commits into from Dec 4, 2021

Conversation

matmair
Copy link
Member

@matmair matmair commented Sep 23, 2021

This is a heavy PR for #2037.
It adds a new plugin system with database controlled plugins, wide integration into InvenTree, a pluggable mixin system so that integrations are easily made, live-reloading of apps so no server admin is needed for plugin changes, a maintenance mode while plugins reload (errors out to 503), ...
Plugins can be loaded from a directory or from the 'inventree_plugins' entry_point. Metadata about the latest git commit or metadata in the plugin class are used to inform admins about the different plugins.
Initial integrations are:

  • navigation
  • urls
  • global settings
  • full Django apps

Includes #2049 as that is needed for a few showcase mixins.
Closes #2037
Closes #2218
Closes #2295
Closes #2294
Closes #2293
Closes #2292
Closes #2305
Closes #2318
Closes #2308

@matmair matmair self-assigned this Sep 23, 2021
@matmair matmair added the plugin Plugin ecosystem label Sep 23, 2021
@matmair matmair added this to the 0.6.0 milestone Sep 23, 2021
@matmair matmair changed the title New Plugin defintion New Plugin definition Sep 23, 2021
@matmair matmair marked this pull request as ready for review September 28, 2021 22:43
@matmair
Copy link
Member Author

matmair commented Sep 28, 2021

@SchrodingersGat @eeintech the PoC / basics for the 'new' plugin system are laid. There is a lot still missing for a full ecosystem but this should be a good base to start on.
My idea is that every base function will be separated out into mixins so devs need to write the least possible code for interaction with InvenTree and concentrate on the developing.

@eeintech
Copy link
Contributor

@matmair Nice work! How can we test this?

@matmair
Copy link
Member Author

matmair commented Sep 29, 2021

@matmair Nice work! How can we test this?

@eeintech there are multiple (simple) samples included. If you access the settings you will discover a plugin section after the server stuff. You can click through the different plugins and see what they define. I am currently finishing a basic Shopify 'integration' that will be a better example.

@SchrodingersGat
Copy link
Member

Very excited to check this out @matmair

I should have some more time after the imminent 0.5.0 release to look at this. Sorry, have been totally swamped with work + life :)

@matmair
Copy link
Member Author

matmair commented Sep 30, 2021

Very excited to check this out @matmair

I should have some more time after the imminent 0.5.0 release to look at this. Sorry, have been totally swamped with work + life :)

We all do this as a hobby, no worries. If you get to it in half a year it should still work😇.

@matmair matmair marked this pull request as draft October 5, 2021 23:53
@matmair matmair marked this pull request as ready for review October 8, 2021 20:18
@matmair matmair marked this pull request as draft October 14, 2021 00:10
@matmair matmair marked this pull request as ready for review October 17, 2021 18:39
@matmair
Copy link
Member Author

matmair commented Oct 17, 2021

@SchrodingersGat @eeintech any idea what is stoping this test? Can not reproduce locally with docker.

Copy link
Member

@SchrodingersGat SchrodingersGat left a comment

Choose a reason for hiding this comment

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

@matmair see comment here regarding workflow failure

InvenTree/InvenTree/urls.py Outdated Show resolved Hide resolved
@matmair
Copy link
Member Author

matmair commented Oct 19, 2021

@SchrodingersGat this is ready for merge now!

@matmair
Copy link
Member Author

matmair commented Oct 19, 2021

@eeintech @SchrodingersGat docs are now done inventree/inventree-docs#192

@matmair
Copy link
Member Author

matmair commented Oct 30, 2021

@SchrodingersGat had time to look at this? Already have lined up a few improvements lined up to start building a small ecosystem around the plugins and like 4 more mixin-types but gonna wait till you/@eeintech have had a look and it is clear the direction fits the project.

@SchrodingersGat
Copy link
Member

@matmair not yet, but very soon. I want to close out the following PRs first and then I'll have some clear air. I do want to get to this ASAP so it does not drag on!

@matmair
Copy link
Member Author

matmair commented Nov 4, 2021

@SchrodingersGat @eeintech plugins can now be installed as pip packages:
https://test.pypi.org/project/ShopifyIntegrationPlugin/

Also the migrations are slowly colliding

@SchrodingersGat
Copy link
Member

@matmair wow, this is huge! i'm starting to read through the code, can you give me some pointers on where to start to look at the functionality?

@matmair
Copy link
Member Author

matmair commented Nov 11, 2021

@matmair wow, this is huge!

It grew a lot due to all the refactoring for 0.6.0

i'm starting to read through the code, can you give me some pointers on where to start to look at the functionality?

I would recommend reading the docs first. They give a good overview of what all the components do in the end.
Then I would start with everything not in the 'InvenTree/plugin' folder. There you will find the integrations into apps, urls, settings, navigation.

@SchrodingersGat
Copy link
Member

SchrodingersGat commented Nov 11, 2021

image

Pretty simple, the breadcrumb-list block simply appears twice in the settings/settings.html template file

@SchrodingersGat
Copy link
Member

image

This is what greeted my once I turned on the "enable navigation" and "enable URL" settings and restarted the server

@matmair
Copy link
Member Author

matmair commented Nov 22, 2021

@SchrodingersGat I think this should be ready for its final round of reviews. I will try to add a few more tests but coverage is at +94%. I refactored a lot from the last time you took a look - Nearly all plugin code is now in InvenTree/plugin.
Broken code should not block startup etc anymore, there are checks on collection and initiation of plugins now. Runtime-errors still brick the system - I have a crude system that blocks that already but the performance impact is around 15% so I am searching for a better way.
Plugin-wide settings should be part of a separate PR.

@matmair
Copy link
Member Author

matmair commented Nov 23, 2021

@SchrodingersGat there seem to be problems with the images for mysql / postgres checks. Maybe it will run later again

@SchrodingersGat
Copy link
Member

SchrodingersGat commented Dec 2, 2021

image

As above:

  • Add class "panel-heading" to the "Plugin List" and "Plugin Error Stack" titles
  • Move buttons to the right
  • Fix spelling :)

@SchrodingersGat
Copy link
Member

Generally looking pretty good though. Once the workflows are fixed I'm happy to merge this in so we can continue with the other plugin-related issues :)

@SchrodingersGat
Copy link
Member

SchrodingersGat commented Dec 2, 2021

image

Hmmm this is a strange one. Looks like the logout screen is broken for this PR?

image

And the login screen too... Have the account URLs changed?

@matmair
Copy link
Member Author

matmair commented Dec 3, 2021

image

Hmmm this is a strange one. Looks like the logout screen is broken for this PR?

image

And the login screen too... Have the account URLs changed?

Not really but I will check in the evening

using c instead of k does not make it Englisch
@SchrodingersGat
Copy link
Member

@matmair keen to get this one merged if you can take a look at the conflict and the logout / login screen issues :)

@matmair
Copy link
Member Author

matmair commented Dec 4, 2021

@SchrodingersGat still trying to understand why the templates do not load. Will try to get this done today.

@matmair
Copy link
Member Author

matmair commented Dec 4, 2021

@SchrodingersGat figured it out, it was the ordering of the template loaders

@SchrodingersGat
Copy link
Member

Ok, looks good now :) Thanks for the huge effort on this @matmair ! Let's get the other linked PRs sorted now

@SchrodingersGat SchrodingersGat merged commit 7ba0161 into inventree:master Dec 4, 2021
@matmair matmair deleted the plugin-2037 branch December 4, 2021 21:52
SchrodingersGat added a commit to inventree/inventree-docs that referenced this pull request Dec 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment