Skip to content

update import#13

Merged
Jintao-Huang merged 1 commit intomodelscope:mainfrom
Jintao-Huang:update_bridge
Apr 3, 2026
Merged

update import#13
Jintao-Huang merged 1 commit intomodelscope:mainfrom
Jintao-Huang:update_bridge

Conversation

@Jintao-Huang
Copy link
Copy Markdown
Collaborator

No description provided.

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 modifies the model package's initialization file to export the MODEL_MAPPING dictionary. The review feedback points out that exposing this raw dictionary directly in the public API could lead to encapsulation issues and bypass validation logic, suggesting that the register_model function should be exported instead to maintain internal consistency.

from .gpt_model import GPTModel
from .mm_gpt_model import MultimodalGPTModel
from .register import get_mcore_model, get_mcore_model_type, get_model_meta
from .register import MODEL_MAPPING, get_mcore_model, get_mcore_model_type, get_model_meta
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

Exposing the raw MODEL_MAPPING dictionary in the public API allows external code to modify the registry directly, which can bypass the validation logic in register_model and lead to inconsistencies with the internal model_type_mapping cache in register.py. If the intention is to allow external registration of models, it is recommended to export the register_model function instead. If the intention is to allow inspection of the registered models, consider providing a read-only view or a getter function to maintain better encapsulation.

Suggested change
from .register import MODEL_MAPPING, get_mcore_model, get_mcore_model_type, get_model_meta
from .register import get_mcore_model, get_mcore_model_type, get_model_meta, register_model

@Jintao-Huang Jintao-Huang merged commit 085a837 into modelscope:main Apr 3, 2026
1 check passed
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