Skip to content

Commit c5c7331

Browse files
Mohamed ShahinMohamed Shahin
authored andcommitted
Formatted files to pass Black checks
1 parent 19aebe7 commit c5c7331

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

weaviate_cli/commands/batch.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
from weaviate_cli.utils import get_client_from_context
66
from weaviate.exceptions import WeaviateConnectionError
77
from weaviate_cli.defaults import CreateCollectionDefaults
8-
from weaviate_cli.managers.batch_manager import BatchManager
8+
from weaviate_cli.managers.batch_manager import BatchManager
9+
910

1011
@click.group()
1112
def batch() -> None:
1213
"""Batch operations in Weaviate."""
1314
pass
1415

16+
1517
@batch.command("insert")
1618
@click.option(
1719
"--collection",
@@ -65,7 +67,9 @@ def batch_insert_cli(ctx, collection, path, vectorizer, shards, replication_fact
6567

6668
# Validate JSON structure
6769
if not isinstance(data, list) or not all(isinstance(obj, dict) for obj in data):
68-
click.echo("Error: The JSON file must contain a list of objects (e.g., [{...}, {...}]).")
70+
click.echo(
71+
"Error: The JSON file must contain a list of objects (e.g., [{...}, {...}])."
72+
)
6973
sys.exit(1)
7074

7175
# Initialize the Weaviate client
@@ -96,4 +100,4 @@ def batch_insert_cli(ctx, collection, path, vectorizer, shards, replication_fact
96100
sys.exit(1)
97101
finally:
98102
if client:
99-
client.close()
103+
client.close()

weaviate_cli/managers/batch_manager.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ def create_collection(
6262
vectorizer_config=vectorizer_map[vectorizer],
6363
properties=None if force_auto_schema else [],
6464
)
65-
click.echo(f"Collection '{collection}' created successfully with vectorizer '{vectorizer}'.")
65+
click.echo(
66+
f"Collection '{collection}' created successfully with vectorizer '{vectorizer}'."
67+
)
6668
except Exception as e:
6769
raise Exception(f"Error creating collection '{collection}': {e}")
6870

@@ -79,7 +81,9 @@ def batch_insert(
7981
data (List[Dict]): Data to be inserted.
8082
"""
8183
if not self.client.collections.exists(collection):
82-
raise Exception(f"Collection '{collection}' does not exist. Cannot insert data.")
84+
raise Exception(
85+
f"Collection '{collection}' does not exist. Cannot insert data."
86+
)
8387

8488
try:
8589
# Perform batch insertion using Weaviate's dynamic batch
@@ -94,7 +98,9 @@ def batch_insert(
9498
collection=collection,
9599
properties=record,
96100
)
97-
click.echo(f"Processed record") # add '{record}' <- if you would like to see the record being processed
101+
click.echo(
102+
f"Processed record"
103+
) # add '{record}' <- if you would like to see the record being processed
98104
except Exception as e:
99105
raise Exception(f"Batch insertion failed: {e}")
100106

@@ -105,4 +111,4 @@ def batch_insert(
105111
for i, failed_obj in enumerate(failed_objects, 1):
106112
click.echo(f"Failed object {i}: {failed_obj}")
107113
else:
108-
click.echo(f"All objects successfully inserted into '{collection}'.")
114+
click.echo(f"All objects successfully inserted into '{collection}'.")

0 commit comments

Comments
 (0)