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

[Serve] Expose FastAPI docs path #32863

Merged
merged 12 commits into from
Mar 2, 2023
Merged

Conversation

zcin
Copy link
Contributor

@zcin zcin commented Feb 27, 2023

Why are these changes needed?

For FastAPI integrated applications, we want to expose the Open api docs path.

Related issue number

#32878

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 :(

zcin added 3 commits February 27, 2023 11:50
Signed-off-by: Cindy Zhang <cindyzyx9@gmail.com>
Signed-off-by: Cindy Zhang <cindyzyx9@gmail.com>
Signed-off-by: Cindy Zhang <cindyzyx9@gmail.com>
Signed-off-by: Cindy Zhang <cindyzyx9@gmail.com>
@zcin zcin marked this pull request as ready for review February 28, 2023 02:15
python/ray/serve/tests/test_fastapi.py Outdated Show resolved Hide resolved
python/ray/serve/_private/client.py Outdated Show resolved Hide resolved
zcin added 2 commits February 28, 2023 10:12
Signed-off-by: Cindy Zhang <cindyzyx9@gmail.com>
Signed-off-by: Cindy Zhang <cindyzyx9@gmail.com>
@@ -51,6 +51,7 @@ def __init__(
self.deploy_obj_ref = deploy_obj_ref
self.app_msg = ""
self.route_prefix = None
self.fastapi_docs_path = None
Copy link
Contributor

Choose a reason for hiding this comment

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

This should not be tied directly to fastapi, we may support other docs links in the future (e.g., if there is a different HTTP wrapper or users provide their own).

Let's call it docs_path everywhere except in the fastapi-specific code.

zcin added 2 commits February 28, 2023 10:54
Signed-off-by: Cindy Zhang <cindyzyx9@gmail.com>
Signed-off-by: Cindy Zhang <cindyzyx9@gmail.com>
Comment on lines 97 to 106
assert num_route_prefixes <= 1, (
f"Found multiple route prefix from application {self.name},"
" Please specify only one route prefix for the application "
"to avoid this issue."
)
assert num_fastapi_deployments <= 1, (
f"Found multiple FastAPI deployments from application {self.name}. "
"Please only use one FastAPI deployment in your application to avoid "
"this issue."
)
Copy link
Contributor

Choose a reason for hiding this comment

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

please add test cases for these! we should also not use assert for any user-facing error messages (it's written like it might be one)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added! I also changed the error message to be more generic in case we decide to expand usage of docs_path in the future.

Copy link
Contributor

Choose a reason for hiding this comment

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

nice thank you

zcin added 2 commits February 28, 2023 12:56
Signed-off-by: Cindy Zhang <cindyzyx9@gmail.com>
Signed-off-by: Cindy Zhang <cindyzyx9@gmail.com>
Copy link
Contributor

@shrekris-anyscale shrekris-anyscale left a comment

Choose a reason for hiding this comment

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

Nice work, the code mostly looks good! Are you planning to add docs in this PR or a separate PR?

"to avoid this issue."
)

if "docs_path" in deploy_param and deploy_param["docs_path"] is not None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if "docs_path" in deploy_param and deploy_param["docs_path"] is not None:
if deploy_param.get("docs_path") is not None:

@zcin
Copy link
Contributor Author

zcin commented Mar 1, 2023

Nice work, the code mostly looks good! Are you planning to add docs in this PR or a separate PR?

Since this is not yet a user-facing variable, I was not planning on adding docs yet. Is there some part of this PR that you think we should add to the docs?

When I add the metadata REST endpoint, this will be one of the metadata fields so it will be documented there; also, in the future as Ed suggested we may support other docs links that users themselves provide, and we would probably document that as well. WDYT?

zcin added 2 commits March 1, 2023 11:30
Signed-off-by: Cindy Zhang <cindyzyx9@gmail.com>
Signed-off-by: Cindy Zhang <cindyzyx9@gmail.com>
@edoakes
Copy link
Contributor

edoakes commented Mar 1, 2023

@zcin @shrekris-anyscale I don't think it's worth adding any public-facing documentation for this at the moment.

Copy link
Contributor

@shrekris-anyscale shrekris-anyscale left a comment

Choose a reason for hiding this comment

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

Sounds good, this change looks good to me!

@zcin
Copy link
Contributor Author

zcin commented Mar 1, 2023

Link check failing on master & unrelated.

@edoakes edoakes merged commit fdf9866 into ray-project:master Mar 2, 2023
@zcin zcin deleted the serve-fastapi branch March 3, 2023 19:49
ProjectsByJackHe pushed a commit to ProjectsByJackHe/ray that referenced this pull request Mar 21, 2023
For FastAPI integrated applications, we want to expose the Open api docs path.

Signed-off-by: Jack He <jackhe2345@gmail.com>
edoakes pushed a commit to edoakes/ray that referenced this pull request Mar 22, 2023
For FastAPI integrated applications, we want to expose the Open api docs path.

Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
peytondmurray pushed a commit to peytondmurray/ray that referenced this pull request Mar 22, 2023
For FastAPI integrated applications, we want to expose the Open api docs path.
elliottower pushed a commit to elliottower/ray that referenced this pull request Apr 22, 2023
For FastAPI integrated applications, we want to expose the Open api docs path.

Signed-off-by: elliottower <elliot@elliottower.com>
ProjectsByJackHe pushed a commit to ProjectsByJackHe/ray that referenced this pull request May 4, 2023
For FastAPI integrated applications, we want to expose the Open api docs path.

Signed-off-by: Jack He <jackhe2345@gmail.com>
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.

4 participants