Skip to content

Build Executor (model) UI in Jina #16

Open
@Nick17t

Description

@Nick17t

Project idea 1: Build Executor (model) UI in jina

info details
Skills needed Python
Project size 175 hours
Difficulty level Easy
Mentors @Alaeddine Abdessalem, @Philip Vollet

Project Brief Description

  • Jina Executors are components that perform certain tasks and expose them as services using gRPC. Executors accept DocumentArrays as input and output. However, with DocArray v2 focusing on type annotations and enabling annotation of executor endpoints, it becomes possible for executors to describe their services and input/output in the same way as OpenAPI schemas. This allows us to offer built-in UIs for executors, enabling people to easily use their services with multi-modal data. The goal is to build this feature in Jina using Gradio.

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:

from jina import Flow

flow = Flow(protocol='ui').add(MyExecutorModel)

or

from jina import Flow, ModelUIGateway

flow = Flow().config_gateway(uses=ModelUIGateway).add(MyExecutorModel)

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:

  • Executor service specifications (like OpenAPI specifications in http) based on DocArray v2 type hints
  • Leverage the service specifications to build a model UI gateway. The UI Gateway is a custom Jina gateway and can use any framework (gradio, streamlit or even any web framework).
  • Integrate the model ui gateway into jina (offer simple API to use it)

Expected outcomes

  • Submit one or more Pull Requests (PRs) to the Jina repository that enables providing a built-in Executor UI for Executors. The UI can be built using Gradio and should be able to infer information about the Executor service using type annotations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions