Skip to content

New Plugin definition - #2074

Merged
SchrodingersGat merged 513 commits into
inventree:masterfrom
matmair:plugin-2037
Dec 4, 2021
Merged

SchrodingersGat merged 513 commits into
inventree:masterfrom
matmair:plugin-2037

Conversation

@matmair

@matmair matmair commented Sep 23, 2021 •

Copy link
Copy Markdown
Member

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

matmair commented Sep 28, 2021

Copy link
Copy Markdown
Member Author

@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
Copy Markdown
Contributor

@matmair Nice work! How can we test this?

@matmair

matmair commented Sep 29, 2021

Copy link
Copy Markdown
Member Author

@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
Copy Markdown
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

matmair commented Sep 30, 2021

Copy link
Copy Markdown
Member Author

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

matmair commented Oct 17, 2021

Copy link
Copy Markdown
Member Author

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

@SchrodingersGat SchrodingersGat left a comment

Copy link
Copy Markdown
Member

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

Comment thread InvenTree/InvenTree/urls.py Resolved
@matmair

matmair commented Oct 19, 2021

Copy link
Copy Markdown
Member Author

@SchrodingersGat this is ready for merge now!

@matmair

matmair commented Oct 19, 2021

Copy link
Copy Markdown
Member Author

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

@matmair

matmair commented Oct 30, 2021

Copy link
Copy Markdown
Member Author

@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
Copy Markdown
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

matmair commented Nov 4, 2021

Copy link
Copy Markdown
Member Author

@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
Copy Markdown
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

matmair commented Nov 11, 2021 •

Copy link
Copy Markdown
Member Author

@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

SchrodingersGat commented Nov 11, 2021 •

Copy link
Copy Markdown
Member

image

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

@SchrodingersGat

Copy link
Copy Markdown
Member

image

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

@matmair

matmair commented Nov 22, 2021

Copy link
Copy Markdown
Member Author

@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

matmair commented Nov 23, 2021

Copy link
Copy Markdown
Member Author

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

@SchrodingersGat

SchrodingersGat commented Dec 2, 2021 •

Copy link
Copy Markdown
Member

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
Copy Markdown
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

SchrodingersGat commented Dec 2, 2021 •

Copy link
Copy Markdown
Member

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

matmair commented Dec 3, 2021

Copy link
Copy Markdown
Member Author

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
Copy Markdown
Member

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

@matmair

matmair commented Dec 4, 2021

Copy link
Copy Markdown
Member Author

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

@matmair

matmair commented Dec 4, 2021

Copy link
Copy Markdown
Member Author

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

@SchrodingersGat

Copy link
Copy Markdown
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