Skip to content
Merged
472 changes: 469 additions & 3 deletions test/unittests/test_managers/test_data_manager.py

Large diffs are not rendered by default.

18 changes: 12 additions & 6 deletions test/unittests/test_managers/test_tenant_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ def test_happy_path_deletes_tenants_text_output(
json_output=False,
)

mock_collection.tenants.remove.assert_called_once_with(mock_tenant)
mock_collection.tenants.remove.assert_called_once_with([mock_tenant])
out = capsys.readouterr().out
assert "1" in out
assert "deleted" in out
Expand Down Expand Up @@ -459,7 +459,10 @@ def test_deletes_only_up_to_number_tenants(
json_output=False,
)

assert mock_collection.tenants.remove.call_count == 2
# Batch delete: single call with list of tenants to delete
mock_collection.tenants.remove.assert_called_once()
removed = mock_collection.tenants.remove.call_args[0][0]
assert len(removed) == 2

def test_deletes_using_tenants_list(self, mock_client: MagicMock, capsys) -> None:
"""When tenants_list is provided, get_by_names is used."""
Expand All @@ -483,7 +486,7 @@ def test_deletes_using_tenants_list(self, mock_client: MagicMock, capsys) -> Non
# get() should NOT be called when tenants_list is provided
mock_collection.tenants.get.assert_not_called()
assert mock_collection.tenants.get_by_names.call_count == 2
mock_collection.tenants.remove.assert_called_once_with(specific_tenant)
mock_collection.tenants.remove.assert_called_once_with([specific_tenant])

def test_delete_all_with_wildcard_suffix(
self, mock_client: MagicMock, capsys
Expand All @@ -505,7 +508,10 @@ def test_delete_all_with_wildcard_suffix(
json_output=False,
)

assert mock_collection.tenants.remove.call_count == 2
# Batch delete: single call with all tenants
mock_collection.tenants.remove.assert_called_once()
removed = mock_collection.tenants.remove.call_args[0][0]
assert len(removed) == 2


# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -844,5 +850,5 @@ def test_skips_update_call_when_tenant_already_in_desired_state(
json_output=False,
)

# The existing tenant object should be passed directly (no new Tenant)
mock_collection.tenants.update.assert_called_once_with(already_active)
# Batch update: single call with list containing the existing tenant as-is
mock_collection.tenants.update.assert_called_once_with([already_active])
8 changes: 8 additions & 0 deletions weaviate_cli/commands/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,12 @@ def create_backup_cli(
type=int,
help=f"Number of concurrent requests to send to the server (default: {MAX_WORKERS}).",
)
@click.option(
"--parallel_workers",
default=CreateDataDefaults.parallel_workers,
type=click.IntRange(min=1),
help=f"Number of tenants to process in parallel (default: {CreateDataDefaults.parallel_workers}). Set to 1 to disable parallelism.",
)
@click.option(
"--json", "json_output", is_flag=True, default=False, help="Output in JSON format."
)
Expand All @@ -543,6 +549,7 @@ def create_data_cli(
dynamic_batch,
batch_size,
concurrent_requests,
parallel_workers,
json_output,
):
"""Ingest data into a collection in Weaviate."""
Expand Down Expand Up @@ -593,6 +600,7 @@ def create_data_cli(
dynamic_batch=dynamic_batch,
batch_size=batch_size,
concurrent_requests=concurrent_requests,
parallel_workers=parallel_workers,
json_output=json_output,
)
except Exception as e:
Expand Down
17 changes: 16 additions & 1 deletion weaviate_cli/commands/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,26 @@ def delete_tenants_cli(
default=DeleteDataDefaults.verbose,
help="Show detailed progress information (default: False).",
)
@click.option(
"--parallel_workers",
default=DeleteDataDefaults.parallel_workers,
type=click.IntRange(min=1),
help=f"Number of tenants to process in parallel (default: {DeleteDataDefaults.parallel_workers}). Set to 1 to disable parallelism.",
)
@click.option(
"--json", "json_output", is_flag=True, default=False, help="Output in JSON format."
)
@click.pass_context
def delete_data_cli(
ctx, collection, limit, consistency_level, tenants, uuid, verbose, json_output
ctx,
collection,
limit,
consistency_level,
tenants,
uuid,
verbose,
parallel_workers,
json_output,
):
"""Delete data from a collection in Weaviate."""

Expand All @@ -184,6 +198,7 @@ def delete_data_cli(
),
uuid=uuid,
verbose=verbose,
parallel_workers=parallel_workers,
json_output=json_output,
)
except Exception as e:
Expand Down
8 changes: 8 additions & 0 deletions weaviate_cli/commands/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,12 @@ def update_shards_cli(
default=UpdateDataDefaults.verbose,
help="Show detailed progress information (default: True).",
)
@click.option(
"--parallel_workers",
default=UpdateDataDefaults.parallel_workers,
type=click.IntRange(min=1),
help=f"Number of tenants to process in parallel (default: {UpdateDataDefaults.parallel_workers}). Set to 1 to disable parallelism.",
)
@click.option(
"--json", "json_output", is_flag=True, default=False, help="Output in JSON format."
)
Expand All @@ -325,6 +331,7 @@ def update_data_cli(
randomize,
skip_seed,
verbose,
parallel_workers,
json_output,
):
"""Update data in a collection in Weaviate."""
Expand All @@ -341,6 +348,7 @@ def update_data_cli(
randomize=randomize,
skip_seed=skip_seed,
verbose=verbose,
parallel_workers=parallel_workers,
json_output=json_output,
)
except Exception as e:
Expand Down
3 changes: 3 additions & 0 deletions weaviate_cli/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class CreateDataDefaults:
multi_vector: bool = False
batch_size: int = 1000
dynamic_batch: bool = False
parallel_workers: int = MAX_WORKERS


@dataclass
Expand Down Expand Up @@ -179,6 +180,7 @@ class DeleteDataDefaults:
consistency_level: str = "quorum"
uuid: Optional[str] = None
verbose: bool = False
parallel_workers: int = MAX_WORKERS


@dataclass
Expand Down Expand Up @@ -287,6 +289,7 @@ class UpdateDataDefaults:
randomize: bool = False
skip_seed: bool = False
verbose: bool = False
parallel_workers: int = MAX_WORKERS


@dataclass
Expand Down
Loading
Loading