modelpack
Python client for pushing and pulling CNCF ModelPack artifacts through any OCI Distribution-compatible registry, including Harbor, Docker Hub, and GHCR.
Installation
pip install modelpack-client
Python API
from modelpack_client import (
ModelDescriptor,
ModelLayer,
ModelPackClient,
ModelPackConfig,
ModelTechnicalConfig,
)
client = ModelPackClient()
client.login(
"ghcr.io",
username="octocat",
password="TOKEN",
)
config = ModelPackConfig(
descriptor=ModelDescriptor(
name="example-model",
version="1.0.0",
licenses=("Apache-2.0",),
),
config=ModelTechnicalConfig(
architecture="transformer",
format="safetensors",
param_size="7B",
precision="float16",
),
)
result = client.push(
"ghcr.io/example/models/example:1.0.0",
layers=[
ModelLayer("model.safetensors"),
ModelLayer(
"tokenizer.json",
media_type="application/vnd.cncf.model.weight.config.v1.raw",
),
],
config=config,
)
print(result.digest)
pulled = client.pull(
"ghcr.io/example/models/example:1.0.0",
"./example-model",
)
print(pulled.files)
print(pulled.config)
Directories passed as layers are packed as tar layers: a raw media type becomes
the matching tar type, and the +gzip and +zstd tar types are compressed.
Entries are sorted, and owners, timestamps and permissions (except the
executable bit) are normalized, so the same tree gets the same digest on any
machine. Hard links are stored as regular files; symbolic links are rejected.
The client sets the required ModelPack artifact/config media types, generates
modelfs.diffIds, validates configs against the specification's JSON schema,
verifies manifests and blobs against their digests, and rejects unsafe artifact
and archive paths.
pull() unpacks tar layers into the destination directory. With
unpack=False, they are saved as archives named after the layer's file path,
such as weights.tar. push() streams each blob in a single request; pass
chunked=True for registries that require chunked uploads. Each layer must be
pulled to its own path, so give files that share a name an artifact_path.
To use Docker's existing credential file, omit login(). oras-py loads
credentials from the standard registry configuration. A custom file can be
passed as config_path to push() or pull(), and its entries take
precedence. Credential files are read again on every call. login() saves
credentials to Docker's file or config_path, and logout() removes them from
the same file. Credentials and tokens are only sent to the registry they belong
to; an upload that the registry sends to another host goes without them.
CLI
modelpack push ghcr.io/example/models/example:1.0.0 \
--config model-config.json \
--layer model.safetensors \
--layer 'tokenizer.json:application/vnd.cncf.model.weight.config.v1.raw'
modelpack pull ghcr.io/example/models/example:1.0.0 ./model
python -m modelpack_client runs the same CLI.
Metadata
Release files for modelpack-client 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| modelpack_client-0.1.0.tar.gz | 22.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| modelpack_client-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 49.1 kB
Release files / modelpack_client-0.1.0.tar.gz
| Download URL | modelpack_client-0.1.0.tar.gz |
|---|---|
| Size | 22.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7bde76864d1d28e812cace4f396d415add8a32db36c7e6924dd6317fabdf6393
|
|
BLAKE2b-256 checksum How to use checksums |
a8db2bfae3123d44a4583a03dede21983aa9ad321a7c3fa8bcc6e9f0a608f030
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / modelpack_client-0.1.0-py3-none-any.whl
| Download URL | modelpack_client-0.1.0-py3-none-any.whl |
|---|---|
| Size | 26.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1d720075b91c263d2b799809885c83e6af54f229fec31c683b5ca6d1ecea14fa
|
|
BLAKE2b-256 checksum How to use checksums |
6f6e360c59cd84a9e04f6e752f85ac5568b28dfdb5c5c2295e9c60e4a8d3f87a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for modelpack-client 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.