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 Ruby client library by adding direct support for managing resumable uploads. It provides developers with the ability to programmatically restart interrupted uploads and explicitly delete incomplete upload sessions, improving the robustness and control over data transfers.

Highlights

  • New Resumable Upload Management: Introduced new methods restart_resumable_upload and delete_resumable_upload to the Bucket class, allowing for better control over large file transfers in Google Cloud Storage.
  • API Integration: Implemented corresponding restart_resumable_upload and delete_resumable_upload methods within the Service layer to facilitate interaction with the underlying Google Cloud Storage API.
  • Dependency Update: Updated the google-apis-storage_v1 gem dependency to version >= 0.56 to ensure compatibility and access to the necessary API features for the new resumable upload functionality.
  • Comprehensive Testing: Added new test cases for both restart_resumable_upload and delete_resumable_upload methods, covering functionality and argument validation, along with a new test helper.
  • Tooling Regex Fix: Corrected a minor regex pattern in batch review tooling scripts (.toys/batch-review-legacy.rb and .toys/batch-review.rb) for snippet metadata file paths.
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 changes are well-structured, including updates to the service and bucket classes, dependency bumps, and new tests. My review includes suggestions to improve the accuracy of the YARD documentation for the new methods and to clean up some unused variables in the tests for better maintainability.

Comment on lines +726 to +727
# @return [Google::Apis::StorageV1::Object, Integer]
# The object metadata on success, or 0 request is not completed.

Choose a reason for hiding this comment

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

medium

The return type documentation appears to be inaccurate. It states that the method can return an Integer (specifically 0) if the request is not completed. However, within this library, an incomplete or failed request typically raises an exception rather than returning a special value. On success, the method should return the Google::Apis::StorageV1::Object. Please update the documentation to reflect this expected behavior.

# @return [Google::Apis::StorageV1::Object]
#   The object metadata on success.

# Delete resumable upload
# @param [String] upload_id Unique Id of a resumable upload
#
# @return [Boolean,nil] Returns `true` if the resumable upload was deleted, 'nil' if the request is not completed.

Choose a reason for hiding this comment

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

medium

The return type documentation [Boolean,nil] and the explanation are a bit confusing. The mention of nil for an incomplete request is ambiguous, as failed requests typically raise exceptions. For clarity and consistency, it's better for methods that perform a DELETE operation to return true on success. I'll provide a suggestion on the method implementation to align with this.

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

Comment on lines +1451 to +1455
def delete_resumable_upload upload_id
ensure_service!
raise ArgumentError, "Upload Id missing" unless upload_id
service.delete_resumable_upload name, upload_id
end

Choose a reason for hiding this comment

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

medium

To provide a clear success signal to the caller, this method should explicitly return true after the service call completes successfully. The underlying service call for a successful delete might return nil (on an HTTP 204 response), so returning true makes the method's contract more robust and aligns with both the test expectation and the recommended documentation change.

        def delete_resumable_upload upload_id
          ensure_service!
          raise ArgumentError, "Upload Id missing" unless upload_id
          service.delete_resumable_upload name, upload_id
          true
        end

end

it "raises ArgumentError if anyone or both arguments are not provided to restart_resumable_upload" do
new_file_name = random_file_path

Choose a reason for hiding this comment

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

medium

The variable new_file_name is initialized but never used in this test case. It can be removed to improve code clarity.

end

it "raises ArgumentError if upload_id as nil is provided to restart_resumable_upload" do
new_file_name = random_file_path

Choose a reason for hiding this comment

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

medium

The variable new_file_name is initialized but never used in this test case. It can be removed.

Comment on lines +1476 to +1477
new_file_name = random_file_path
upload_id = "TEST_ID"

Choose a reason for hiding this comment

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

medium

The variables new_file_name and upload_id are initialized but never used in this test case. They can be removed.

end

it "raises ArgumentError if upload_id as nil is provided to delete_resumable_upload" do
new_file_name = random_file_path

Choose a reason for hiding this comment

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

medium

The variable new_file_name is initialized but never used in this test case. It 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