Skip to content

feat: load_clip_configs to accept both file path and dictionary input#942

Merged
helloyongyang merged 1 commit intomainfrom
gp/dev
Mar 16, 2026
Merged

feat: load_clip_configs to accept both file path and dictionary input#942
helloyongyang merged 1 commit intomainfrom
gp/dev

Conversation

@GACLove
Copy link
Contributor

@GACLove GACLove commented Mar 13, 2026

No description provided.

@GACLove GACLove requested a review from wangshankun March 13, 2026 12:35
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 load_clip_configs function by introducing the capability to process configuration data directly from a dictionary object. This change provides greater flexibility in how configurations are handled, allowing in-memory data structures to be used without the need for intermediate file operations, thereby streamlining the configuration loading process.

Highlights

  • Configuration Loading Flexibility: The load_clip_configs function now accepts a dictionary directly as input, in addition to its previous functionality of loading configuration from a file path.
  • Type Hint Adjustment: The type hint for the main_json_path parameter in load_clip_configs was removed to accommodate both string (file path) and dictionary inputs.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • lightx2v/shot_runner/shot_base.py
    • Modified load_clip_configs to accept both file paths and dictionary objects for configuration.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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
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 enhances the load_clip_configs function to accept either a file path or a dictionary, increasing its flexibility. My review focuses on improving the implementation's robustness and clarity by adding proper type hinting, more descriptive parameter naming, and explicit error handling for invalid input types. These changes will make the function more maintainable and easier to use correctly.

Comment on lines +35 to +40
def load_clip_configs(main_json_path):
if isinstance(main_json_path, dict):
cfg = main_json_path
else:
with open(main_json_path, "r", encoding="utf-8") as f:
cfg = json.load(f)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The function now accepts both a path and a dictionary, which is great for flexibility. However, there are a few improvements that could be made for robustness and clarity:

  • Type Hinting: The type hint was removed. It's good practice to add it back to reflect the accepted types (e.g., Union[str, dict]). You'll need to import Union from typing.
  • Parameter Naming: The parameter name main_json_path is now misleading. A more descriptive name like main_config would improve readability.
  • Error Handling: The current implementation doesn't handle cases where the input is neither a str nor a dict. It would be more robust to add an explicit check and raise a TypeError, similar to the get_config_json function in this file.
Suggested change
def load_clip_configs(main_json_path):
if isinstance(main_json_path, dict):
cfg = main_json_path
else:
with open(main_json_path, "r", encoding="utf-8") as f:
cfg = json.load(f)
def load_clip_configs(main_config: "Union[str, dict]"):
if isinstance(main_config, dict):
cfg = main_config
elif isinstance(main_config, str):
with open(main_config, "r", encoding="utf-8") as f:
cfg = json.load(f)
else:
raise TypeError("main_config must be a file path (str) or a dictionary.")

@helloyongyang helloyongyang merged commit b3ae477 into main Mar 16, 2026
2 checks passed
@helloyongyang helloyongyang deleted the gp/dev branch March 16, 2026 06:29
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