Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .github/workflows/citest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: citest

on:
push:
branches:
- main
- "release/**"
paths-ignore:
- "docs/**"
- "temp/**"
- "README.md"
- "LICENSE"
- ".github/workflows/publish.yaml"

pull_request:
paths-ignore:
- "docs/**"
- "temp/**"
- "README.md"
- "LICENSE"
- ".github/workflows/publish.yaml"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
unittest:
# Mock mode: no credentials, no network calls to the Hub. This mirrors
# distro build sandboxes (NixOS/FreeBSD) so a green run here means the
# test suite also passes when downstream packagers run it.
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
# 3.10 = oldest supported, 3.14 = used by NixOS packaging.
python-version: ["3.10", "3.12", "3.14"]
env:
MODELSCOPE_RUN_REMOTE_TESTS: "false"
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install package with dev dependencies
run: pip install -e ".[dev]"

- name: Run unit tests (mock mode)
run: pytest tests/ --ignore=tests/integration -q

lint:
# Hard gate: the ruff/mypy backlog was cleared, keep it at zero.
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install package with dev dependencies
run: pip install -e ".[dev]"

- name: Ruff check
run: ruff check src/ tests/

- name: Ruff format check
run: ruff format --check src/ tests/

- name: Mypy
run: mypy src/modelscope_hub/
22 changes: 22 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,29 @@ concurrency:
cancel-in-progress: true

jobs:
test-gate:
# Release gate: the mock-mode suite must pass before anything is built
# or uploaded. Same environment shape as downstream distro sandboxes.
runs-on: ubuntu-latest
timeout-minutes: 30
env:
MODELSCOPE_RUN_REMOTE_TESTS: "false"
steps:
- uses: actions/checkout@v4

- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: '3.13'

- name: Install package with dev dependencies
run: pip install -e ".[dev]"

- name: Run unit tests (mock mode)
run: pytest tests/ --ignore=tests/integration -q

build-n-publish:
needs: test-gate
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand Down
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Local pre-commit hooks. Optional but recommended: CI (citest.yaml) enforces
# the same checks as a hard gate, this just gives faster feedback.
#
# Setup:
# pip install pre-commit && pre-commit install
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.11
hooks:
- id: ruff-check
args: [--fix]
files: ^(src|tests)/
- id: ruff-format
files: ^(src|tests)/
# mypy is intentionally left to CI: a full run over src/ takes too long for a
# commit hook and needs the package's own dependencies installed.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,20 @@ The official Python SDK & CLI for [ModelScope Hub](https://modelscope.cn) — do

## News

**v0.1.9** (2026-07-31)
- **Fix**: two stale unit tests that failed in downstream distro sandboxes ([#46](https://github.com/modelscope/modelscope_hub/issues/46), NixOS): align the `mcp deploy` call-shape assertion and the `parse_timestamp` timezone-normalization contract
- **Feature**: `ms-hub mcp deploy` prints the operational URL after deployment; new `--auth-check` and repeatable `--env KEY=VALUE` options; `--transport-type` now validates against `sse`/`streamable_http`
- **CI**: new `citest` workflow — mock-mode test suite (no credentials/network, mirrors distro build sandboxes) on Python 3.10/3.12/3.14 plus ruff/mypy hard gates; releases now require a green test gate before publishing; added a `pre-commit` config
- **Quality**: ruff & mypy debt cleared to zero; lint/type-check targets aligned to the supported Python floor (3.10)

**v0.1.8** (2026-07-21)
- **Feature**: `ms-hub agent` raw file transfer (download/upload/list) for remote agent repos; visibility support for agent hub; cache checksum verification (`ms-hub cache verify`)
- **Fix**: forward `progress_callbacks` through `HubApi.download_repo` so custom download-progress callbacks work end-to-end; harden legacy (pre-1.38) cache auto-detection (reuse existing `{cache}/models/...` and default `{cache}/hub/models/...` layouts); normal (non-LFS) file upload
- **Packaging**: rename console scripts to `modelscope-hub` / `ms-hub` to avoid a file conflict with the `modelscope` package (e.g. FreeBSD pkg)

<details>
<summary>Older releases</summary>

**v0.1.7** (2026-07-07)
- **Feature**: intra-/inter-region cloud download acceleration, with a source marker in the progress bar
- **Fix**: align `snapshot_download` cache path with the CLI; add legacy cache fallback
Expand All @@ -49,9 +58,6 @@ The official Python SDK & CLI for [ModelScope Hub](https://modelscope.cn) — do
**v0.1.5** (2026-06-30)
- **Fix**: adaptive commit batch size for uploads

<details>
<summary>Older releases</summary>

**v0.1.4** (2026-06-26)
- **Feature**: `gated_mode` parameter for `create_repo`; `ms-hub create --gated/--no-gated` flags
- **Refactor**: unify visibility / gated_mode semantics in the SDK layer
Expand Down
24 changes: 21 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,24 @@ modelscope_hub = ["py.typed"]
version = {attr = "modelscope_hub.version.__version__"}

[tool.ruff]
target-version = "py313"
# Must match requires-python (>=3.10): with py313 the UP rules would
# auto-rewrite code into 3.12+ syntax and silently break 3.10 support.
target-version = "py310"
line-length = 120

[tool.ruff.lint]
select = ["E", "F", "I", "N", "W", "UP"]

[tool.ruff.lint.per-file-ignores]
# Public exception names mirror the legacy SDK; renaming breaks downstream compat.
"src/modelscope_hub/errors.py" = ["N818"]
# Function-scope constants deliberately use CONST_CASE.
"src/modelscope_hub/api.py" = ["N806"]
"src/modelscope_hub/types.py" = ["N806"]
"src/modelscope_hub/compat/hub_api.py" = ["N806"]
# unittest.mock patch decorators inject mock classes; CamelCase args mirror the patched target.
"tests/**" = ["N803"]

[tool.pytest.ini_options]
testpaths = ["tests"]
markers = [
Expand All @@ -66,6 +78,12 @@ markers = [
addopts = "-v --tb=short"

[tool.mypy]
python_version = "3.13"
python_version = "3.10"
strict = false
warn_return_any = true
# The HTTP boundary (requests -> JSON) is dynamically typed; until response
# models are introduced, warning on Any-returns only produces noise.
warn_return_any = false

[[tool.mypy.overrides]]
module = ["tqdm.*", "modelscope.*"]
ignore_missing_imports = true
Loading
Loading