Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
Signed-off-by: Filip Haltmayer <[email protected]>
  • Loading branch information
Filip Haltmayer committed Jun 9, 2023
1 parent ca569a9 commit 6e22635
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions pymilvus/simple_api/simple_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(

self.uri = uri or "http://localhost:19530/default"
if api_key is None:
api_key = f"{user}:{password}"
api_key = f"{user if user is not None else ''}:{password if password is not None else ''}"
logger.debug("Using USER:PASS API Key")

self.alias = self._create_connection(uri, api_key, timeout=timeout)
Expand Down Expand Up @@ -95,7 +95,7 @@ def describe_collection(
if not self.conn.has_collection(
collection_name=collection_name, using=self.alias, timeout=timeout
):
raise simple_exception.CollectionDoesNotExist()
raise simple_exception.CollectionDoesNotExist(f"Collection {collection_name} does not exist.")
res = self.conn.describe_collection(
collection_name=collection_name, timeout=timeout
)
Expand Down Expand Up @@ -141,7 +141,7 @@ def num_entities(self, collection_name: str, timeout: int = None) -> int:
if not self.conn.has_collection(
collection_name=collection_name, timeout=timeout
):
raise simple_exception.CollectionDoesNotExist()
raise simple_exception.CollectionDoesNotExist(f"Collection {collection_name} does not exist.")
self.conn.flush(collection_names=[collection_name])
stats = self.conn.get_collection_stats(collection_name=collection_name)
result = {stat.key: stat.value for stat in stats}
Expand Down Expand Up @@ -207,7 +207,7 @@ def create_collection(
):
if overwrite is True:
self.conn.drop_collection(collection_name, timeout=timeout)
logger.debug("Dropping collection %s", collection_name)
logger.debug("Dropping collection %s due to overwrite param.", collection_name)
else:
raise simple_exception.CollectionAlreadyExists()

Expand All @@ -220,7 +220,7 @@ def create_collection(
if primary_type.lower() == "str":
if primary_auto_id:
raise simple_exception.InvalidPKFormat(
"str based primary_field cannot be auto-id'ed"
"Str based primary_field cannot be auto-id'ed"
)
fields.append(
FieldSchema(
Expand Down Expand Up @@ -338,7 +338,7 @@ def create_collection_from_schema(
):
if overwrite is True:
self.conn.drop_collection(collection_name, timeout=timeout)
logger.debug("Dropping collection %s", collection_name)
logger.debug("Dropping collection %s due to overwrite param.", collection_name)
else:
raise simple_exception.CollectionAlreadyExists()

Expand Down Expand Up @@ -404,7 +404,6 @@ def insert(
return []

if batch_size < 0:
logger.error("Invalid batch size provided for insert.")
raise simple_exception.InvalidInsertBatchSize(
f"Invalid batch size of {batch_size}"
)
Expand Down Expand Up @@ -518,7 +517,6 @@ def search(
consistency_level=consistency_level,
)
except Exception as ex:
logger.error("Failed to search collection: %s", collection_name)
raise ex
ret = []
if include_vectors:
Expand Down Expand Up @@ -767,7 +765,6 @@ def _create_connection(self, uri: str, api_key: str, timeout: int = None) -> str
logger.debug("Created new connection using: %s", alias)
return alias
except MilvusException as ex:
logger.error("Failed to create new connection using: %s", alias)
raise ex

def _fetch_formatter(self, field, values):
Expand Down

0 comments on commit 6e22635

Please sign in to comment.