Repository navigation
Use real commit hashes as ref target commits when the platform expose - #84
Merged
tastelikefeet merged 3 commits intoNov 18, 2026
Merged
Conversation
…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.
wangxingjun778
approved these changes
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.