From c4474128b8ea48fdadde3134a184f90e94bdfd8e Mon Sep 17 00:00:00 2001 From: Jose Luis Franco Arza Date: Wed, 30 Oct 2024 22:03:00 +0100 Subject: [PATCH] Add missing director property with --randomize. This commit also renames the --auto_tenant flag into --force_auto_tenant which will leave the properties field empty so that auto_schema takes care of its creation. --- test/integration/test_integration.py | 10 +++++----- .../unittests/test_managers/test_collection_manager.py | 6 +++--- weaviate_cli/commands/create.py | 10 +++++++--- weaviate_cli/managers/collection_manager.py | 4 ++-- weaviate_cli/managers/data_manager.py | 1 + 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/test/integration/test_integration.py b/test/integration/test_integration.py index f87b4af..a6e43de 100644 --- a/test/integration/test_integration.py +++ b/test/integration/test_integration.py @@ -49,7 +49,7 @@ def test_collection_lifecycle(collection_manager: CollectionManager): auto_tenant_creation=False, auto_tenant_activation=False, vectorizer="contextionary", - auto_schema=True, + force_auto_schema=True, ) # Verify collection exists @@ -97,7 +97,7 @@ def test_multiple_collections(collection_manager: CollectionManager): auto_tenant_creation=False, auto_tenant_activation=False, vectorizer="contextionary", - auto_schema=True, + force_auto_schema=True, ) assert collection_manager.client.collections.exists(col) finally: @@ -128,7 +128,7 @@ def test_shard_operations( auto_tenant_creation=False, auto_tenant_activation=False, vectorizer="transformers", - auto_schema=True, + force_auto_schema=True, ) # Get shard info @@ -169,7 +169,7 @@ def test_error_handling(collection_manager: CollectionManager): auto_tenant_creation=False, auto_tenant_activation=False, vectorizer="transformers", - auto_schema=True, + force_auto_schema=True, ) with pytest.raises(Exception): @@ -185,7 +185,7 @@ def test_error_handling(collection_manager: CollectionManager): auto_tenant_creation=False, auto_tenant_activation=False, vectorizer="transformers", - auto_schema=True, + force_auto_schema=True, ) finally: # Test deleting non-existent collection diff --git a/test/unittests/test_managers/test_collection_manager.py b/test/unittests/test_managers/test_collection_manager.py index fdd1bb4..f6b69f1 100644 --- a/test/unittests/test_managers/test_collection_manager.py +++ b/test/unittests/test_managers/test_collection_manager.py @@ -27,7 +27,7 @@ def test_create_collection(mock_client): multitenant=False, auto_tenant_creation=False, auto_tenant_activation=False, - auto_schema=False, + force_auto_schema=False, shards=1, vectorizer=None, ) @@ -65,7 +65,7 @@ def test_create_existing_collection(mock_client): multitenant=False, auto_tenant_creation=False, auto_tenant_activation=False, - auto_schema=False, + force_auto_schema=False, shards=1, vectorizer=None, ) @@ -101,7 +101,7 @@ def test_create_collection_failure(mock_client): multitenant=False, auto_tenant_creation=False, auto_tenant_activation=False, - auto_schema=False, + force_auto_schema=False, shards=1, vectorizer=None, ) diff --git a/weaviate_cli/commands/create.py b/weaviate_cli/commands/create.py index 7f86191..01dcd3e 100644 --- a/weaviate_cli/commands/create.py +++ b/weaviate_cli/commands/create.py @@ -57,7 +57,11 @@ def create() -> None: is_flag=True, help="Enable auto tenant activation (default: False).", ) -@click.option("--auto_schema", default=True, help="Enable auto-schema (default: True).") +@click.option( + "--force_auto_schema", + is_flag=True, + help="Force auto-schema (default: False). If passed, no properties will be added to the collection and it will be the auto-schema the one that infers the properties.", +) @click.option("--shards", default=1, help="Number of shards (default: 1).") @click.option( "--vectorizer", @@ -77,7 +81,7 @@ def create_collection_cli( multitenant: bool, auto_tenant_creation: bool, auto_tenant_activation: bool, - auto_schema: bool, + force_auto_schema: bool, shards: int, vectorizer: Optional[str], ) -> None: @@ -98,7 +102,7 @@ def create_collection_cli( multitenant=multitenant, auto_tenant_creation=auto_tenant_creation, auto_tenant_activation=auto_tenant_activation, - auto_schema=auto_schema, + force_auto_schema=force_auto_schema, shards=shards, vectorizer=vectorizer, ) diff --git a/weaviate_cli/managers/collection_manager.py b/weaviate_cli/managers/collection_manager.py index 496b7fa..307c6c9 100644 --- a/weaviate_cli/managers/collection_manager.py +++ b/weaviate_cli/managers/collection_manager.py @@ -55,7 +55,7 @@ def create_collection( multitenant: bool, auto_tenant_creation: bool, auto_tenant_activation: bool, - auto_schema: bool, + force_auto_schema: bool, shards: int, vectorizer: Optional[str], ) -> None: @@ -152,7 +152,7 @@ def create_collection( auto_tenant_activation=auto_tenant_activation, ), vectorizer_config=(vectorizer_map[vectorizer] if vectorizer else None), - properties=properties if auto_schema else None, + properties=properties if not force_auto_schema else None, ) except Exception as e: diff --git a/weaviate_cli/managers/data_manager.py b/weaviate_cli/managers/data_manager.py index 2762043..a0585aa 100644 --- a/weaviate_cli/managers/data_manager.py +++ b/weaviate_cli/managers/data_manager.py @@ -101,6 +101,7 @@ def create_single_object() -> Dict: "title": f"{prefix}title" + get_random_string(10), "genres": f"{prefix}genre" + get_random_string(3), "keywords": f"{prefix}keywords" + get_random_string(3), + "director": f"{prefix}director" + get_random_string(3), "popularity": float(random.randint(1, 200)), "runtime": f"{prefix}runtime" + get_random_string(3), "cast": f"{prefix}cast" + get_random_string(3),