Skip to content

Use real commit hashes as ref target commits when the platform expose - #84

Merged
tastelikefeet merged 3 commits into
modelscope:mainfrom
tastelikefeet:feat/kernels-real-commit-refs
Nov 18, 2026
Merged

tastelikefeet merged 3 commits into
modelscope:mainfrom
tastelikefeet:feat/kernels-real-commit-refs

Conversation

@tastelikefeet

Copy link
Copy Markdown
Collaborator

ModelScope's revisions API does not carry git commit hashes today, so list_repo_refs hands out synthetic OIDs (branch-name-derived) and kernel lockfiles pin a moving branch rather than an immutable snapshot. This prepares the shim for the platform exposing real hashes: when a revisions entry carries one (probed under the Commit/CommitHash/commit keys, validated as 40/64-hex), it becomes the ref's target_commit verbatim, and the synthesized v1 of a master-only mirror inherits master's hash. Real hashes are deliberately not registered in the synthetic-OID table, so downloads by hash pass through unchanged — this relies on the platform's download API accepting commit-hash revisions as well. Without a hash (the current state) the synthetic-OID behaviour is unchanged.

Lockfile snapshot pinning therefore activates automatically once the platform's revisions API (list) and download path both accept real commit hashes; no further SDK change will be needed.

…s them

ModelScope's revisions API does not carry git commit hashes today, so
list_repo_refs hands out synthetic OIDs (branch-name-derived) and kernel
lockfiles pin a moving branch rather than an immutable snapshot. This
prepares the shim for the platform exposing real hashes: when a
revisions entry carries one (probed under the Commit/CommitHash/commit
keys, validated as 40/64-hex), it becomes the ref's target_commit
verbatim, and the synthesized v1 of a master-only mirror inherits
master's hash. Real hashes are deliberately not registered in the
synthetic-OID table, so downloads by hash pass through unchanged — this
relies on the platform's download API accepting commit-hash revisions
as well. Without a hash (the current state) the synthetic-OID behaviour
is unchanged.

Lockfile snapshot pinning therefore activates automatically once the
platform's revisions API (list) and download path both accept real
commit hashes; no further SDK change will be needed.
@tastelikefeet tastelikefeet changed the title Use real commit hashes as ref target commits when the platform expose… Use real commit hashes as ref target commits when the platform expose Nov 18, 2026
The upstream `kernels lock` console script runs in its own process and so
cannot pick up the in-process patch_kernels_hub() redirection — it always
resolved against the Hugging Face Hub, leaving no way to produce a
ModelScope-resolved kernels.lock. Two entry points now cover that gap:

- lock_kernels(dependencies, lockfile=None): the in-process equivalent of
  `kernels lock`. It builds KernelDependency entries (int/numeric versions
  become KernelVersion.Version, anything else a Revision), resolves the
  full dependency tree via kernels.locking.extract_dependency_locks with
  the Hub factory rebound to the ModelScope shim under patch_scope, and
  writes the serialized locks to kernels.lock (default: cwd).
- `ms-hub kernels lock [project_dir] [--lockfile]`: reads the same
  [tool.kernels.dependencies] table from pyproject.toml (tomllib with
  kernels.compat/tomli fallbacks for Python < 3.11) and delegates to
  lock_kernels, with actionable CLI errors when kernels or kernels>=0.18
  is missing.

README's lockfile notes now point at these entry points instead of the
not-actually-patchable `kernels` CLI. mypy's ignore list covers tomllib/
tomli for the 3.10 target.
The three `ms-hub kernels lock` execute tests imported kernels directly
to load it before the locking stub, which errored on CI runners where
only the [dev] extra is installed. They now use pytest.importorskip, so
minimal environments skip instead of erroring (matching the guards the
kernels test suite already uses). The CI test job additionally installs
the kernels extra so those tests — and the rest of the kernels suite,
which until now skipped wholesale on CI — actually run there.
@tastelikefeet
tastelikefeet merged commit 244d78a into modelscope:main Nov 18, 2026
6 checks passed
@tastelikefeet
tastelikefeet deleted the feat/kernels-real-commit-refs branch November 18, 2026 09:29
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.

2 participants