Skip to content

fix: bugfix in dev mode#93

Merged
Col0ring merged 1 commit intomainfrom
fix/dev-mode
Sep 5, 2025
Merged

fix: bugfix in dev mode#93
Col0ring merged 1 commit intomainfrom
fix/dev-mode

Conversation

@Col0ring
Copy link
Copy Markdown
Collaborator

@Col0ring Col0ring commented Sep 5, 2025

No description provided.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Sep 5, 2025

🦋 Changeset detected

Latest commit: 0d2d8be

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown

@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 @Col0ring, 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 addresses a bug in development mode by streamlining component imports and dynamically adjusting the documentation interface. It refactors how modelscope_studio components are imported and ensures that the legacy documentation tab is not displayed when the application is running in a development environment, improving the developer experience and preventing potential issues specific to legacy components during development.

Highlights

  • Refactored Component Imports: The import structure for modelscope_studio components has been refactored. Individual component imports were moved from backend/modelscope_studio/init.py to a new backend/modelscope_studio/components/init.py file, simplifying the main init.py.
  • Conditional Legacy Tab Removal in Dev Mode: A new is_dev flag has been introduced in docs/app.py which is set based on the GRADIO_WATCH_MODULE_NAME environment variable. When in development mode, the 'Version 0.x' (legacy) documentation tab is now conditionally excluded from the application.
  • Robust Tab Handling in Site Helper: The Site class in docs/helper/Site.py has been updated to filter out None values from its tabs list. This change ensures that conditionally excluded tabs (like the legacy tab in dev mode) do not cause issues in the site rendering.
  • New Changeset Entry: A new changeset file, .changeset/twenty-moles-slide.md, has been added to document this patch, specifically noting a bugfix in dev mode for modelscope_studio.
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
Copy Markdown

@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 a fix for development mode by conditionally hiding the 'legacy' components tab. The implementation involves adding a None value to a list in dev mode and then filtering it out in a constructor, which works but could be made more direct. Additionally, the PR refactors component imports, but continues to use wildcard imports (import *), which is generally discouraged for maintainability. I've provided suggestions to improve the conditional logic and address the use of wildcard imports.

from .components.base import *
from .components.legacy.components import *
from .components.pro.components import *
from .components import *
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using a wildcard import (from .components import *) is generally discouraged as it can make it unclear which names are present in the namespace, potentially causing confusion and making the code harder to maintain.1

Style Guide References

Footnotes

  1. PEP 8 advises against wildcard imports (from <module> import *) because they make it unclear which names are present in the namespace. This can confuse both human readers and automated tools.

Comment on lines +1 to +5
from .antd.components import *
from .antdx.components import *
from .base import *
from .legacy.components import *
from .pro.components import *
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This new __init__.py file centralizes component imports, but it uses multiple wildcard imports (from ... import *). This practice is discouraged by PEP 8 because it pollutes the namespace and hides which names are being exported.1 It can make debugging and code navigation difficult. Consider defining __all__ in each submodule and then explicitly importing and re-exporting them here to create a clear public API for the components package.

Style Guide References

Footnotes

  1. PEP 8 advises against wildcard imports (from <module> import *) because they make it unclear which names are present in the namespace. This can confuse both human readers and automated tools. Using __all__ is the recommended way to define a module's public API.

Comment thread docs/app.py
"key": "legacy",
"content": legacy_demo
},
} if not is_dev else None,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This conditional logic to add None to the list works, but it makes the code less direct. The Site class now has to be aware of and filter out these None values. A cleaner approach would be to conditionally append the entire dictionary to the tabs list after its initial definition. This would keep the logic for constructing the tabs list self-contained and avoid passing None values around.

For example:

# After defining the main `tabs` list...
if not is_dev:
    tabs.append({
        "label": get_text("Version 0.x", "0.x 版本"),
        "key": "legacy",
        "content": legacy_demo
    })

This would remove the need for this inline conditional and the corresponding filtering logic in the Site constructor.

@Col0ring Col0ring merged commit 4bfbc1d into main Sep 5, 2025
2 checks passed
@Col0ring Col0ring deleted the fix/dev-mode branch September 5, 2025 09:02
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.

1 participant