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

[Jobs] [Doc] Add Jobs openapi spec and REST API documentation #30417

Merged
merged 10 commits into from
Nov 21, 2022

Conversation

architkulkarni
Copy link
Contributor

@architkulkarni architkulkarni commented Nov 17, 2022

Why are these changes needed?

  • Adds an OpenAPI spec for the Jobs REST API
  • Adds an API doc page using Redoc.

The spec was generated via a combination of pydantic automatic schema generation, github copilot, and manual entry, but this won't be maintainable in the long term. When we move the dashboard server to FastAPI, this spec can be automatically generated.

Link to the doc page built from this PR: https://ray--30417.org.readthedocs.build/en/30417/cluster/running-applications/job-submission/rest.html

Screen Shot 2022-11-17 at 8 52 02 AM

Related issue number

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

Signed-off-by: Archit Kulkarni <[email protected]>
Signed-off-by: Archit Kulkarni <[email protected]>
Signed-off-by: Archit Kulkarni <[email protected]>
Signed-off-by: Archit Kulkarni <[email protected]>
Signed-off-by: Archit Kulkarni <[email protected]>
openapi: 3.1.0
info:
title: Ray Jobs API
version: 4.0.0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The /api/version returns "4", not "4.0.0". Do these need to be kept in sync?

@@ -59,6 +59,7 @@ sphinxcontrib.yt==0.2.2
sphinx-sitemap==2.2.0
sphinx-thebe==0.1.1
autodoc_pydantic==1.6.1
sphinxcontrib-redoc==1.6.0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't have a particular reason to pin the version here, just following what's been done for other sphinx extensions

@edoakes
Copy link
Contributor

edoakes commented Nov 17, 2022

@architkulkarni re: the process to generate the documentation, at a minimum we need to document how to do this in case others make changes in the future. Could you add a short README somewhere in the code?

@edoakes
Copy link
Contributor

edoakes commented Nov 17, 2022

This is fantastic though!

Signed-off-by: Archit Kulkarni <[email protected]>
Signed-off-by: Archit Kulkarni <[email protected]>
@architkulkarni
Copy link
Contributor Author

@edoakes Good point, I added a note to job_head.py

Comment on lines 148 to 151
NOTE(architkulkarni): Please keep this class in sync with the OpenAPI spec at
`doc/source/cluster/running-applications/job-submission/openapi.yml`.
We currently do not automatically check that the OpenAPI
spec is in sync with the implementation.
Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't know how to do this from the description alone, can you include instructions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@edoakes updated, let me know if any parts are unclear

Copy link
Contributor

@DmitriGekhtman DmitriGekhtman left a comment

Choose a reason for hiding this comment

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

stamp

Copy link
Contributor

@edoakes edoakes left a comment

Choose a reason for hiding this comment

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

Suggest to get a review from @alanwguo before merging

@@ -0,0 +1,471 @@
openapi: 3.1.0
Copy link
Contributor

Choose a reason for hiding this comment

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

is this file manually written? Did we consider switching the jobs api to use fast-api which has the ability to automatically generate openapi spec from the route definitions?

@rkooo567 and I have been chatting about doing a fast-api migration in the next 6 months so that we can have openapi specs for all of our APIs. If we are to do that, there's a chance that this spec will be slightly modified because it's generated instead of manually written. Will that be disruptive to users?

Copy link
Contributor Author

@architkulkarni architkulkarni Nov 21, 2022

Choose a reason for hiding this comment

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

@alanwguo Yeah, migrating Jobs to FastAPI makes sense as the long term plan, we just didn't have time to do it for Ray 2.2. I think by marking the OpenAPI section of the doc as "Beta" as it currently is marked this PR, it should be okay if there are slight modifications in the future. The underlying API is stable and once we migrate to FastAPI we can mark the OpenAPI doc as "stable" as well.

Copy link
Contributor

@dmatrix dmatrix left a comment

Choose a reason for hiding this comment

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

minor nits. You can incorporate them if they make sense or add clarity. LGTM

paths in the @route decorators or in the Responses returned by the
methods (or any nested fields in the Responses), you will need to find the
corresponding field of the OpenAPI yaml file and update it manually, and
bump the version number in the yaml file and in this class's `get_version`.
Copy link
Contributor

Choose a reason for hiding this comment

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

The sentence is long. I would break it.

"update it manually." Also, bump the version number in the yaml file and in this class's get_version.

summary: |
Get Version
description: |
Get the Ray Jobs API version and the Ray version running on the cluster.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use possessive here? Ray Jobs' API? If so then change in all description below.
I guess this would be tantamount to asking "Get Python's version" or "Get Python version."

I think either would work. But a grammar pedantic would suggest otherwise.

type: object
properties:
version:
description: The version of the Ray Jobs API running on the server.
Copy link
Contributor

Choose a reason for hiding this comment

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

Which one reads declaratively:
"The version of the Ray Jobs API running on the server." or
"Ray Jobs' API version running on the server."

- name: submission_id
in: path
description: |
The ID of the job to tail the logs of.
Copy link
Contributor

Choose a reason for hiding this comment

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

Ending with a proposition could read awkward in some cases. Would this be simpler: "Tail job ID's logs."

title: Job Id
description: >-
The job id. An id that is created for every job that is launched in ray.
This can be used to fetch data about jobs using ray core apis.
Copy link
Contributor

Choose a reason for hiding this comment

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

launched in Ray.

title: Job Id
description: >-
The job id. An id that is created for every job that is launched in ray.
This can be used to fetch data about jobs using ray core apis.
Copy link
Contributor

Choose a reason for hiding this comment

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

This can --> This id can be used to ...

title: Submission Id
description: >-
A submission id is an id created for every submission job. It can be used
to fetch data about jobs using the job submission apis.
Copy link
Contributor

Choose a reason for hiding this comment

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

The antecedent is ambiguous here. Does it refer to id or job. It normally refers to the last antecedent, which is job, and that is incorrect.

Suggest use "This id can be used to fetch ...

@architkulkarni
Copy link
Contributor Author

Thanks @dmatrix, I will incorporate these in a follow-up PR!

@architkulkarni architkulkarni merged commit 4e39367 into ray-project:master Nov 21, 2022
WeichenXu123 pushed a commit to WeichenXu123/ray that referenced this pull request Dec 19, 2022
…oject#30417)

Adds an OpenAPI spec for the Jobs REST API
Adds an API doc page using Redoc.

Signed-off-by: Weichen Xu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants