mirror of
https://github.com/modelscope/modelscope.git
synced 2026-07-09 20:09:17 +02:00
[Fix] Fix studio cli (#1742)
This commit is contained in:
@@ -11,7 +11,7 @@ plugins_manager = PluginsManager()
|
||||
|
||||
|
||||
class PluginsCMD(CLICommand):
|
||||
name = 'plugin'
|
||||
name = 'plugins'
|
||||
|
||||
@staticmethod
|
||||
def register(subparsers: ArgumentParser) -> None:
|
||||
|
||||
@@ -90,9 +90,19 @@ class HubApi(_LegacyHubApi):
|
||||
# ------------------------------------------------------------------
|
||||
# Legacy method shims missing from LegacyHubApi
|
||||
# ------------------------------------------------------------------
|
||||
def create_model(self, model_id: str, **kwargs) -> None:
|
||||
"""Create a model repo — delegates to ``create_repo`` (model type)."""
|
||||
return self.create_repo(model_id, repo_type='model', **kwargs)
|
||||
def create_model(self, model_id: str, **kwargs) -> str:
|
||||
"""Create a model repo — delegates to ``create_repo`` (model type).
|
||||
|
||||
Returns the model repository URL for backward compatibility.
|
||||
Authentication errors are converted to ``ValueError`` by the compat layer.
|
||||
"""
|
||||
# LegacyHubApi.create_model handles exception conversion;
|
||||
# override endpoint in the returned URL with local self.endpoint.
|
||||
result = super().create_model(model_id, **kwargs)
|
||||
# Replace endpoint in URL with the one resolved at __init__ time
|
||||
if result and self.endpoint and self.endpoint not in result:
|
||||
return f'{self.endpoint}/models/{model_id}'
|
||||
return result
|
||||
|
||||
def get_model_url(self, model_id: str) -> str:
|
||||
"""Return the model page URL ``{endpoint}/{model_id}``."""
|
||||
|
||||
@@ -147,10 +147,12 @@ def check_model_from_owner_group(model_dir: str,
|
||||
if group in owner_group:
|
||||
return True
|
||||
# Also check cache path pattern: {cache_root}/{owner}--{model_name}/snapshots/{revision}
|
||||
# Only check the grandparent directory to avoid path traversal attacks
|
||||
# Require exactly "{owner}--{name}" format (2 segments split by --)
|
||||
# to prevent spoofing via accounts like "iic--hacked" which would
|
||||
# produce paths like "iic--hacked--evil" and bypass the check.
|
||||
grandparent = os.path.basename(os.path.dirname(parent_dir))
|
||||
if '--' in grandparent:
|
||||
prefix = grandparent.split('--', 1)[0]
|
||||
if prefix in owner_group:
|
||||
parts = grandparent.split('--')
|
||||
if len(parts) == 2 and parts[0] in owner_group:
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -34,6 +34,7 @@ plugins = "modelscope.cli.plugins:PluginsCMD"
|
||||
skills = "modelscope.cli.skills:SkillsCMD"
|
||||
llamafile = "modelscope.cli.llamafile:LlamafileCMD"
|
||||
modelcard = "modelscope.cli.modelcard:ModelCardCMD"
|
||||
studio = "modelscope.cli.studio:StudioCMD"
|
||||
|
||||
[build-system]
|
||||
requires = ["setuptools>=69", "wheel"]
|
||||
|
||||
Reference in New Issue
Block a user