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

Support retrieving partial responses from endpoints (refactor for pydantic 2.10) #20

Open
devraj opened this issue Dec 14, 2023 · 2 comments
Assignees
Milestone

Comments

@devraj
Copy link
Member

devraj commented Dec 14, 2023

Endpoint such as searches allow providing a parameters called fields which is an enum of fields which the response ends up returning e.g href, id, name, type, division, serverDisplayName, notes

The string must not contain any spaces. Just alphanumerics, underscores, commas, and dots.

This would mean we would have to make all fields in our Response objects optional.

We should also validate that the input is in fact an acceptable response field name.

@devraj
Copy link
Member Author

devraj commented Oct 31, 2024

pydantic has official support for this as of v2.10.

Rather than make the values optional, we should consider moving up to v2.10 and use the partial validation feature

@devraj devraj changed the title Support retrieving partial responses from endpoints Support retrieving partial responses from endpoints (refactor for pydantic 2.10) Oct 31, 2024
@devraj
Copy link
Member Author

devraj commented Nov 2, 2024

Using yield and async callbacks in Python serve different purposes, and the choice depends on the behavior you need:

  • Callback Approach: Suitable for simple async tasks where you want to pass a result to a specific function once the task completes, as shown in the previous example.
  • Using yield with Generators: Useful when you want to produce a series of results over time, especially when processing a large dataset or streaming data. In async scenarios, yield can be used in asynchronous generators with async for, which is ideal for processing multiple chunks of data as they become available.

devraj added a commit that referenced this issue Nov 6, 2024
updates to pydantic210 to investigate the partial validation feature
which will make #20 easier
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

No branches or pull requests

1 participant