Commit Graph

2932 Commits

Author SHA1 Message Date
suluyana
7e0eacb0ec fix: forward download kwargs in HF patcher snapshot_download calls (#1762)
* fix: forward download kwargs in HF patcher snapshot_download calls

Honor local_files_only, cache_dir, token, and revision/code_revision when
resolving from_pretrained and cross-repo auto_map dynamic modules.

Co-authored-by: Cursor <cursoragent@cursor.com>

* style: fix yapf/flake8 formatting in hf util tests

Co-authored-by: Cursor <cursoragent@cursor.com>

* style: yapf format legacy cache reuse helpers

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: suluyan <suluyan.sly@aliabab-inc.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
v1.39.0
2026-07-22 17:00:09 +08:00
suluyan
cfe1f4190c fix: reuse legacy hub cache and use build-time PyPI fallback
Reuse flat/hub legacy caches in download paths. For docker builds, pass
PIP_EXTRA_INDEX_URL via ARG and RUN export so PyPI is available during
install without persisting it as an image ENV default.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-21 20:01:05 +08:00
Xingjun.Wang
9ab427b29a [Fix] Fix progress_callbacks for snapshot_download func (#1760)
* fix(msdatasets): make HfFileSystem monkey-patch idempotent for repeated streaming loads

When streaming=True the patches on HfFileSystem._open and HfFileSystem.__init__
are intentionally kept alive after load_dataset_with_ctx exits. A second call to
load_dataset_with_ctx then snaps the already-patched wrappers as 'originals',
causing _hf_fs_init_with_cookie / _hf_fs_open to call themselves recursively
until RecursionError: maximum recursion depth exceeded.

Fix: detect whether HfFileSystem is already patched before overwriting
_hf_fs_{open,init}_original, and skip re-applying the patch when it is already
in place.  The finally-block restores only patches that were applied in the
current invocation, leaving pre-existing patches intact.

Adds: test_hf_filesystem_patch_idempotent_for_repeated_streaming_loads

* fix(msdatasets): restore patches when streaming load fails; hermetic tests

Addresses both Gemini Code Assist review comments on PR #1754:

1. Bug fix – patch leak on failed streaming loads:
   Replace  guard with  flag.
   The flag is set True only after load_dataset() succeeds with streaming=True.
   Any exception in load_dataset (network, auth, invalid dataset, etc.) leaves
   _streaming_dataset_returned=False, so the finally block always restores all
   monkey-patches, preventing permanent global-state corruption.

2. Test improvement – hermetic test environment:
   Add _reset_hf_filesystem_patch() helper that strips pre-existing patches
   before each unit test, ensuring tests are independent of execution order.
   Add test_hf_filesystem_patch_restored_when_streaming_load_fails to cover
   the bug scenario introduced in fix 1.

* update requirements for hub

* feat(hub): restore progress_callbacks on snapshot_download shim (issue #1757)

The progress_callbacks parameter was dropped from snapshot_download after v1.38, breaking legacy code and GUI progress reporting. Re-expose it on modelscope.hub.snapshot_download (positioned before token per the v1.34 signature) and forward it to modelscope_hub.compat. Requires modelscope-hub >= 0.1.8.

Add network-free forwarding tests that patch the compat delegate so the real shim executes.

* fix lint

* feat(hub): add legacy-cache capability guard to snapshot_download shim

Warn once (thread-safe) when the installed modelscope-hub lacks pre-1.38 legacy cache auto-detection (DownloadManager._find_legacy_repo_dir, added in modelscope-hub>=0.1.7), so programmatic snapshot_download/dataset_snapshot_download callers are not silently downloading into the new layout while an old cache exists. Capability is probed, not reimplemented (kept single-sourced in modelscope-hub). Adds network-free tests for present/absent capability and fire-once behavior.
2026-07-21 17:57:49 +08:00
suluyana
ac61e0bd8f [Fix]dynamic module auto map double dash (#1761)
* fix: resolve cross-repo auto_map when cache paths contain --

modelscope_hub 0.1.x layout embeds -- in local dirs; rejoining that
path into class_reference broke transformers' split("--"). Pass the
local snapshot as pretrained_model_name_or_path with a bare class name
instead, and stop mutating the args tuple in place.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: reject empty model name in trusted owner cache paths

check_model_from_owner_group treated paths like iic--/snapshots/v1 as
trusted because split('--') still yields two parts. Require both owner
and name segments to be non-empty.

Co-authored-by: Cursor <cursoragent@cursor.com>

* test: cover remote pretrained args tuple rebuild in dynamic module patcher

The TypeError from mutating *args was already fixed with the auto_map
double-dash change; add an explicit regression test for that branch.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: derive valid module names from snapshot revision paths

Path(model_dir).stem on revisions like v1.0.4 produced v1.0, so
importlib treated it as package v1 and raised ModuleNotFoundError.
Use the owner--name (+ revision) segment and sanitize to an identifier.

Co-authored-by: Cursor <cursoragent@cursor.com>

* test: cover module naming for dotted snapshot revisions

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: handle pretrained_model_name_or_path passed via kwargs

When the arg is only in kwargs, downloading and then forcing a
positional overwrite caused a duplicate-keyword TypeError. Resolve and
update kwargs or args consistently for both the download and cross-repo
branches.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix lint

* fix(docker): catch JSONDecodeError when querying Docker Hub tags

Non-JSON Hub responses (block pages, 5xx HTML) would bypass URLError
handling and crash json.load; surface them as RuntimeError instead.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: suluyan <suluyan.sly@aliabab-inc.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-20 19:49:53 +08:00
suluyan
4f223056cd fix(docker): pin transformer_engine to 2.16.0 for 1.39.0
Temporarily pin for the 1.39.0 release: TE 2.17 has no prebuilt
transformer_engine_torch wheels and fails to compile from source.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-20 10:11:46 +08:00
suluyan
5ee9b27220 feat(docker): add AMD ROCm image build from vllm-openai-rocm
Add image_type=amd that auto-resolves the newest concrete Docker Hub
tag, probes rocm/python/torch without GPU, installs modelscope from the
build branch, and tags as ubuntu*-rocm*-py*-torch*-{version}.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-17 11:19:02 +08:00
suluyan
b5c6f8a462 fix(docker): limit notebook deps to stable images only
Keep ipywidgets, jupyter_core, nbconvert, and nbclient inside the
INSTALL_MS_DEPS gate so latest and old image builds are unaffected.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-16 16:29:44 +08:00
suluyan
860323a22b bump version 2026-07-16 15:48:55 +08:00
suluyan
4865b47b19 feat(docker): add notebook deps for stable and latest images
Install ipywidgets, ipykernel, jupyter_core, nbconvert, and nbclient
outside the INSTALL_MS_DEPS gate so latest GPU images also support
python -m jupyter nbconvert for agent notebook debugging.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-16 15:26:20 +08:00
suluyan
d06f6912d0 fix: remove global pip extra-index-url from docker images
Align LLM image pip config with GPU images by dropping the persistent
pypi.org extra-index-url that was added for modelscope-hub fallback.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-16 14:05:55 +08:00
Xingjun.Wang
61571c0169 Fix RecursionError on Repeated Streaming Dataset Loads via Idempotent HfFileSystem Patching (#1754) 2026-07-14 16:19:08 +08:00
tastelikefeet
9379504fd3 Fix some bugs (#1746) 2026-07-07 11:26:14 +08:00
Yunlin Mao
d5d13c1f25 Fix release workflow hub dependency (#1749) 2026-07-06 11:39:03 +08:00
Xingjun.Wang
5db3b88e2a add property session in HubApi (#1748) 2026-07-03 10:38:49 +08:00
Yunlin Mao
020cad8229 [Backport] Docker fixes from release/1.38 (#1735)
* Upgrade numpy to 2.x for 1.38 Docker images

- Replace deprecated numpy aliases (np.math.ceil → math.ceil, np.Inf → np.inf)
- Upgrade Docker constraints: numpy>=2.0, cython>=3.0, remove scipy upper bound

* Add ipywidgets dependency to Docker images

* update docker

* fix

* fix

* fix

* fix cpu image

* fix(docker): force numpy>=2.0 after evalscope install

ms-opencompass pulls numpy<2.0, downgrading numpy from 2.x to 1.26.4.
Force reinstall numpy>=2.0 after pip install .[eval] to restore it.

* add metax dockerfile and its requirements for ms-swift 4.2.x (#1734)

* Update npu dockerfile (#1736)

* fix(docker): remove unrelated added docker files

---------

Co-authored-by: Jintao Huang <huangjintao.hjt@alibaba-inc.com>
Co-authored-by: dwd <dwd1044898101@gmail.com>
Co-authored-by: addsubmuldiv <zyh13227@163.com>
2026-06-26 17:10:49 +08:00
Xingjun.Wang
39583ec639 fix: patch_context() use try/finally to ensure unpatch on exception (#1743)
- Wrapped yield in try/finally block so unpatch_hub() executes even when
  the with-body raises an exception, preventing patch state leakage
2026-06-25 16:04:11 +08:00
Xingjun.Wang
cf08fb242d [Fix] Fix studio cli (#1742) 2026-06-23 16:42:49 +08:00
tastelikefeet
cecb699cd0 fix (#1740) 2026-06-18 17:16:11 +08:00
addsubmuldiv
c1d88e6ab7 Update npu dockerfile (#1736) 2026-06-15 11:07:56 +08:00
tastelikefeet
c7dba8de1e Fix some security issues (#1737) 2026-06-15 10:35:50 +08:00
dwd
37eb369e9b add metax dockerfile and its requirements for ms-swift 4.2.x (#1734) 2026-06-15 10:04:01 +08:00
Xingjun.Wang
d3effb7370 [Update] Update modelscope-hub requirement (#1733) 2026-06-09 20:08:33 +08:00
Xingjun.Wang
50f8d37bc9 [Feat & Refactor] Refactor hub and CLI modules (#1732)
* refactor(hub): shim layer delegating to modelscope-hub

- Replace hub/api.py (4674→250 lines) with shim inheriting LegacyHubApi
- Replace hub/snapshot_download.py, callback.py with thin shims
- Partial shim hub/file_download.py (retain http_get_file)
- Shim hub/constants.py and errors.py with legacy aliases
- Shim hub/git.py, repository.py, cache_manager.py, upload_*.py
- Migrate CLI entry to modelscope_hub.cli.main:run_cmd
- Adapt 6 CLI commands as modelscope_hub.cli_plugins
- Delete redundant CLI files (download/upload/login/create/etc)
- Add modelscope-hub>=0.2.0 dependency, Python>=3.10
- Add __getattr__ proxy for forward-compatible method access
- Propagate timeout/max_retries to internal LegacyClient
- Bridge MODELSCOPE_CREDENTIALS_PATH env var to HubConfig

* fix lint: isort/yapf formatting + exclude hub/api.py from hooks

* set modelscope-hub>=0.0.5

* remove unused code

* refactor(hub): standardize token naming — git_token vs token

Disambiguate git token and SDK/API token naming across the hub layer:
- ModelScopeConfig: get_token/save_token → get_git_token/save_git_token
  (old names kept as deprecated aliases with DeprecationWarning)
- GitCommandWrapper: rename token params to git_token in clone/push/config
- Repository/DatasetRepository: auth_token → git_token (deprecated compat kept)
- data_loader.py: update caller to use get_git_token()

SDK token references (HubApi(token=...), get_cookies(access_token=...),
commit_scheduler.token) remain unchanged as they correctly use `token` naming.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* remove(msdatasets): remove all Virgo-related implementation

Remove the entire Virgo dataset subsystem which is no longer needed:
- Remove VirgoDataset class and VirgoDownloader
- Remove VirgoAuthConfig and VirgoDatasetConfig
- Remove Hubs.virgo enum value
- Remove fetch_virgo_meta from DataMetaManager
- Remove download_virgo_files from DatasetContextConfig
- Remove test_virgo_dataset.py test file
- Clean up unused imports (pandas, MaxComputeUtil, valid_url, etc.)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat(hub): add OSS dataset operations and meta-file download to HubApi

Add methods that msdatasets depends on but don't belong in modelscope_hub:
- _legacy_request: internal helper combining legacy HTTP transport with
  application-level envelope validation (Code/Data/Message)
- list_oss_dataset_objects: list OSS storage objects for a dataset
- delete_oss_dataset_object / delete_oss_dataset_dir: delete OSS objects
- fetch_meta_files_from_url: download and cache meta CSV/JSONL files

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix imports issue

* fix: address PR review feedback

- cli/plugins.py: change --yes and --all flags to action='store_true'
- hub/git.py: replace os.linesep with .splitlines() for cross-platform safety
- hub/__init__.py: use is_file() with fallback for robust credentials path detection

* fix lint

* update ms hub version

* fix(ci): add PyPI official as fallback index for pip

Aliyun mirror may lag behind PyPI for newly published packages,
causing dependency resolution failures (e.g. modelscope-hub>=0.0.6).
Add pypi.org/simple as extra-index-url so new versions are immediately
available while keeping the Aliyun mirror as the primary source.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix UTs

* remove unused UTs

* fix ut

* update modelscope-hub installation for source code

* fix UT

* fix uts

* fix ut

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-09 20:00:20 +08:00
Xingjun.Wang
1804ac6bf8 [Feature] Add studio module (#1727) 2026-06-05 14:33:25 +08:00
Xingjun.Wang
63ff6ec6e9 Addgated_mode for create repo (#1730) 2026-06-05 14:30:18 +08:00
Seas0
491e3df224 fix: quote version of timm specs in Dockerfile.ubuntu (#1728)
Co-authored-by: Seas0 <liusichen.seas0@bytedance.com>
2026-06-03 18:50:04 +08:00
AAAkater
2719754beb 🐛 fix(clearcache): fix single model cache path (#1724)
* 🐛 fix(clearcache): fix single model cache path

- Add 'models' subdirectory under 'hub' for single model cache paths
- Align dataset and model path structures for consistency

* 🐛 fix(clearcache): use cache root helpers to handle MODELSCOPE_CACHE correctly

Unconditionally prepending `hub/` broke `$MODELSCOPE_CACHE`-set users,
since the cache root has no `hub/` segment in that case. Reuse
get_model_cache_root() / get_dataset_cache_root() from file_utils,
which already handle both default and env-set layouts. Add tests
covering both scenarios.

---------

Co-authored-by: Yunnglin <mao.looper@qq.com>
2026-06-03 18:39:39 +08:00
tastelikefeet
8bab4b9bc1 Fix bug: 1. patch_context cannot revert classmethod 2. kernels testcase miss trust_remote_code and revision (#1729) 2026-05-31 16:11:21 +08:00
Xingjun.Wang
76cf0450a1 Fix timeout for create_model_tag (#1723)
* update timeout for create_model_tag

* fix review comments
2026-05-29 14:10:45 +08:00
tastelikefeet
70197537df Fix adaseq trust_remote_code (#1721) 2026-05-20 23:12:03 +08:00
雨泓
57961c1f4b fix pipelines in plugin 2026-05-19 15:05:21 +08:00
tastelikefeet
d52d5e67b2 Add whitelist to iic and damo (#1720) 2026-05-19 12:53:02 +08:00
tastelikefeet
cddbabaed5 Fix pipeline parameter (#1717) 2026-05-15 14:06:55 +08:00
xvxuopop
6f347a203c update npu dockerfile (#1716) 2026-05-14 10:36:31 +08:00
Xingjun.Wang
d968a2cf87 [Fix] Fix split detection (#1714) 2026-05-13 17:46:20 +08:00
Xingjun.Wang
a56e2ce08f [Fix] fix invalid commit (#1715) 2026-05-13 17:46:07 +08:00
tastelikefeet
d77bc8f83b fix trainer + trust_remote_code (#1713) 2026-05-12 19:16:13 +08:00
tastelikefeet
b7d47748ed fix plugin (#1712) 2026-05-12 17:40:06 +08:00
tastelikefeet
c2b8d9f020 Fix plugin rce (#1703) 2026-05-09 14:44:09 +08:00
Xingjun.Wang
2da1d94913 fix upload cache ignore (#1709) 2026-05-08 15:14:08 +08:00
Xingjun.Wang
c15c5261e1 [Fix] Fix dataset preview args, private streaming auth, and download retries (#1700) 2026-05-08 15:13:52 +08:00
dwd
2f5f52fc3c feat(docker/Metax): add metax dockerfile and its requirements for ms-swift 4.1.x (#1689) 2026-05-06 20:57:17 +08:00
tastelikefeet
68ab75af24 fix (#1708) 2026-05-06 20:54:46 +08:00
Xingjun.Wang
13064d9486 [Fix] Fix msdatasets split issue (#1704) 2026-05-05 23:49:23 +08:00
addsubmuldiv
c18f11ccbd update ascend dockerfile (#1687) 2026-04-29 16:06:57 +08:00
Xingjun.Wang
f0ba7bf885 [Fix] Add endpoint for creating model repo (#1699) 2026-04-29 01:37:24 +08:00
tastelikefeet
b3808b7c20 Support kernels downloading (#1697) 2026-04-28 10:29:19 +08:00
Xingjun.Wang
10298197e0 [Fix] Update helper desc (#1696) 2026-04-27 21:21:04 +08:00
Xingjun.Wang
16a79bc80b [Feat & Fix] Refactor endpoint arg for CLI (#1695) 2026-04-27 17:28:37 +08:00
Xingjun.Wang
b3599deb03 [Fix] Upload report (#1694) 2026-04-27 12:31:19 +08:00