From 40cde1d0adf8bd47ee401da5fc5aa775afd9e834 Mon Sep 17 00:00:00 2001 From: Rohit Gupta Date: Thu, 20 Jun 2024 16:17:24 +0530 Subject: [PATCH 01/11] return array data type in infer_dtype_bydata Signed-off-by: Rohit Gupta Signed-off-by: r0g0bum --- pymilvus/orm/types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymilvus/orm/types.py b/pymilvus/orm/types.py index eebbb50bc..af9d9e7c8 100644 --- a/pymilvus/orm/types.py +++ b/pymilvus/orm/types.py @@ -121,7 +121,7 @@ def infer_dtype_bydata(data: Any): failed = True if not failed: d_type = dtype_str_map.get(type_str, DataType.UNKNOWN) - return DataType.FLOAT_VECTOR if is_numeric_datatype(d_type) else DataType.UNKNOWN + return DataType.FLOAT_VECTOR if is_numeric_datatype(d_type) else DataType.ARRAY if d_type == DataType.UNKNOWN: try: From 87ae1c34a22750e62699ed92190e5dc3032ac13a Mon Sep 17 00:00:00 2001 From: Rohit Gupta Date: Thu, 20 Jun 2024 16:23:26 +0530 Subject: [PATCH 02/11] return array data type in infer_dtype_bydata Signed-off-by: Rohit Gupta Signed-off-by: r0g0bum --- pymilvus/orm/types.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pymilvus/orm/types.py b/pymilvus/orm/types.py index af9d9e7c8..c17a57040 100644 --- a/pymilvus/orm/types.py +++ b/pymilvus/orm/types.py @@ -123,6 +123,7 @@ def infer_dtype_bydata(data: Any): d_type = dtype_str_map.get(type_str, DataType.UNKNOWN) return DataType.FLOAT_VECTOR if is_numeric_datatype(d_type) else DataType.ARRAY + if d_type == DataType.UNKNOWN: try: elem = data[0] From 85f7797c325efe835f58fa84cf1477e8b701ea43 Mon Sep 17 00:00:00 2001 From: Rohit Gupta Date: Thu, 20 Jun 2024 16:23:33 +0530 Subject: [PATCH 03/11] return array data type in infer_dtype_bydata Signed-off-by: Rohit Gupta Signed-off-by: r0g0bum --- pymilvus/orm/types.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pymilvus/orm/types.py b/pymilvus/orm/types.py index c17a57040..af9d9e7c8 100644 --- a/pymilvus/orm/types.py +++ b/pymilvus/orm/types.py @@ -123,7 +123,6 @@ def infer_dtype_bydata(data: Any): d_type = dtype_str_map.get(type_str, DataType.UNKNOWN) return DataType.FLOAT_VECTOR if is_numeric_datatype(d_type) else DataType.ARRAY - if d_type == DataType.UNKNOWN: try: elem = data[0] From debb42f4aa520b008a723965e42b88596a3c09c0 Mon Sep 17 00:00:00 2001 From: Rohit Gupta Date: Thu, 27 Jun 2024 09:18:20 +0530 Subject: [PATCH 04/11] add array data type for milvus vector store collection create Signed-off-by: Rohit Gupta Signed-off-by: r0g0bum --- pymilvus/orm/types.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pymilvus/orm/types.py b/pymilvus/orm/types.py index af9d9e7c8..cd3628cb5 100644 --- a/pymilvus/orm/types.py +++ b/pymilvus/orm/types.py @@ -70,6 +70,11 @@ def is_float_datatype(data_type: DataType): def is_numeric_datatype(data_type: DataType): return is_float_datatype(data_type) or is_integer_datatype(data_type) +def is_varchar_datatype(data_type: DataType): + return data_type in (DataType.VARCHAR,) + +def is_bool_datatype(data_type: DataType): + return data_type in (DataType.BOOL,) # pylint: disable=too-many-return-statements def infer_dtype_by_scalar_data(data: Any): @@ -105,7 +110,7 @@ def infer_dtype_by_scalar_data(data: Any): return DataType.UNKNOWN -def infer_dtype_bydata(data: Any): +def infer_dtype_bydata(data: Any, **kargs): d_type = DataType.UNKNOWN if is_scalar(data): return infer_dtype_by_scalar_data(data) @@ -121,7 +126,17 @@ def infer_dtype_bydata(data: Any): failed = True if not failed: d_type = dtype_str_map.get(type_str, DataType.UNKNOWN) - return DataType.FLOAT_VECTOR if is_numeric_datatype(d_type) else DataType.ARRAY + if is_varchar_datatype(d_type) or is_bool_datatype(d_type): + return DataType.ARRAY + if kargs is None or len(kargs) == 0: + return DataType.FLOAT_VECTOR if \ + is_numeric_datatype(d_type) else DataType.UNKNOWN + else: + if kargs["type"] is not None and kargs["type"] == "vector": + return DataType.FLOAT_VECTOR \ + if is_numeric_datatype(d_type) else DataType.UNKNOWN + else: + return DataType.ARRAY if d_type == DataType.UNKNOWN: try: From 76c0593db87929fcd585ce3c5c9c980c244b9d46 Mon Sep 17 00:00:00 2001 From: Rohit Gupta Date: Thu, 27 Jun 2024 09:19:03 +0530 Subject: [PATCH 05/11] add array data type for milvus vector store collection create Signed-off-by: Rohit Gupta Signed-off-by: r0g0bum --- pymilvus/orm/types.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pymilvus/orm/types.py b/pymilvus/orm/types.py index cd3628cb5..27edc68c4 100644 --- a/pymilvus/orm/types.py +++ b/pymilvus/orm/types.py @@ -70,12 +70,15 @@ def is_float_datatype(data_type: DataType): def is_numeric_datatype(data_type: DataType): return is_float_datatype(data_type) or is_integer_datatype(data_type) + def is_varchar_datatype(data_type: DataType): return data_type in (DataType.VARCHAR,) + def is_bool_datatype(data_type: DataType): return data_type in (DataType.BOOL,) + # pylint: disable=too-many-return-statements def infer_dtype_by_scalar_data(data: Any): if isinstance(data, float): From 8521df5fa251950e160971cef3fcc082c9b1e29a Mon Sep 17 00:00:00 2001 From: Rohit Gupta Date: Thu, 27 Jun 2024 09:37:58 +0530 Subject: [PATCH 06/11] add array data type for milvus vector store collection create Signed-off-by: Rohit Gupta Signed-off-by: r0g0bum --- pymilvus/orm/types.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pymilvus/orm/types.py b/pymilvus/orm/types.py index 27edc68c4..1c513b1d0 100644 --- a/pymilvus/orm/types.py +++ b/pymilvus/orm/types.py @@ -113,7 +113,7 @@ def infer_dtype_by_scalar_data(data: Any): return DataType.UNKNOWN -def infer_dtype_bydata(data: Any, **kargs): +def infer_dtype_bydata(data: Any, **kwargs): d_type = DataType.UNKNOWN if is_scalar(data): return infer_dtype_by_scalar_data(data) @@ -131,11 +131,11 @@ def infer_dtype_bydata(data: Any, **kargs): d_type = dtype_str_map.get(type_str, DataType.UNKNOWN) if is_varchar_datatype(d_type) or is_bool_datatype(d_type): return DataType.ARRAY - if kargs is None or len(kargs) == 0: + if kwargs is None or len(kargs) == 0: return DataType.FLOAT_VECTOR if \ is_numeric_datatype(d_type) else DataType.UNKNOWN else: - if kargs["type"] is not None and kargs["type"] == "vector": + if kwargs["type"] is not None and kwargs["type"] == "vector": return DataType.FLOAT_VECTOR \ if is_numeric_datatype(d_type) else DataType.UNKNOWN else: From fea309d709943ca0a7729a95f96256efa6b4a394 Mon Sep 17 00:00:00 2001 From: r0g0bum Date: Thu, 4 Jul 2024 23:36:01 +0530 Subject: [PATCH 07/11] reformatted Signed-off-by: r0g0bum --- pymilvus/orm/types.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pymilvus/orm/types.py b/pymilvus/orm/types.py index 1c513b1d0..4a208520a 100644 --- a/pymilvus/orm/types.py +++ b/pymilvus/orm/types.py @@ -132,12 +132,12 @@ def infer_dtype_bydata(data: Any, **kwargs): if is_varchar_datatype(d_type) or is_bool_datatype(d_type): return DataType.ARRAY if kwargs is None or len(kargs) == 0: - return DataType.FLOAT_VECTOR if \ - is_numeric_datatype(d_type) else DataType.UNKNOWN + return DataType.FLOAT_VECTOR if is_numeric_datatype(d_type) else DataType.UNKNOWN else: if kwargs["type"] is not None and kwargs["type"] == "vector": - return DataType.FLOAT_VECTOR \ - if is_numeric_datatype(d_type) else DataType.UNKNOWN + return ( + DataType.FLOAT_VECTOR if is_numeric_datatype(d_type) else DataType.UNKNOWN + ) else: return DataType.ARRAY From 27e3c7e38decbd1bb727a03daa919234317aad12 Mon Sep 17 00:00:00 2001 From: r0g0bum Date: Fri, 5 Jul 2024 08:45:53 +0530 Subject: [PATCH 08/11] reformatted Signed-off-by: r0g0bum --- pymilvus/orm/types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymilvus/orm/types.py b/pymilvus/orm/types.py index 4a208520a..746dde065 100644 --- a/pymilvus/orm/types.py +++ b/pymilvus/orm/types.py @@ -131,7 +131,7 @@ def infer_dtype_bydata(data: Any, **kwargs): d_type = dtype_str_map.get(type_str, DataType.UNKNOWN) if is_varchar_datatype(d_type) or is_bool_datatype(d_type): return DataType.ARRAY - if kwargs is None or len(kargs) == 0: + if kwargs is None or len(kwargs) == 0: return DataType.FLOAT_VECTOR if is_numeric_datatype(d_type) else DataType.UNKNOWN else: if kwargs["type"] is not None and kwargs["type"] == "vector": From b779ad28c20b7c186ef74c25accbfff3c5a9648f Mon Sep 17 00:00:00 2001 From: r0g0bum Date: Fri, 5 Jul 2024 08:47:51 +0530 Subject: [PATCH 09/11] reformatted Signed-off-by: r0g0bum --- pymilvus/orm/types.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pymilvus/orm/types.py b/pymilvus/orm/types.py index 746dde065..3f8706ff6 100644 --- a/pymilvus/orm/types.py +++ b/pymilvus/orm/types.py @@ -133,13 +133,12 @@ def infer_dtype_bydata(data: Any, **kwargs): return DataType.ARRAY if kwargs is None or len(kwargs) == 0: return DataType.FLOAT_VECTOR if is_numeric_datatype(d_type) else DataType.UNKNOWN + elif kwargs["type"] is not None and kwargs["type"] == "vector": + return ( + DataType.FLOAT_VECTOR if is_numeric_datatype(d_type) else DataType.UNKNOWN + ) else: - if kwargs["type"] is not None and kwargs["type"] == "vector": - return ( - DataType.FLOAT_VECTOR if is_numeric_datatype(d_type) else DataType.UNKNOWN - ) - else: - return DataType.ARRAY + return DataType.ARRAY if d_type == DataType.UNKNOWN: try: From 871486c0b40e782df38b90a26685b01adcec4a7a Mon Sep 17 00:00:00 2001 From: r0g0bum Date: Fri, 5 Jul 2024 09:05:33 +0530 Subject: [PATCH 10/11] reformatted Signed-off-by: r0g0bum --- pymilvus/orm/types.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pymilvus/orm/types.py b/pymilvus/orm/types.py index 3f8706ff6..438e24767 100644 --- a/pymilvus/orm/types.py +++ b/pymilvus/orm/types.py @@ -131,9 +131,7 @@ def infer_dtype_bydata(data: Any, **kwargs): d_type = dtype_str_map.get(type_str, DataType.UNKNOWN) if is_varchar_datatype(d_type) or is_bool_datatype(d_type): return DataType.ARRAY - if kwargs is None or len(kwargs) == 0: - return DataType.FLOAT_VECTOR if is_numeric_datatype(d_type) else DataType.UNKNOWN - elif kwargs["type"] is not None and kwargs["type"] == "vector": + if kwargs is None or len(kwargs) == 0 or (kwargs["type"] is not None and kwargs["type"] == "vector"): return ( DataType.FLOAT_VECTOR if is_numeric_datatype(d_type) else DataType.UNKNOWN ) From cadea3f3b8400d5ba3594403c493288a0cb93efc Mon Sep 17 00:00:00 2001 From: r0g0bum Date: Fri, 5 Jul 2024 17:49:19 +0530 Subject: [PATCH 11/11] reformatted, Signed-off-by: r0g0bum --- pymilvus/orm/types.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pymilvus/orm/types.py b/pymilvus/orm/types.py index 438e24767..fae883fa8 100644 --- a/pymilvus/orm/types.py +++ b/pymilvus/orm/types.py @@ -131,10 +131,12 @@ def infer_dtype_bydata(data: Any, **kwargs): d_type = dtype_str_map.get(type_str, DataType.UNKNOWN) if is_varchar_datatype(d_type) or is_bool_datatype(d_type): return DataType.ARRAY - if kwargs is None or len(kwargs) == 0 or (kwargs["type"] is not None and kwargs["type"] == "vector"): - return ( - DataType.FLOAT_VECTOR if is_numeric_datatype(d_type) else DataType.UNKNOWN - ) + if ( + kwargs is None + or len(kwargs) == 0 + or (kwargs["type"] is not None and kwargs["type"] == "vector") + ): + return DataType.FLOAT_VECTOR if is_numeric_datatype(d_type) else DataType.UNKNOWN else: return DataType.ARRAY