Commit Graph

76 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>
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
Xingjun.Wang
5db3b88e2a add property session in HubApi (#1748) 2026-07-03 10:38:49 +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
fc0e2159a3 [Fix] Fix preview csv stream loading (#1665) 2026-04-14 14:17:23 +08:00
Xingjun.Wang
f4dbe65110 [Fix] fix dataset util (#1645) 2026-03-13 10:36:11 +08:00
tastelikefeet
6dd24e3e3c lint code (#1619) 2026-02-19 17:58:09 +08:00
tastelikefeet
c1d91a4454 fix downloading txt files (#1610) 2026-02-19 17:18:40 +08:00
Xingjun.Wang
f9dd6794c4 Fix #1316 (#1612) 2026-02-11 13:57:52 +08:00
Xingjun.Wang
4f867bfe80 Fix: deprecate delete_repo, delete_model and delete_dataset due to token a… (#1588) 2026-01-12 11:51:46 +08:00
Gongsheng Li
a31c44cb5a Feat/update default revision (#1553) 2025-12-05 15:24:42 +08:00
Yunlin Mao
dfb370b77d fix daily regression (#1545)
* update daily regression

* update test
2025-11-07 17:45:59 +08:00
Yunlin Mao
723599ac48 Update list datasets to OpenAPI (#1532)
* update list datasets

* Update modelscope/hub/constants.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Update modelscope/hub/api.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Update modelscope/hub/api.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Update modelscope/hub/api.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* fix lint

* update workflow

* fix lint

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2025-11-05 17:04:29 +08:00
Gongsheng Li
3fd95b1bd7 Feat/support commit scheduler (#1480) 2025-10-21 16:41:55 +08:00
Gongsheng Li
4733d5374b add support for siblings field in repo_info (#1490) 2025-09-08 17:22:29 +08:00
Gongsheng Li
2fc6d8e822 Feat/support repo info (#1483) 2025-08-29 17:23:46 +08:00
tastelikefeet
a5039281d3 skip aigc test (#1476) 2025-08-23 11:12:35 +08:00
Xingjun.Wang
055496c597 Fix CI 2025-08-07 19:26:32 +08:00
Koko-ry
1d93f7e56d Feat: Add AIGC model creation support to create_model (#1431)
1.  Add create aigc model in `create_model` func
2. Add CLI for creating aigc model
2025-08-06 17:01:42 +08:00
Yunlin Mao
ff7551c494 fix large log in scan cache test (#1439) 2025-08-04 20:58:30 +08:00
tastelikefeet
f01864a2f9 weak file lock (#1417) 2025-07-17 18:38:24 +08:00
Jintao
29ea57dfbc [hub] Support ProgressCallback (#1380)
1. Add ProgressCallback for file download
2025-06-26 14:02:05 +08:00
Yunlin Mao
b034267345 [Feature] Add scan_cache_dir function (#1348)
* init cache manager

* add scan cache

* fix lint

* add scan cache unit test

* add download first for scan cache test
2025-05-28 09:59:03 +08:00
Xingjun.Wang
6adc8614c9 Add create_repo and upload UTs (#1282)
* add delete_repo, delete_dataset, exists_ok in create_repo

* add UT for create_repo
2025-04-07 10:24:26 +08:00
Yingda Chen
12d492e21f fix log level 2025-03-13 17:23:01 +08:00
xingjun.wxj
1036316afe update fallback for UTs 2025-03-12 22:39:00 +08:00
Yingda Chen
175b8d315e support dataset too 2025-03-11 18:22:29 +08:00
Yingda Chen
7d91e1b243 add tests 2025-03-11 17:05:08 +08:00
Yingda Chen
18fb4286d9 repo exist api support dataset 2025-03-04 15:18:37 +08:00
Yingda Chen
65075191f7 clean directory structure (#1201)
默认
模型:
~/.cache/modelscope/hub/models/{model_owner}/{model_name}
数据集:
~/.cache/modelscope/hub/datasets/{dataset_owner}/{dataset_name}

配置MODELSCOPE_CACHE环境变量:
模型:
$MODELSCOPE_CACHE/models/{model_owner}/{model_name}
数据集:
$MODELSCOPE_CACHE/datasets/{dataset_owner}/{dataset_name}

Co-authored-by: Yingda Chen <yingda.chen@alibaba-inc.com>
2025-01-23 17:31:49 +08:00
tastelikefeet
b1404cdc2e Fix typo and unused imports (#1196)
* fix file exists of sub folder

* fix code doc

* add ci

* lint code

* fix unused imports and typo
2025-01-18 10:22:22 +08:00
tastelikefeet
b892164d11 Fix file exists of sub folder (#1192)
* fix file exists of sub folder

* fix code doc

* add ci

* lint code
2025-01-18 09:59:14 +08:00
Yingda Chen
83f1e20e80 add repo existence check hub-api (#1060)
* add repo existence check api

* update

---------

Co-authored-by: Yingda Chen <yingda.chen@alibaba-inc.com>
2024-11-02 08:04:40 +08:00
tastelikefeet
74d97ea7e0 Refactor zero sized file downloading (#991) 2024-09-14 15:12:28 +08:00
mulin.lyh
da9f3e58e3 enable download branch 2024-07-31 18:10:44 +08:00
mulin.lyh
775c29ef79 optimize code 2024-07-31 17:01:06 +08:00
liuyhwangyh
f7a32e48e3 add dataset download (#906)
* add dataset download

* fix cr issue

* fix cv matplotlib issue

* refactor code

* fix ut issue

* remove debug code

* remove unused import

* fix import issue

* sleep 65s before start docker avoid kill and run failed

---------

Co-authored-by: mulin.lyh <mulin.lyh@taobao.com>
2024-07-12 19:06:44 +08:00
zhyncs
5b8e1e971c fix ignore_file_pattern (#886)
* fix ignore_file_pattern

---------

Co-authored-by: root <root@kunkun>
2024-07-01 14:31:39 +08:00
mulin.lyh
4a22b05891 restore http_get_file interface 2024-05-28 15:09:05 +08:00
liuyhwangyh
17da5e2264 fix error report (#868)
Co-authored-by: mulin.lyh <mulin.lyh@taobao.com>
2024-05-28 14:38:19 +08:00
liuyhwangyh
5c470f8941 Download optimize (#862)
* fix #845

Supports resumption of downloads from breakpoints, optimized download progress bar, finer display granularity, better experience under low bandwidth, and added function of downloading specified directories.

* restore push to hub

* fix merge issue

* fix ut issue

---------

Co-authored-by: mulin.lyh <mulin.lyh@taobao.com>
2024-05-24 15:37:43 +08:00
mulin.lyh
8c80b0c3f5 support master branch version and add http request id
Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/14072105
* support master branch version and add http request id

* modify no revision use master

* add specified revision="master"

* error message add request id
2023-09-20 19:29:30 +08:00
yuze.zyz
febc0365de Support FlexTrain and update the structure of trainer
1. Refactor training_args
2. Refactor hooks
3. Add train_id for push_to_hub
4. Support both output_dir/output_sub_dir for checkpoint_hooks
5. Support copy when hardlink fails when checkpointing
6. Support mixed dataset config file as a CLI argument
7. Add eval txt in output folder
Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/12384253
* support the ignorance of file pattern
2023-05-13 12:12:04 +08:00
mulin.lyh
8ea82e6f6d * add lfs append 2023-04-18 20:32:11 +08:00
yuze.zyz
2650d37094 Fix the log level and return value of push_to_hub
Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/12338218
2023-04-15 16:42:35 +08:00
yuze.zyz
4040320346 push to hub
Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/12235855
2023-04-10 18:17:52 +08:00
mulin.lyh
af641f7838 temporarily skip hub cases 2023-04-04 06:41:13 +08:00
wenmeng.zwm
285208912b add command line tool
Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/11661608

* add command line tool

* add unittest

* change absolute import to relative import for test case

* mv test_util to package
2023-02-20 21:21:54 +08:00
mulin.lyh
e54694690f [to #46993990]feat: run ci cases base on code diff to reduct ci test time 2023-02-06 08:00:19 +00:00