Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ classifiers =
include_package_data = True
python_requires = >=3.9
install_requires =
weaviate-client>=4.16.0
weaviate-client==v4.17.0-rc1
click==8.1.7
semver>=3.0.2
numpy>=1.24.0
Expand Down
8 changes: 7 additions & 1 deletion weaviate_cli/commands/restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ def restore() -> None:
default=RestoreBackupDefaults.exclude,
help="Collection to exclude in backup (default: None).",
)
@click.option(
"--override-alias",
is_flag=True,
help="Override the alias of the collection (default: False).",
)
@click.pass_context
def restore_backup_cli(ctx, backend, include, exclude, backup_id, wait):
def restore_backup_cli(ctx, backend, include, exclude, backup_id, wait, override_alias):
"""Restore a backup in Weaviate."""

client = None
Expand All @@ -52,6 +57,7 @@ def restore_backup_cli(ctx, backend, include, exclude, backup_id, wait):
include=include,
exclude=exclude,
wait=wait,
override_alias=override_alias,
)
except Exception as e:
click.echo(f"Error: {e}")
Expand Down
1 change: 1 addition & 0 deletions weaviate_cli/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ class RestoreBackupDefaults:
wait: bool = False
include: Optional[str] = None
exclude: Optional[str] = None
override_alias: bool = False


@dataclass
Expand Down
4 changes: 3 additions & 1 deletion weaviate_cli/managers/backup_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class BackupManager:
def __init__(self, client: WeaviateClient) -> None:
self.client = client
self.client: WeaviateClient = client

def create_backup(
self,
Expand Down Expand Up @@ -68,13 +68,15 @@ def restore_backup(
include: Optional[str] = RestoreBackupDefaults.include,
exclude: Optional[str] = RestoreBackupDefaults.exclude,
wait: bool = RestoreBackupDefaults.wait,
override_alias: bool = RestoreBackupDefaults.override_alias,
) -> None:

result = self.client.backup.restore(
backup_id=backup_id,
backend=backend,
include_collections=include.split(",") if include else None,
exclude_collections=exclude.split(",") if exclude else None,
overwrite_alias=override_alias,
wait_for_completion=wait,
)

Expand Down
39 changes: 22 additions & 17 deletions weaviate_cli/managers/data_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ def __import_json(
num_objects: Optional[int] = None,
) -> int:
counter = 0

properties: List[wvc.Property] = collection.config.get().properties

try:
Expand Down Expand Up @@ -449,6 +450,7 @@ def __ingest_data(

# Determine vector dimensions based on vectorizer
config = collection.config.get()

if not config.vectorizer and config.vector_config:
# Named vectors
named_vectors = list(config.vector_config.keys())
Expand Down Expand Up @@ -609,10 +611,11 @@ def create_data(
) -> Collection:

if not self.client.collections.exists(collection):

raise Exception(
f"Class '{collection}' does not exist in Weaviate. Create first using <create class> command"
)
alias_list = self.client.alias.list_all()
if collection not in alias_list.keys():
raise Exception(
f"Class '{collection}' does not exist in Weaviate. Create first using <create class> command"
)

col: Collection = self.client.collections.get(collection)
mt_enabled = col.config.get().multi_tenancy_config.enabled
Expand Down Expand Up @@ -952,10 +955,11 @@ def update_data(
) -> None:

if not self.client.collections.exists(collection):

raise Exception(
f"Class '{collection}' does not exist in Weaviate. Create first using ./create_class.py"
)
alias_list = self.client.alias.list_all()
if collection not in alias_list.keys():
raise Exception(
f"Class '{collection}' does not exist in Weaviate. Create first using ./create_class.py"
)

col: Collection = self.client.collections.get(collection)
try:
Expand Down Expand Up @@ -1092,11 +1096,11 @@ def delete_data(
) -> None:

if not self.client.collections.exists(collection):
print(
f"Class '{collection}' does not exist in Weaviate. Create first using <create class> command."
)

return 1
alias_list = self.client.alias.list_all()
if collection not in alias_list.keys():
raise Exception(
f"Class '{collection}' does not exist in Weaviate. Create first using <create class> command."
)

col: Collection = self.client.collections.get(collection)
mt_enabled = col.config.get().multi_tenancy_config.enabled
Expand Down Expand Up @@ -1217,10 +1221,11 @@ def query_data(
) -> None:

if not self.client.collections.exists(collection):

raise Exception(
f"Class '{collection}' does not exist in Weaviate. Create first using <create class> command."
)
alias_list = self.client.alias.list_all()
if collection not in alias_list.keys():
raise Exception(
f"Class '{collection}' does not exist in Weaviate. Create first using <create class> command."
)

col: Collection = self.client.collections.get(collection)
mt_enabled = col.config.get().multi_tenancy_config.enabled
Expand Down