Model Hub Reference¶
Nomad can download and cache model weights from various sources. Config files
use the name_or_path field to choose the source.
Name |
Example |
|---|---|
Local directory URI |
|
Hugging Face URI |
|
ORAS artifact |
|
Git/Git LFS HTTPS URI |
|
Git/Git LFS SSH URI |
|
Local path[1] |
|
Hugging Face repo ID[1] |
|
Plain HTTPS Git URL[2] |
|
SCP-style Git URL[2] |
|
Nomad resolves mutable remote sources, downloads them into a local cache, and
reuses cached artifacts across runs. Add #path/to/dir to any source when the
model files live in a subdirectory.
The Python API for these sources is nomad.hub.RepoSpec. Use
RepoSpec.resolved().uri() or RepoSpec.lock(...) when application code needs
a pinned URI for a remote source.
- nomad.hub.looks_like_digest(value)¶
Return True when
valuelooks like a bare or algorithm-prefixed digest.
- nomad.hub.get_cache_root()¶
Return the cache root, honoring XDG conventions or defaulting to ~/.cache.
- Return type:
- class nomad.hub.OrasRegistry(hostname=None, insecure=False, tls_verify=True, auth_backend='token')¶
ORAS registry client that refreshes stale bearer tokens after scope changes.
- push(target, *args, config_path=None, do_chunked=True, **kwargs)¶
Push a set of files to a target
- Parameters:
config_path (str) – path to a config file
disable_path_validation (bool) – ensure paths are relative to the running directory.
files (list) – list of files to push
insecure (bool) – allow registry to use http
annotation_file (str) – manifest annotations file
manifest_annotations (dict) – manifest annotations
target (str) – target location to push to
do_chunked (bool) – if true do chunked blob upload
chunk_size (int) – chunk size in bytes
subject (oras.oci.Subject) – optional subject reference
- pull(target, *args, config_path=None, **kwargs)¶
Pull an artifact from a target
- Parameters:
config_path (str) – path to a config file
allowed_media_type (list or None) – list of allowed media types
overwrite (bool) – if output file exists, overwrite
manifest_config_ref (str) – save manifest config to this file
outdir (str) – output directory path
target (str) – target location to pull from
- request(target, url, method='GET', *, config_path=None, data=None, headers=None, json=None, stream=False)¶
- do_request(url, method='GET', data=None, headers=None, json=None, stream=False)¶
Do a request. This is a wrapper around requests to handle retry auth.
- nomad.hub.run(cmd, cwd=None, capture=False, env=None)¶
Execute a subprocess, exiting the interpreter if the command fails.
- nomad.hub.check_dependencies()¶
Ensure required git tooling is available, exiting with a helpful message.
- Return type:
None
- class nomad.hub.RepoSpec(scheme, location, reference=None, subpath=None)¶
Normalized model-weight source URI with download and cache behavior.
- classmethod can_parse(spec, *, base_dir=None)¶
Return True when the input can be normalized into a RepoSpec.
- classmethod parse(spec, *, base_dir=None)¶
Normalize a model source string into a RepoSpec.
Missing schemes are treated as local files when the path exists and as Hugging Face model IDs otherwise.
- classmethod normalize(spec, *, base_dir=None)¶
Return a canonical model source URI for supported shorthand inputs.
- uri(*, base_dir=None)¶
Render this source as a canonical URI without resolving remote refs.
- Parameters:
base_dir (TypeAliasForwardRef('pathlib.Path') | None)
- Return type:
- resolved()¶
Return this source with mutable remote refs resolved where applicable.
- Return type:
- classmethod lock(spec, *, base_dir=None)¶
Return
specpinned to its current remote revision.
- as_https()¶
Return a copy that uses HTTPS transport when the scheme supports it.
- Return type:
- classmethod to_https_spec(spec, *, base_dir=None)¶
Return
specrewritten to HTTPS transport when possible.
- pull()¶
Return a local path containing this source, using the cache if needed.
- Return type:
- push(source)¶
Push
sourceto this destination and return the exported spec.- Parameters:
source (pathlib.Path)
- Return type:
- cache_dir()¶
Return the cache directory for the resolved source.
- Return type:
- class nomad.hub.FileRepoSpec(scheme, location, reference=None, subpath=None)¶
Local filesystem model-weight source.
- as_https()¶
Return a copy that uses HTTPS transport when the scheme supports it.
- Return type:
- uri(*, base_dir=None)¶
Render this source as a canonical URI without resolving remote refs.
- Parameters:
base_dir (TypeAliasForwardRef('pathlib.Path') | None)
- Return type:
- pull()¶
Return a local path containing this source, using the cache if needed.
- Return type:
- push(source)¶
Push
sourceto this destination and return the exported spec.- Parameters:
source (pathlib.Path)
- Return type:
- class nomad.hub.HuggingFaceRepoSpec(scheme, location, reference=None, subpath=None)¶
Hugging Face model repository source.
- as_https()¶
Return a copy that uses HTTPS transport when the scheme supports it.
- Return type:
- uri(*, base_dir=None)¶
Render this source as a canonical URI without resolving remote refs.
- Parameters:
base_dir (TypeAliasForwardRef('pathlib.Path') | None)
- Return type:
- resolved()¶
Return this source with mutable remote refs resolved where applicable.
- Return type:
- cache_digest()¶
Return the resolved Hugging Face revision used as the cache version.
- Return type:
- pull()¶
Download or reuse a Hugging Face snapshot and return its local path.
- Return type:
- class nomad.hub.GitRepoSpec(scheme, location, reference=None, subpath=None)¶
Git/Git LFS repository model-weight source.
- as_https()¶
Return a copy that uses HTTPS transport when the scheme supports it.
- Return type:
- uri(*, base_dir=None)¶
Render this source as a canonical URI without resolving remote refs.
- Parameters:
base_dir (TypeAliasForwardRef('pathlib.Path') | None)
- Return type:
- resolved()¶
Return this source with mutable remote refs resolved where applicable.
- Return type:
- pull()¶
Clone or reuse a cached git repository and return its path.
- Return type:
- class nomad.hub.OrasRepoSpec(scheme, location, reference=None, subpath=None)¶
ORAS artifact model-weight source.
- as_https()¶
Return a copy that uses HTTPS transport when the scheme supports it.
- Return type:
- uri(*, base_dir=None)¶
Render this source as a canonical URI without resolving remote refs.
- Parameters:
base_dir (TypeAliasForwardRef('pathlib.Path') | None)
- Return type:
- resolved()¶
Return this source with mutable remote refs resolved where applicable.
- Return type:
- pull()¶
Pull or reuse a cached ORAS artifact and return its path.
- Return type:
- push(source)¶
Push a local model directory and return a digest-pinned ORAS spec.
- Parameters:
source (pathlib.Path)
- Return type: