-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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: improve update_docs for openapi schema #2169
Conversation
.github/workflows/autodocs.yaml
Outdated
- name: Install Protoc | ||
uses: arduino/setup-protoc@v1 | ||
- name: Clean unused files | ||
run: | | ||
sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android | ||
sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is that coming from ?Feels very random I don't think it' anywhere in our current CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea it is strange but was in tests.yml here
text-generation-inference/.github/workflows/tests.yaml
Lines 41 to 46 in 0759ec4
- name: Install Protoc | |
uses: arduino/setup-protoc@v1 | |
- name: Clean unused files | |
run: | | |
sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android | |
sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET |
In general I'd love to avoid rebuilding the server in this workflow, but it may be needed for this check
@@ -192,7 +190,6 @@ | |||
"Text Generation Inference" | |||
], | |||
"summary": "Generate a stream of token using Server-Sent Events", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are the descriptions gone ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is related to an upstream change where utopia added support for a custom description instead of using the same value for both description and summary (related PRs juhaku/utoipa#781 and juhaku/utoipa#948).
"example": "user" | ||
"oneOf": [ | ||
{ | ||
"$ref": "#/components/schemas/TextMessage" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels the cleaner types also help here, no ?
update_doc.py
Outdated
|
||
|
||
if __name__ == "__main__": | ||
main() | ||
parser = argparse.ArgumentParser( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep the simpler version that just checks everything by default ?
instead just add check_openapi
function ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep that makes sense, updated in the latest commits
update_doc.py
Outdated
|
||
args = parser.parse_args() | ||
process = subprocess.Popen( | ||
["text-generation-launcher"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use an extremely small model ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe to simplify we could add a flag in router
in order to print the openapi directly ?
Would remove the necessity to compile things (except the router).
I know I said internally I didn't like that option, but I also said after that you were right since I didn't have a better idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated and added a text-generation-router print-schema
command that prints the api docs as JSON and exits, if no command is passed it goes through the normal flow
update_doc.py
Outdated
json.dump(new_data, f, indent=2) | ||
|
||
|
||
def compare_openapi(old_data, new_data): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly I wouldn't even ever parse the files and simply reuse some simple diffing.
diff = subprocess.run(
["diff", tmp, filename], capture_output=True
).stdout.decode("utf-8")
print(diff)
Not strong opinion, your code seems to provide cleaner output, but given the unreadableness of the original JSON file, I'm not sure it's worth potentially making mistakes in that diff algorithm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good points! I think diff
is a better long term solution and the pr has been updated to use diff
* feat: add pre commit step to force schema update when router changes * fix: prefer improved update_doc and start server and compare * fix: adjust typo * fix: adjust revert typo * fix: update workflow to use update_doc md command * feat: improve workflow to check openapi schema too * fix: adjust timeout for CI * fix: adjust raise condition and install server in ci * fix: install protoc before server * feat: improve update doc and add command to print router schema * fix: adjust autodoc workflow * fix: explicitly install protoc and python * fix: alllow trailing space in openapi schema diff
* feat: add pre commit step to force schema update when router changes * fix: prefer improved update_doc and start server and compare * fix: adjust typo * fix: adjust revert typo * fix: update workflow to use update_doc md command * feat: improve workflow to check openapi schema too * fix: adjust timeout for CI * fix: adjust raise condition and install server in ci * fix: install protoc before server * feat: improve update doc and add command to print router schema * fix: adjust autodoc workflow * fix: explicitly install protoc and python * fix: alllow trailing space in openapi schema diff
This PR aims to help sync the openapi schema
via a combination of pre-commit hooks and a new cli arg to dump the spec fileThis PR now updates
update_doc.py
to have two commands allowing callers to update the launcher docs and or the openapi spec