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

Open
wants to merge 67 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-commenter commented May 31, 2024

Codecov Report

Attention: Patch coverage is 93.47692% with 106 lines in your changes missing coverage. Please review.

Project coverage is 94.37%. Comparing base (6516ca4) to head (b28ebbd).
Report is 5 commits behind head on main.

Files Patch % Lines
integration/conftest.py 78.02% 20 Missing ⚠️
weaviate/collections/collection/async_.py 77.77% 12 Missing ⚠️
weaviate/event_loop.py 80.70% 11 Missing ⚠️
weaviate/connect/v4.py 91.26% 9 Missing ⚠️
integration/test_collection_async.py 90.00% 7 Missing ⚠️
weaviate/collections/collections/async_.py 87.75% 6 Missing ⚠️
weaviate/client_base.py 93.42% 5 Missing ⚠️
weaviate/collections/collection/sync.py 82.14% 5 Missing ⚠️
weaviate/connect/authentication_async.py 95.40% 4 Missing ⚠️
weaviate/collections/batch/base.py 93.61% 3 Missing ⚠️
... and 18 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1007      +/-   ##
==========================================
- Coverage   94.62%   94.37%   -0.25%     
==========================================
  Files         182      197      +15     
  Lines       18870    19548     +678     
==========================================
+ Hits        17855    18449     +594     
- Misses       1015     1099      +84     

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

integration/test_client.py Show resolved Hide resolved
integration/test_collection.py Outdated Show resolved Hide resolved
integration/test_collection_aggregate.py Outdated Show resolved Hide resolved
profiling/test_profiling.py Outdated Show resolved Hide resolved
weaviate/client.py Show resolved Hide resolved
weaviate/collections/collection/sync.py Show resolved Hide resolved
weaviate/collections/tenants/async_.py Outdated Show resolved Hide resolved
weaviate/event_loop.py Show resolved Hide resolved
weaviate/embedded.py Outdated Show resolved Hide resolved
weaviate/connect/v4.py Show resolved Hide resolved
@tsmith023 tsmith023 marked this pull request as ready for review June 7, 2024 10:43
@tsmith023 tsmith023 requested a review from a team as a code owner June 7, 2024 10:43
@tsmith023 tsmith023 requested a review from dirkkul June 7, 2024 10:43
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
5 participants