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

Introduce WeaviateAsyncClient as async alternative to WeaviateClient #1007

Draft
wants to merge 52 commits into
base: main
Choose a base branch
from

Conversation

tsmith023
Copy link
Contributor

@tsmith023 tsmith023 commented Apr 12, 2024

  • Changes base implementation to be purely async using httpx and grpclib(instead of google's grpc due to issues)
  • Uses base implementation in WeaviateAsyncClient directly
  • A class decorator pattern wraps the async implementation in the sync routes replication the arguments and docstrings automagically @dirkkul
  • Replace WeaviateClient internal calls with event-loop-wrapped blocking calls using the base async implementation
  • An event loop thread is spun up by the client at instantiation as a global singleton that is used in all calls
  • client.batch is only available on the WeaviateClient object, since it is a purely sync algorithm. It depends on the new higher-level event loop thread

- Changes base implementation to be purely async using `httpx` and `grpclib`(instead of google's grpc due to [issues](grpc/grpc#25364))
- Uses base implementation in `WeaviateAsyncClient` directly
- Subdivides the codebase into `**/asy/*.py` and `**/sy/*.py` directories within each namespace directory
- Replace `WeaviateClient` internal calls with event-loop-wrapped blocking calls using the base async implementation
- `WeaviateClient` spins up its own personal event loop thread that it schedules async calls to. Should this be a global singleton instead?
- `client.batch` is only available on the `WeaviateClient` object, since it is a purely sync algorithm. It depends on the new higher-level event loop thread
@weaviate-git-bot
Copy link

Great to see you again! Thanks for the contribution.

beep boop - the Weaviate bot 👋🤖

PS:
Are you already a member of the Weaviate Slack channel?

@rolandgvc
Copy link

I'm following this as well. I'm looking forward to the async client :)

@tsmith023 tsmith023 self-assigned this May 15, 2024
@tsmith023 tsmith023 added the enhancement New feature or request label May 15, 2024
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 92.21184% with 125 lines in your changes are missing coverage. Please review.

Project coverage is 94.12%. Comparing base (9fa261f) to head (5617f76).
Report is 26 commits behind head on main.

Files Patch % Lines
weaviate/client.py 83.70% 22 Missing ⚠️
weaviate/collections/collection/async_.py 74.02% 20 Missing ⚠️
weaviate/collections/iterator.py 78.26% 10 Missing ⚠️
weaviate/event_loop.py 82.45% 10 Missing ⚠️
weaviate/connect/v4.py 91.26% 9 Missing ⚠️
integration/conftest.py 79.41% 7 Missing ⚠️
weaviate/collections/collections/async_.py 87.75% 6 Missing ⚠️
weaviate/collections/collection/sync.py 86.48% 5 Missing ⚠️
weaviate/connect/authentication_async.py 95.40% 4 Missing ⚠️
weaviate/collections/aggregations/base.py 83.33% 3 Missing ⚠️
... and 20 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1007      +/-   ##
==========================================
- Coverage   94.56%   94.12%   -0.45%     
==========================================
  Files         181      200      +19     
  Lines       18825    19492     +667     
==========================================
+ Hits        17802    18346     +544     
- Misses       1023     1146     +123     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Async Client to be able to make asynchronous requests
4 participants