Implement backup & restore#479
Conversation
austin-denoble
left a comment
There was a problem hiding this comment.
LGTM overall, nice work. Even with all the refactoring underneath everything still feels like a clean and easy review.
| ) | ||
| return BackupList(self._index_api.list_index_backups(**args)) | ||
| else: | ||
| return BackupList(self._index_api.list_project_backups()) |
There was a problem hiding this comment.
Just make sure to pass args through once you've pulled in the changes to add pagination to this one.
| deletion_protection: Optional[Union["DeletionProtection", str]] = "disabled", | ||
| tags: Optional[Dict[str, str]] = None, | ||
| timeout: Optional[int] = None, | ||
| ) -> "IndexModel": |
There was a problem hiding this comment.
edit: Ignore - I saw elsewhere why this returns IndexModel 👍
This doesn't return an IndexModel. It returns a different shape as this initiates a restore job, and the index hasn't been created yet. It should be something like CreateIndexFromBackupResponse, it looks like this:
{
restore_job_id: string
index_id: string
}
| await self.index_api.create_index_from_backup( | ||
| backup_id=backup_id, create_index_from_backup_request=req | ||
| ) | ||
| return await self.__poll_describe_index_until_ready(name, timeout) |
There was a problem hiding this comment.
Ah - I commented on returning IndexModel rather than the response shape from the API call, but I didn't realize you were awaiting. That's a nice bit of sugar for this.
Problem
Implement backup & restore
Solution
Added new methods to
PineconeandPineconeAsyncio:create_index_from_backupcreate_backuplist_backupsdescribe_backupdelete_backuplist_restore_jobsdescribe_restore_jobThese can also be accessed with the new-style syntax, e.g.
pc.db.index.create_from_backup,pc.db.backup.create,pc.db.restore_job.list.More Details:
create_backup,create_index_from_backups) as well as new-style namespc.db.index.create_from_backup. In the upcoming release, both styles will be present. We still need to do some work to reorg methods for some less-used parts of the client (bulk imports, etc) before transitioning fully to the new style in examples and documentation.@kwargs_requireddecorator. I will probably follow up and add this to all new methods added in the recent refactoring PR. Keyword arguments are strongly preferred over positional arguments because the keyword labels act as documentation and having the keyword labels makes them order-independent. This gives a lot of flexibility to expand the signature or change things from required to optional later without creating breaking changes for callers.Pinecone > DbControl > BackupResourcePinecone > DbControl > IndexResourcePinecone > DbControl > RestoreJobResourcePineconeAsyncio > DbControlAsyncio > AsyncioBackupResourcePineconeAsyncio > DbControlAsyncio > AsyncioIndexResourcePineconeAsyncio > DbControlAsyncio > AsyncioRestoreJobResourceUsage
Initial setup
Backups
Creating an index from backup
Restore job
Type of Change
Test Plan
Describe specific steps for validating this change.