Skip to content

[Bug]: TypeError if consistency_level is passed to Collection.delete #2327

@ofir-ov

Description

@ofir-ov

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When I do

my_collection.delete(expr='...', consistency_level='Strong')  # Or any `consistency_level` for that matter

I get the following error:

    @retry_on_rpc_failure()
    def delete(
        self,
        collection_name: str,
        expression: str,
        partition_name: Optional[str] = None,
        timeout: Optional[float] = None,
        **kwargs,
    ):
        check_pass_param(collection_name=collection_name, timeout=timeout)
        try:
>           req = Prepare.delete_request(
                collection_name,
                partition_name,
                expression,
                consistency_level=kwargs.get("consistency_level", 0),
                param_name=kwargs.pop("param_name", None),
                **kwargs,
            )
E           TypeError: pymilvus.client.prepare.Prepare.delete_request() got multiple values for keyword argument 'consistency_level'

/usr/local/lib/python3.12/site-packages/pymilvus/client/grpc_handler.py:597: TypeError

Expected Behavior

To not fail

Steps/Code To Reproduce behavior

All you need to do is pass the consistency_level to the delete method. This bug is directly due to the use of kwargs.get in the function in order to populate a "new" keyword argument called consistency_level in addition to the existing one. It should happen no matter the other circumstances.

Environment details

- Hardware/Softward conditions: (OS: `6.10.0-linuxkit` Docker Desktop on Mac running Linux using the image `python:3.12-slim`, CPU: Apple M2 Pro, Memory: 8GB)
- Method of installation (Docker, or from source): A Docker image, as mentioned above. I'm using LangChain, so technically not calling the collection directly. `langchain-milvus==0.1.4`
- Milvus version (v0.3.1, or v0.4.0): Milvus is running using the Docker image `milvusdb/milvus:v2.4.6`
- Milvus configuration (Settings you made in `server_config.yaml`): Didn't change anything.

Anything else?

The bug is inherit in that call in the code, it basically will never work if consistency_level is provided. It looks like a direct result of this change: cb4cbc6

The solution could be to change the .get to .pop but it's worth making sure it's not going to be a problem with the line

                f = MutationFuture(future, cb, timeout=timeout, **kwargs)

which is also inside this function (I wasn't able to fully follow the logic of MutationFuture).

Metadata

Metadata

Assignees

Labels

kind/bugSomething isn't working

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions