-
Notifications
You must be signed in to change notification settings - Fork 30
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
Own plugins for Jupyverse #439
Comments
There is no need to add plugins to this repository, all you need is to create a package which has the following in its [project.entry-points]
"asphalt.components" = {my_package = "my_package.main:MyComponent"}
"jupyverse.components" = {my_package = "my_package.main:MyComponent"} And something like the following in from asphalt.core import Component, Context
from fastapi import APIRouter, Depends
from jupyverse_api import Router
from jupyverse_api.app import App
from jupyverse_api.auth import Auth, User
class MyComponent(Component):
async def start(
self,
ctx: Context,
) -> None:
app = await ctx.request_resource(App)
auth = await ctx.request_resource(Auth)
resource = Resource(app, auth)
ctx.add_resource(resource)
class Resource(Router):
def __init__(
self,
app: App,
auth: Auth,
) -> None:
super().__init__(app=app, auth=auth)
router = APIRouter()
@router.get("/")
async def get_root(
user: User = Depends(auth.current_user())
) -> str:
return "Hello"
self.include_router(router) |
Ok, I have a plugin as a module that lies next to the main project. How will Jupyverse understand that it needs to pull it up? Do I need to install my plugin as a package as a dependency in the main pyproject.toml, where jupyverse also lies as a dependency, or is it possible to run jupyverse with some flag? |
Jupyverse will start all components that are registered in the [project.entry-points]
"asphalt.components" = {my_package = "my_package.main:MyComponent"}
"jupyverse.components" = {my_package = "my_package.main:MyComponent"} |
In your first answer you said that you need to add these fields to pyproject.toml of the package itself. Or should it be in pyproject.toml of the main application, where my_package will be in the dependencies of this project next to jupyverse? |
The entry points should be defined in the |
Hello everyone, there was a need to write my own additional plugins for Jupuverse, there is no documentation for this as such, depending on how the main plugins are written, it seems to be clear how they are written, basically new handles seem to be added there, and the logic of these handles is written. But how to add your own plugin to Jupyverse is not entirely clear; do you need to fork it and add it to plugins and rewrite the source code, or are there more convenient ways to add your own plugins?
The text was updated successfully, but these errors were encountered: