-
Notifications
You must be signed in to change notification settings - Fork 0
Restart delete resumable upload v4 #35
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Neha Bajaj <bajajneha27@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @shubhangi-google, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request enhances the Google Cloud Storage client library by introducing new functionalities for managing resumable uploads. It provides developers with the ability to restart an interrupted resumable upload and to explicitly delete an ongoing resumable upload using its unique identifier. This change improves the resilience and control over large file transfers, making the client library more robust for handling various network conditions and user requirements.
Highlights
- New Resumable Upload Management API: This PR introduces two new methods,
restart_resumable_uploadanddelete_resumable_upload, to theBucketclass, providing direct control over resumable upload sessions. - Enhanced Input Validation: The new methods include argument validation to ensure that a unique
upload_idis always provided, preventing common errors and improving API robustness. - Increased Test Coverage: Comprehensive unit tests have been added for both
restart_resumable_uploadanddelete_resumable_upload, ensuring the reliability and correct behavior of the new functionalities.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces functionality to restart and delete resumable uploads. The implementation is a good start, but there are several areas for improvement. The new restart_resumable_upload method has incorrect documentation and returns a raw API object, which is inconsistent with the rest of the library. The documentation for delete_resumable_upload is also misleading. Additionally, the new tests include some unnecessary code that can be removed for clarity. I've provided specific suggestions to address these points.
| # @return [Hash(String => String)] | ||
| # A Hash of file object returned from server. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return type documentation is incorrect. The method currently returns a raw GAPI object, not a Hash. For consistency with the rest of the client library, it should return a Google::Cloud::Storage::File object. This will require a change in the implementation as well.
# @return [Google::Cloud::Storage::File]
# The newly created File object.| ensure_service! | ||
| ensure_io_or_file_exists! file | ||
| raise ArgumentError, "Upload Id missing" unless upload_id | ||
| service.restart_resumable_upload name, file, upload_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method returns a raw GAPI object, which is inconsistent with other methods in this class (e.g., create_file) that wrap the GAPI object in a Google::Cloud::Storage::File instance. To provide a consistent and more user-friendly API, please wrap the result. This change aligns with my other comment on updating the @return documentation for this method.
File.from_gapi(service.restart_resumable_upload(name, file, upload_id), service)| # Delete resumable upload | ||
| # @param [String] upload_id Unique Id of an resumable upload | ||
| # | ||
| # @return [Boolean] Returns `true` if the bucket was deleted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # storage = Google::Cloud::Storage.new | ||
| # | ||
| # bucket = storage.bucket "my-bucket" | ||
| # bucket.restart_resumable_upload file,upload_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| mock = Minitest::Mock.new | ||
| mock.expect :restart_resumable_upload, create_file_gapi(bucket.name, new_file_name), | ||
| [bucket.name, tmpfile, upload_id], | ||
| **resumable_upload_args(options: {}) | ||
| bucket.service.mocked_service = mock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| mock.verify | ||
| end | ||
|
|
||
| it "Raises ArgumentError if upload_id is not provided to delete_resumable_upload" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| mock = Minitest::Mock.new | ||
| mock.expect :delete_resumable_upload, true, | ||
| [bucket.name, upload_id], | ||
| **resumable_upload_args(options: {}) | ||
| bucket.service.mocked_service = mock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Neha Bajaj <bajajneha27@users.noreply.github.com>
Co-authored-by: Neha Bajaj <bajajneha27@users.noreply.github.com>
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
bundle exec rake ciin the gem subdirectory.closes: #<issue_number_goes_here>