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

Expose API Handler #333

Merged
merged 9 commits into from
Dec 20, 2023
Merged

Expose API Handler #333

merged 9 commits into from
Dec 20, 2023

Conversation

eyurtsev
Copy link
Collaborator

@eyurtsev eyurtsev commented Dec 15, 2023

  • Exposes the underlying API handler, so that developers can use it directly.
  • Document more of the API handler methods.
  • Adds an optional server_config to each endpoint on the API handler to provide developers with maximal flexibility in terms of specifying configuration dynamically.

@@ -381,7 +381,14 @@ def _add_callbacks(
config["callbacks"].extend(callbacks)


class _APIHandler:
_MODEL_REGISTRY = {}
Copy link
Contributor

Choose a reason for hiding this comment

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

what is this used for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Even though I wrote the code I was wondering the same today :)

I'll try update the doc-string later -- it was needed to fix up some behavior associated with fast api / open api specs and having the same pydantic model appear multiple times causing the open api docs to crash, so instead this helps to look up an existing model if it was already seen (instead of creating a duplicate)


chain = RunnableLambda(add_one)

api_handler = APIHandler(chain, "/simple")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a more realistic scenario we can show this with?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah probably should!

I think another example though -- this example has complexity coming from the doc-generation itself.

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 name the example to make it more clear then it's about doc generation? I feel like people may not understand why this example exists / what it does that's special

@eyurtsev eyurtsev merged commit 245ace4 into main Dec 20, 2023
10 checks passed
@eyurtsev eyurtsev deleted the eugene/expose_api_handler branch December 20, 2023 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants