Skip to content
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

feat: provide openapi doc #370

Merged
merged 18 commits into from
Jun 13, 2023
Merged

feat: provide openapi doc #370

merged 18 commits into from
Jun 13, 2023

Conversation

n063h
Copy link
Contributor

@n063h n063h commented May 28, 2023

ref to #359

Description

Provide openapi json doc for users to build their api-reference or swagger site.

How it works

mosec will inspect input/return variable to figure out their type schema in the python end, save them into json schema file. Only the input variable of Ingress and the return variable of Egress worker will be inspected.

Since Rust side can't have access to python varible type, so here I set placeholder types InferenceRequest and InferenceResponse, and replace them with the json schema generated in python side.

Signed-off-by: hang lv <xlv20@fudan.edu.cn>
@github-actions github-actions bot added the enhancement New feature or request label May 28, 2023
@n063h n063h marked this pull request as draft May 28, 2023 15:51
n063h added 3 commits May 29, 2023 00:22
Signed-off-by: hang lv <xlv20@fudan.edu.cn>
Signed-off-by: hang lv <xlv20@fudan.edu.cn>
Signed-off-by: hang lv <xlv20@fudan.edu.cn>
@n063h n063h marked this pull request as ready for review May 28, 2023 18:01
src/main.rs Outdated Show resolved Hide resolved
mosec/mixin/typed_worker.py Outdated Show resolved Hide resolved
mosec/mixin/typed_worker.py Outdated Show resolved Hide resolved
mosec/mixin/typed_worker.py Outdated Show resolved Hide resolved
mosec/server.py Outdated Show resolved Hide resolved
mosec/server.py Outdated Show resolved Hide resolved
src/apidoc.rs Outdated Show resolved Hide resolved
src/apidoc.rs Outdated Show resolved Hide resolved
src/apidoc.rs Outdated Show resolved Hide resolved
op.request_body.as_mut()
}

fn get_route_responses<'a>(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to have an explicit lifetime?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I annotated lifetime on more functions which ware removed under clippy's warning.
I didn't really understand this part, will continue to learn.

mosec/mixin/typed_worker.py Outdated Show resolved Hide resolved
mosec/mixin/typed_worker.py Outdated Show resolved Hide resolved
src/apidoc.rs Outdated Show resolved Hide resolved
Signed-off-by: hang lv <xlv20@fudan.edu.cn>
@n063h n063h marked this pull request as draft May 29, 2023 19:49
n063h added 2 commits May 30, 2023 04:55
Signed-off-by: hang lv <xlv20@fudan.edu.cn>
Signed-off-by: hang lv <xlv20@fudan.edu.cn>
@kemingy kemingy linked an issue Jun 1, 2023 that may be closed by this pull request
@kemingy
Copy link
Member

kemingy commented Jun 1, 2023

Is it ready to review?

@n063h
Copy link
Contributor Author

n063h commented Jun 1, 2023

Is it ready to review?

It works, but needs to be improved.
In the last commit, I tried to integrate the input/output/components schemas to simplify the interface. But it led to extra components schema. I'm working on it to make it simple and correct.
Besides, though it's ok for current demand, building only ingress request and egress response may be a bit dumb and inflexible. I'm going to build a complete openapi spec, making the rust end more robust and general.

n063h added 5 commits June 8, 2023 12:24
Signed-off-by: Xing Lv <xlv20@fudan.edu.cn>
Signed-off-by: hang lv <xlv20@fudan.edu.cn>
Signed-off-by: Xing Lv <xlv20@fudan.edu.cn>
Signed-off-by: Xing Lv <xlv20@fudan.edu.cn>
@n063h n063h marked this pull request as ready for review June 8, 2023 04:58
@n063h
Copy link
Contributor Author

n063h commented Jun 8, 2023

I'm adding some test cases on it. The maintainers can have a look at the updates now.

mosec/mixin/typed_worker.py Outdated Show resolved Hide resolved
mosec/mixin/typed_worker.py Outdated Show resolved Hide resolved
mosec/server.py Outdated Show resolved Hide resolved
mosec/server.py Outdated Show resolved Hide resolved
mosec/worker.py Outdated Show resolved Hide resolved
mosec/worker.py Outdated Show resolved Hide resolved
mosec/utils/types.py Outdated Show resolved Hide resolved
src/main.rs Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
Signed-off-by: Xing Lv <xlv20@fudan.edu.cn>
@n063h n063h marked this pull request as draft June 11, 2023 19:21
Signed-off-by: hang lv <xlv20@fudan.edu.cn>
Signed-off-by: hang lv <xlv20@fudan.edu.cn>
@n063h n063h marked this pull request as ready for review June 12, 2023 06:16
mosec/mixin/typed_worker.py Outdated Show resolved Hide resolved
mosec/mixin/typed_worker.py Outdated Show resolved Hide resolved
mosec/worker.py Outdated Show resolved Hide resolved
src/apidoc.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
src/apidoc.rs Outdated Show resolved Hide resolved
tests/test_service.py Outdated Show resolved Hide resolved
tests/openapi_service.py Outdated Show resolved Hide resolved
tests/test_service.py Outdated Show resolved Hide resolved
Signed-off-by: hang lv <xlv20@fudan.edu.cn>
src/apidoc.rs Outdated Show resolved Hide resolved
src/apidoc.rs Outdated Show resolved Hide resolved
tests/openapi_service.py Outdated Show resolved Hide resolved
Signed-off-by: hang lv <xlv20@fudan.edu.cn>
@kemingy kemingy enabled auto-merge June 13, 2023 09:55
@kemingy kemingy added this pull request to the merge queue Jun 13, 2023
Merged via the queue into mosecorg:main with commit 3dcac43 Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: generate the OpenAPI doc from the typed request annotation
2 participants