Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass returned errors from backup create/restore to raised exception #1032

Merged
merged 2 commits into from
Apr 30, 2024
Merged
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
9 changes: 7 additions & 2 deletions weaviate/backup/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class BackupStatus(str, Enum):
class BackupStatusReturn(BaseModel):
"""Return type of the backup status methods."""

error: Optional[str] = Field(default=None)
status: BackupStatus
path: str

Expand Down Expand Up @@ -139,7 +140,9 @@ def create(
if status.status == BackupStatus.SUCCESS:
break
if status.status == BackupStatus.FAILED:
raise BackupFailedException(f"Backup failed: {create_status}")
raise BackupFailedException(
f"Backup failed: {create_status} with error: {status.error}"
)
sleep(1)
return BackupReturn(**create_status)

Expand Down Expand Up @@ -249,7 +252,9 @@ def restore(
if status.status == BackupStatus.SUCCESS:
break
if status.status == BackupStatus.FAILED:
raise BackupFailedException(f"Backup restore failed: {restore_status}")
raise BackupFailedException(
f"Backup restore failed: {restore_status} with error: {status.error}"
)
sleep(1)
return BackupReturn(**restore_status)

Expand Down
4 changes: 2 additions & 2 deletions weaviate/collections/backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def create(
One of the arguments have a wrong type.
"""
create = self._backup.create(backup_id, backend, [self._name], None, wait_for_completion)
return BackupStatusReturn(status=create.status, path=create.path)
return BackupStatusReturn(error=create.error, status=create.status, path=create.path)

def restore(
self, backup_id: str, backend: BackupStorage, wait_for_completion: bool = False
Expand Down Expand Up @@ -70,7 +70,7 @@ def restore(
If the backup failed.
"""
restore = self._backup.restore(backup_id, backend, [self._name], None, wait_for_completion)
return BackupStatusReturn(status=restore.status, path=restore.path)
return BackupStatusReturn(error=restore.error, status=restore.status, path=restore.path)

def get_create_status(self, backup_id: str, backend: BackupStorage) -> BackupStatusReturn:
"""Check if a started backup job has completed.
Expand Down
Loading