diff --git a/integration_v3/test_backup_v4.py b/integration_v3/test_backup_v4.py index e8270620a..e7cae9ca9 100644 --- a/integration_v3/test_backup_v4.py +++ b/integration_v3/test_backup_v4.py @@ -16,7 +16,8 @@ from weaviate.exceptions import ( WeaviateUnsupportedFeatureError, UnexpectedStatusCodeException, - BackupFailedException, UnexpectedStatusCodeError, + BackupFailedException, + UnexpectedStatusCodeError, ) BACKEND = BackupStorage.FILESYSTEM @@ -452,17 +453,18 @@ def test_backup_and_restore_with_collection_and_config_1_23_x( ) -def test_list_backup(client: weaviate.WeaviateClient) -> None: - """Create and restore backup without waiting.""" - backup_id = _create_backup_id() - if client._connection._weaviate_version.is_lower_than(1, 27, 0): - pytest.skip("List backups is only supported from 1.27.0") - - resp = client.backup.create(backup_id=backup_id, backend=BACKEND) - assert resp.status == BackupStatus.STARTED - - backups = client.backup.list_backups(backend=BACKEND) - assert backup_id in [b.backup_id for b in backups] +# did not make it into 1.27, will come later +# def test_list_backup(client: weaviate.WeaviateClient) -> None: +# """Create and restore backup without waiting.""" +# backup_id = _create_backup_id() +# if client._connection._weaviate_version.is_lower_than(1, 27, 0): +# pytest.skip("List backups is only supported from 1.27.0") +# +# resp = client.backup.create(backup_id=backup_id, backend=BACKEND) +# assert resp.status == BackupStatus.STARTED +# +# backups = client.backup.list_backups(backend=BACKEND) +# assert backup_id in [b.backup_id for b in backups] def test_cancel_backup(client: weaviate.WeaviateClient) -> None: @@ -476,7 +478,7 @@ def test_cancel_backup(client: weaviate.WeaviateClient) -> None: with pytest.raises(UnexpectedStatusCodeError): assert client.backup.cancel_backup(backup_id=backup_id, backend=BACKEND) - + status_resp = client.backup.get_create_status(backup_id=backup_id, backend=BACKEND) assert status_resp.status == BackupStatus.CANCELED _ = client.backup.list_backups(backend=BACKEND) diff --git a/weaviate/backup/backup.py b/weaviate/backup/backup.py index 840849d05..4663ab2e1 100644 --- a/weaviate/backup/backup.py +++ b/weaviate/backup/backup.py @@ -10,6 +10,7 @@ from requests.exceptions import ConnectionError as RequestsConnectionError from weaviate.connect import Connection, ConnectionV4 +from weaviate.connect.v4 import _ExpectedStatusCodes from weaviate.exceptions import ( WeaviateInvalidInputError, WeaviateUnsupportedFeatureError, @@ -373,15 +374,17 @@ async def __cancel_backup(self, backup_id: str, backend: BackupStorage) -> bool: path = f"/backups/{backend.value}/{backup_id}" response = await self._connection.delete( - path=path, error_msg="Backup delete failed due to connection error." + path=path, + error_msg="Backup delete failed due to connection error.", + status_codes=_ExpectedStatusCodes(ok_in=[204, 404], error="delete object"), ) - typed_response = _decode_json_response_dict(response, "Backup restore status check") - if typed_response is None: - raise EmptyResponseException() if response.status_code == 204: return True # Successfully deleted else: + typed_response = _decode_json_response_dict(response, "Backup restore status check") + if typed_response is None: + raise EmptyResponseException() return False # did not exist async def cancel_backup(self, backup_id: str, backend: BackupStorage) -> bool: @@ -419,20 +422,21 @@ async def __list_backups(self, backend: BackupStorage) -> List[BackupReturn]: raise EmptyResponseException() return [BackupReturn(**entry) for entry in typed_response] - async def list_backups(self, backend: BackupStorage) -> List[BackupReturn]: - """ - List all backups that are currently in progress. - - Parameters - ---------- - backend : BackupStorage - The backend storage where to create the backup. - - Returns - ------- - A list of `BackupStatusReturn` objects that contain the backup restore status responses. - """ - return await self.__list_backups(backend) + # did not make it into 1.27, will come later + # async def list_backups(self, backend: BackupStorage) -> List[BackupReturn]: + # """ + # List all backups that are currently in progress. + # + # Parameters + # ---------- + # backend : BackupStorage + # The backend storage where to create the backup. + # + # Returns + # ------- + # A list of `BackupStatusReturn` objects that contain the backup restore status responses. + # """ + # return await self.__list_backups(backend) class Backup: