Skip to content

Conversation

@shubhangi-google
Copy link
Owner

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:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea.
  • Follow the instructions in CONTRIBUTING. Most importantly, ensure the tests and linter pass by running bundle exec rake ci in the gem subdirectory.
  • Update code documentation if necessary.

closes: #<issue_number_goes_here>

Copy link

@gemini-code-assist gemini-code-assist bot left a 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_upload and delete_resumable_upload, to the Bucket class, providing direct control over resumable upload sessions.
  • Enhanced Input Validation: The new methods include argument validation to ensure that a unique upload_id is always provided, preventing common errors and improving API robustness.
  • Increased Test Coverage: Comprehensive unit tests have been added for both restart_resumable_upload and delete_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

  1. 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.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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.

Comment on lines 728 to 729
# @return [Hash(String => String)]
# A Hash of file object returned from server.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The documentation for the return value is misleading. It states that it "Returns true if the bucket was deleted", but this method deletes a resumable upload, not a bucket.

        # @return [Boolean] Returns `true` if the resumable upload was deleted.

# storage = Google::Cloud::Storage.new
#
# bucket = storage.bucket "my-bucket"
# bucket.restart_resumable_upload file,upload_id

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There's a typo in the example code. The second argument upload_id is missing a space before it.

        #   bucket.restart_resumable_upload file, upload_id

Comment on lines 1437 to 1441
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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The mock setup for :restart_resumable_upload is unnecessary in this test case because the ArgumentError is raised before the service method is ever called. You can remove these lines to simplify the test.

mock.verify
end

it "Raises ArgumentError if upload_id is not provided to delete_resumable_upload" do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The test name "Raises ArgumentError..." starts with a capital letter, which is inconsistent with other test names in this file (e.g., "deletes a resumable upload..."). For consistency, it should be "raises...".

  it "raises ArgumentError if upload_id is not provided to delete_resumable_upload" do

Comment on lines 1464 to 1468
mock = Minitest::Mock.new
mock.expect :delete_resumable_upload, true,
[bucket.name, upload_id],
**resumable_upload_args(options: {})
bucket.service.mocked_service = mock

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similar to the other argument error test, the mock setup for :delete_resumable_upload is unnecessary here because the ArgumentError is raised before the service method is called. These lines can be removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants