Skip to content

refactor(storagecontrol): update managed_folder_create sample #13533

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

eapl-gemugami
Copy link
Contributor

Description

Based on the RPC Workshop, this sample is updated to the current style guide.

Note: I think that create, get and delete samples should be refactored in the same PR, as they depend on each other for a clean test environment. (After creating a folder it should be deleted, or the strategy in conftest.py should be adapted to these samples)

Checklist

@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Aug 1, 2025
Copy link
Contributor

@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 @eapl-gemugami, 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!

I've updated the managed_folder_create sample for Google Cloud Storage to adhere to the latest style guidelines. The primary changes involve transitioning from basic sys.argv for command-line input to the more robust argparse module, adding comprehensive documentation to the function, and introducing a new integration test to validate the sample's functionality. This refactoring aims to improve the sample's clarity, usability, and test coverage.

Highlights

  • Improved Command-Line Argument Handling: I've refactored the managed_folder_create.py sample to use argparse instead of sys.argv for command-line argument parsing. This improves the sample's usability and aligns it with modern Python best practices for CLI applications.
  • Enhanced Documentation: I've added a detailed docstring to the create_managed_folder function, providing clear explanations of its purpose, parameters, and return value, along with a helpful link to the official Google Cloud Storage documentation. This significantly enhances the sample's readability and maintainability.
  • New Integration Test for Managed Folder Creation: I've introduced a new test file, storagecontrol/managed_folder_create_test.py, which includes an integration test for the create_managed_folder sample. This test creates a managed folder, verifies its creation, and then performs a cleanup by deleting it, ensuring the sample works as expected in a real environment.
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 or fill out our survey to provide feedback.

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
Contributor

@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 refactors the managed_folder_create sample to align with current style guides, notably by using argparse and adding a comprehensive docstring. The changes are a good improvement.

However, the change from managed_folder_id to managed_folder_name as a keyword argument in create_managed_folder is a breaking change. The existing test in storagecontrol/snippets_test.py at line 83 calls this function with the old argument name and will fail. Please update snippets_test.py to use the new argument name to fix the tests.

I've also added a couple of suggestions to improve code consistency and readability in the new code.

@eapl-gemugami
Copy link
Contributor Author

/gemini review

@eapl-gemugami eapl-gemugami added the snippet-bot:force-run Force snippet-bot runs its logic label Aug 1, 2025
@snippet-bot snippet-bot bot removed the snippet-bot:force-run Force snippet-bot runs its logic label Aug 1, 2025
Copy link
Contributor

@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

The code changes introduce the ability to load multiple signed images to a registry using a bulk load feature. There was a typo in the argument name being accessed, and a TypeError was introduced because the get_managed_folder function in managed_folder_get.py does not have a managed_folder_name parameter.

@eapl-gemugami eapl-gemugami added the snippet-bot:force-run Force snippet-bot runs its logic label Aug 1, 2025
@snippet-bot snippet-bot bot removed the snippet-bot:force-run Force snippet-bot runs its logic label Aug 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant