-
Notifications
You must be signed in to change notification settings - Fork 11
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
Build Executor (model) UI in Jina #16
Comments
Hi @Nick17t, I would like to contribute to this as part of GSoC 2023. Just trying to understand the plan here - are we looking to automatically build some thing similar to swagger ui for each jina executor (but using gradio)? Hi @alaeddine-13 , Any inputs here will help me to come up with a better proposal. pls let me know |
Project idea 1: Build Executor (model) UI in jina
Project Description
Expected outcomes
Install Jina: First, you need to install Jina. You can use pip to install it: Copy code Define your Executor: Next, you need to define your Executor. For example, you can define a simple Executor that takes a list of strings as input and returns the length of each string: from jina.executors import BaseExecutor class MyExecutor(BaseExecutor):
This code defines a MyExecutor class that inherits from Jina's BaseExecutor class. The MyExecutor class has an exec_fn method that takes a list of strings as input and returns the length of each string as a list. Define a Flow: Once you have defined your Executor, you need to define a Flow that uses your Executor. For example, you can define a Flow that takes input from a REST API endpoint and passes it to your Executor: from jina.flow import Flow flow = Flow().add( Define a REST API endpoint: Next, you need to define a REST API endpoint that accepts input data and passes it to your Flow. For example, you can define a Flask app with a route that accepts POST requests: python _**from flask import Flask, request, jsonify app = Flask(name)**_ @app.route('/api/execute', methods=['POST']) Run the Flask app: Finally, you need to run the Flask app to start the REST API endpoint: if name == 'main': That's it! With these steps, you should be able to build an Executor UI in Jina that uses a REST API endpoint to pass input data to your Executor and return the result. Of course, you will need to add more code to handle things like input validation, error handling, and authentication, but this should give you a good starting point. |
Hey @Asrst @ranjan2829 , I believe your understanding is correct. A jina model UI should work like a swagger UI in an HTTP framework. Then, the next step would be using this service specification endpoint to build a model UI. I think the following API can make sense:
or
In jina, this would request the Executor's service specifications over grpc and then will dynamically build the gradio interface. To sum it up, the proposed technologies are not necessarily what we need to adopt, as long as we implement the following:
|
@alaeddine-13 I appreciate the level of detail you have provided about the technical implementation of the feature, as well as the proposed API. It's great to see that you have already thought through many of the technical challenges and possible solutions. We will certainly consider your request and explore the feasibility of implementing it in a future release of Jina. As you mentioned, we may need to evaluate different technologies and frameworks to determine the best approach for implementing this feature, but we will definitely keep your proposed solution in mind. Thank you again for your interest in contributing to the development of Jina. If you have any further suggestions or feedback, please do not hesitate to let us know. Best regards, |
from jina import Flow, Executor class MyExecutorModel(Executor):
flow = Flow().add(MyExecutorModel) Define the input and output schema using DocArray v2 type hintsinput_schema = DocumentArrayMemmap( Define the Gradio interface for the MyExecutorModel's "foo" methoddef gradio_interface(inputs): Define the Model UI Gateway and configure it to use the Gradio interfacefrom jina.types.request import Response class ModelUIGateway(Gateway):
Use the Model UI Gateway to host the Gradio interface for the MyExecutorModel's "foo" methodgradio_interface = gr.Interface(fn=gradio_interface, inputs=gr.inputs.Group([gr.inputs.Textbox(label="Text"), gr.inputs.Image(label="Image")]), outputs="numpy") |
Dear Jina Team, |
i want to contribute in this project looking forward to work with you all. |
|
I would love to be part of this project, looking forward to contribute and learn a lot. |
Here is a proof of concept for the implementation of the project. @alaeddine-13
|
Hello @ranjan2829, Thanks for the details and starting code you have shared above. |
Dear @ranjan2829, Thank you for considering. |
Nice project, I look forward to making contributions and leaving an impact. |
Hello @ranjan2829, I would like to contribute to this project for GSOC 2023. I am new to open source contributions and I am excited to get into it. I want to learn more about Jina and hopefully make contributions to this project. Thank your for the wonderful idea. |
Hi @jamesbright @AkbarHabeeb @Asrst @asuzukosi @krishnabhaktanurag01 @MarcDavila1022 @robinokwanma @iamharshvardhan @giuliocn @ranjan2829 @wanaaqy99 I am delighted to hear that you are interested in contributing to the Jina AI community! 🎉 To get started, please take a moment to fill out our survey so that we can learn more about you and your skills. Also, don't forget to mark your calendars for the GSoC x Jina AI webinar on March 23rd at 2 pm (CET). This is an excellent opportunity to learn more about the projects and ask any questions you have about the requirements and expectations. Our mentors will provide an in-depth overview of the projects and answer any questions you may have. So please don't hesitate to ask any questions or seek clarification on any aspect of the project. Is there anything specific you would like to learn from the webinar? Do you have any questions about the Build Executor (model) UI in Jina project that you would like to see clarified during the Q&A session? Let me know, and I'll be happy to help! Looking forward to seeing you at the webinar, and thank you for your interest in the Jina AI community! 😊 |
Hello @ranjan2829, I would like to contribute to this project for GSOC 2023. I am new to open source contributions and I am excited to get into it. I want to learn more about Jina and hopefully make contributions to this project. |
Could we subclass from |
Hello @philipvollet @alaeddine-13. I would like to contribute to this project for the GSoC. I think this is a great idea and an interesting project. |
Hey @philipvollet @alaeddine-13, I would like to contribute for this project in GSoC 2023 as I find it interesting and I am familiar with the pre-requisite |
Hello @Nick17t @alaeddine-13! |
Hello @alaeddine-13 @philipvollet @Nick17t • Create a base executer class def exec_fn(self, input): I have to work with the input /output schema for DocArray v2 and define Gradio interface for the executor created . After this we have to define the Model UI Gateway and integrate to use it with Gradio interface . |
Hello @Nick17t I really love to contribute to this project for GSOC 2023. I am new to open source contributions and I don't know anything. I have tried googling and saw a bunch of you tube videos but it made me confuse more and ended up understanding nothing about the open source contributions for gsoc..... If you don't mind can you help me with the open source contributions, like how can we contribute to them Thank you in advance |
Hello, @Nick17t I really love to contribute to this project, since I had experience with this type of work earlier in my last semester. It will be very helpful if you give me a chance to work with you. I have done 2 research also in the field of machine learning and computer vision, along with this I have made multiple technologies that are very useful for society such as Seasonal Sale Prediction, University Admission Prediction, and many more. I sure giving me a chance to work under your guidance will never let your efforts go in vain. Looking forward to a positive response from your side. Regards |
Hello, @Nick17t I have an intermediate knowledge in Python and I am a beginner in open source projects. I would really love to learn and contribute in this project. Thanks for considering. Regards |
Hello @alaeddine-13 could you please tell me that whether this project is open for GSOC 2024. If yes then it is very exciting for me to work on this project. |
hello team ! If yes , I wish to contribute |
Project idea 1: Build Executor (model) UI in jina
Project Brief Description
Detailed Description
A jina model UI should work like a swagger UI in an HTTP framework.
A swagger UI typically relies on an OpenAPI specifications to know about the services and input output schema, and then will generate the UI based on that.
However, jina executors rely on gRPC and gRPC do not expose OpenAPI. This means we either have to implement an OpenAPI equivalent for gRPC services that Executors expose or adopt a certain standard (I like the kserve).
Building such a service specification depends on knowing exactly the needed input and output schemas.
Jina can now support defining input and output schemas of the endpoints using the docarray v2 in beta support.
The API looks like this actually: https://docs.jina.ai/concepts/executor/docarray-v2/.
This means that, assuming an executor is built using DocArray v2 in type annotations, we can generate service specifications in the same way FastAPI generates open API specifications based on pydantic type hints.
Then, the next step would be using this service specification endpoint to build a model UI.
This can be done using gradio.
However, since we cannot serve a UI on the executor's gRPC service, we can only host the UI on the gateway level.
jina gateways recently added support for customization.
The new support allows basically building any server based on any protocol.
This means, a gateway can target an Executor within a jina flow and expose the UI for it.
I think the following API can make sense:
or
In jina, this would request the Executor's service specifications over grpc and then will dynamically build the gradio interface.
To sum it up, the proposed technologies are not necessarily what we need to adopt, as long as we implement the following:
Expected outcomes
The text was updated successfully, but these errors were encountered: