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

Can't create shard key with async grpc client #788

Closed
joein opened this issue Sep 24, 2024 · 1 comment
Closed

Can't create shard key with async grpc client #788

joein opened this issue Sep 24, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@joein
Copy link
Member

joein commented Sep 24, 2024

from qdrant_client import AsyncQdrantClient, models

async def main():
    cl = AsyncQdrantClient(prefer_grpc=True)
    cn = "cn"
    if await cl.collection_exists(cn):
        await cl.delete_collection(cn)
    await cl.create_collection(
        cn,
        shard_number=2,
        vectors_config=models.VectorParams(size=2, distance=models.Distance.COSINE),
        sharding_method=models.ShardingMethod.CUSTOM,
    )
    await cl.create_shard_key(cn, shard_key="first")
    await cl.create_shard_key(cn, shard_key="second")
    cn_info = await cl.get_collection(cn)
    print(cn_info.config.params.shard_number)
    print(cn_info.config.params.sharding_method)


if __name__ == '__main__':
    import asyncio

    asyncio.run(main())

Traceback:

Traceback (most recent call last):
  File ".../qdrant_client/check.py", line 46, in <module>
    asyncio.run(main())
  File ".../.pyenv/versions/3.10.12/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File ".../.pyenv/versions/3.10.12/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File ".../qdrant_client/check.py", line 36, in main
    await cl.create_shard_key(cn, shard_key="first")
  File ".../qdrant_client/qdrant_client/async_qdrant_client.py", line 2651, in create_shard_key
    return await self._client.create_shard_key(
  File ".../qdrant_client/qdrant_client/async_qdrant_remote.py", line 2768, in create_shard_key
    request = await grpc.CreateShardKey(
TypeError: object CreateShardKey can't be used in 'await' expression
@joein joein added the bug Something isn't working label Sep 24, 2024
@joein
Copy link
Member Author

joein commented Sep 24, 2024

#785

@joein joein closed this as completed Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant