milvus-io / pymilvus

Python SDK for Milvus.
Apache License 2.0
1.03k stars 326 forks source link

[Bug]: [milvus_client_p2] The check rule for the parameter "collection_name" of "flush" interface is not consistent with that of "create_collection" interface #2354

Open binbinlv opened 4 hours ago

binbinlv commented 4 hours ago

Is there an existing issue for this?

Describe the bug

The check rule for the parameter "collection_name" of "flush" interface is not consistent with that of "create_collection" interface

when collection_name is "12-s", create collection reports error "f"Invalid collection name: {collection_name}. the first character of a collection name must be an underscore or letter: invalid parameter"

but flush( "12-s") reports "collection not found[database=default][collection=12-s]"

>>> milvus_client.create_collection(collection_name="12-s", dimension=8)
RPC error: [create_collection], <MilvusException: (code=1100, message=Invalid collection name: 12-s. the first character of a collection name must be an underscore or letter: invalid parameter)>, <Time:{'RPC start': '2024-11-15 16:14:50.873458', 'RPC error': '2024-11-15 16:14:50.898214'}>
Failed to create collection: 12-s
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/milvus_client/milvus_client.py", line 80, in create_collection
    return self._fast_create_collection(
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/milvus_client/milvus_client.py", line 140, in _fast_create_collection
    raise ex from ex
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/milvus_client/milvus_client.py", line 136, in _fast_create_collection
    conn.create_collection(collection_name, schema, timeout=timeout, **kwargs)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 141, in handler
    raise e from e
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 137, in handler
    return func(*args, **kwargs)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 176, in handler
    return func(self, *args, **kwargs)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 116, in handler
    raise e from e
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 86, in handler
    return func(*args, **kwargs)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/client/grpc_handler.py", line 309, in create_collection
    check_status(status)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/client/utils.py", line 63, in check_status
    raise MilvusException(status.code, status.reason, status.error_code)
pymilvus.exceptions.MilvusException: <MilvusException: (code=1100, message=Invalid collection name: 12-s. the first character of a collection name must be an underscore or letter: invalid parameter)>
>>>
>>>
>>> milvus_client.flush(collection_name="12-s")
RPC error: [flush], <MilvusException: (code=100, message=collection not found[database=default][collection=12-s])>, <Time:{'RPC start': '2024-11-15 16:15:37.485106', 'RPC error': '2024-11-15 16:15:37.561322'}>
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/milvus_client/milvus_client.py", line 1067, in flush
    conn.flush([collection_name], timeout=timeout, **kwargs)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 141, in handler
    raise e from e
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 137, in handler
    return func(*args, **kwargs)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 176, in handler
    return func(self, *args, **kwargs)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 116, in handler
    raise e from e
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 86, in handler
    return func(*args, **kwargs)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/client/grpc_handler.py", line 1458, in flush
    check_status(response.status)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/client/utils.py", line 63, in check_status
    raise MilvusException(status.code, status.reason, status.error_code)
pymilvus.exceptions.MilvusException: <MilvusException: (code=100, message=collection not found[database=default][collection=12-s])>

Expected Behavior

The check rule for the parameter "collection_name" of "flush" interface is consistent with that of "create_collection" interface

Steps/Code To Reproduce behavior

from pymilvus import MilvusClient
milvus_client = MilvusClient()
milvus_client.create_collection(collection_name="12-s", dimension=8)
milvus_client.flush(collection_name="12-s")

Environment details

- Hardware/Softward conditions (OS, CPU, GPU, Memory):
- Method of installation (Docker, or from source):
- Milvus version (v0.3.1, or v0.4.0):  master-20241115-d1596297-amd64
- Pymilvus version: 2.5.0rc121
- Milvus configuration (Settings you made in `server_config.yaml`):

Anything else?

No response

binbinlv commented 4 hours ago

/assign @czs007