-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 resources from API routes ending in / #926
Conversation
Reviewer ChecklistPlease leverage this checklist to ensure your code review is thorough before approving Testing, Bugs, Errors, Logs, Documentation
System Compatibility
Quality
|
Thanks! Docs generation readme is here - https://github.com/chroma-core/docs#generating-python-docs (and right below for js) I'd expect there to be no diff in either when we rerun them, thanks for checking |
chromadb/server/fastapi/__init__.py
Outdated
@@ -69,6 +69,29 @@ def _uuid(uuid_str: str) -> UUID: | |||
raise InvalidUUIDError(f"Could not parse {uuid_str} as a UUID") | |||
|
|||
|
|||
class APIRouter(fastapi.APIRouter): |
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.
Nit - let's not stomp the fastapi name for the class
chromadb/server/fastapi/__init__.py
Outdated
"include_in_schema" in kwargs and not kwargs["include_in_schema"] | ||
) | ||
|
||
kwargs["include_in_schema"] = not exclude_from_schema and not path.endswith("/") |
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.
extreme nit - duplicated logic (feel free to ignore this, just calling it out)
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.
Approved pending nits, the testing we discussed and CI! Thank you!
I'm fairly confident I checked all of those correctly but not 100%. So if this causes trouble down the line feel free to revert and @ me. Also addressed your other comments :^) |
@beggers yep that PR cleans it up :) |
@beggers looks great! I'll merge after CI passes shortly. |
Description of changes
#895
Serve registered API routes regardless of whether they end in "/".
In the linked bug @HammadB and I discussed looping over all the routes at the end of
__init__
, but the typechecker complains: the only thing we know aboutself._app.routes
is that they're instances ofBaseRoute
, which may not have the fields we need. Rather than do type coercion I subclassedfastapi.APIRouter
.The logic to set
kwargs["include_in_schema"]
is maybe too clever, should we just do an if-else instead?Test plan
Also,
pytest
locally and CI. I'd like to confirm this doesn't break JS client generation and doc generation -- how can I do that?Documentation Changes
Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the docs repository?
No documentation changes needed for this.