Project-MONAI / MONAILabel

MONAI Label is an intelligent open source image labeling and learning tool.
https://docs.monai.io/projects/label
Apache License 2.0
626 stars 196 forks source link

Allow apps to create their own rest APIs #1764

Open AHarouni opened 1 month ago

AHarouni commented 1 month ago

Is your feature request related to a problem? Please describe. There are ways for an app to override and custom most of the classes. However, I can't find a way to overwrite or extend the rest APIs. I do need to create my own rest APIs and customize it

Describe the solution you'd like Have a way to get to get the restAPIinstance in the same way I can get the datastore as

    instance: MONAILabelApp = app_instance()
    datastore= instance.datastore()

It would be great if there is a function that the app can override as

_add_endpoint(self,routing_app):
# add code here to return or include new new restapis
rounting_app.include_router(....)

Describe alternatives you've considered I had to manually hack the the python packages as /usr/local/lib/python3.8/dist-packages/monailabel/app.py and add a global variable as

global global_routing_app 
global_routing_app = app

which I then define in my app as

global global_routing_app 
global_routing_app .include_router(xnat.router, prefix=settings.MONAI_LABEL_API_STR)