Repository navigation
chore: add the stores helper functions - #245
Conversation
| The file object once it reaches a terminal state | ||
| """ | ||
| self.create( | ||
| store_identifier=store_identifier, file_id=file_id, metadata=metadata, experimental=experimental, **kwargs |
There was a problem hiding this comment.
Bug: Metadata Parameter Type Mismatch
The new create_and_poll, upload, and upload_and_poll methods (and their async versions) define the metadata parameter using NotGiven. However, they pass this parameter to the underlying create method, which expects Omit. This type annotation inconsistency may lead to type checking errors or unexpected runtime behavior.
Additional Locations (4)
| fn=functools.partial(self.retrieve, file_id, store_identifier=store_identifier, **kwargs), | ||
| condition=lambda res: res.status == "completed" or res.status == "failed" or res.status == "cancelled", | ||
| interval_seconds=polling_interval_ms / 1000, | ||
| timeout_seconds=polling_timeout_ms / 1000 if polling_timeout_ms else None, |
There was a problem hiding this comment.
Bug: Poll Parameters Misinterpret Zero Values
The poll_interval_ms and poll_timeout_ms parameters in the poll methods (sync and async) incorrectly treat explicit 0 values as falsy. This causes 0 to be overridden by the default 500ms interval or None (no timeout), preventing users from setting an immediate interval or timeout and potentially leading to unexpected infinite polling.
Additional Locations (1)
| *, | ||
| store_identifier: str, | ||
| file: FileTypes, | ||
| metadata: Optional[object] | NotGiven = not_given, |
There was a problem hiding this comment.
Bug: Sync/Async upload Methods Have Inconsistent Metadata Handling
The metadata parameter in the upload methods has an inconsistent type annotation and default value between the sync and async versions. One uses Optional[object] | Omit = omit while the other uses Optional[object] | NotGiven = not_given. This also creates a type mismatch when upload passes metadata to the create method, which expects object | Omit.
Note
Introduce sync/async helpers to upload/attach files to stores and poll until processing reaches a terminal status.
FilesResource):poll: repeatedly retrievesStoreFileuntil status iscompleted/failed/cancelled.create_and_poll: attach existingfile_idtostorethen poll.upload: upload viaclient.files.createthen attach tostore.upload_and_poll: upload, attach, and poll to completion.AsyncFilesResource):poll,create_and_poll,upload,upload_and_pollasync equivalents usingpolling.poll_async.polling,functools, andFileTypesto support new helpers and file uploads.Written by Cursor Bugbot for commit 153269e. This will update automatically on new commits. Configure here.