Skip to main content

A tool to build modelcar images with layers per file

Project description

modelcar-maker

Downloads Hugging Face models and packages them as minimal OCI container images with one file per layer. Designed for use with KServe as Modelcar images.

Install

Requires Python 3.11+.

pip install modelcar-maker

Usage

modelcar-maker [OPTIONS] [MODEL]
Argument / Option Description
MODEL Hugging Face model repo ID (e.g., meta-llama/Llama-3.2-3B-Instruct). Optional if models.default is configured.
--registry Registry for the output image. Default: quay.io.
-r, --repository Repository within the registry. Default: jharmison/models.
--backend Build backend. Default: olot. The podman backend requires extra dependencies (included via pip install modelcar-maker[podman])
--base-image Base OCI image. Default: registry.access.redhat.com/ubi10/ubi-micro:10.2.
--arch Target architecture(s). Repeat for multiple. Default: amd64, arm64.
--pull / --no-pull Pull base image if a newer version is available. Default: --pull.
--push / --no-push Push the image after building. Default: --push.
-a, --authfile Path to Docker/podman auth config for registry push.
--image-clean-up / --no-image-clean-up Remove local container image after push. Default: off.
--model-clean-up / --no-model-clean-up Remove downloaded model files after build. Default: off.
--skip-if-exists / --no-skip-if-exists Skip if the tag already exists at the registry. Default: on.
-v Increase logging verbosity. Repeat for more.
-V Print version and exit.

Image tag format: {registry}/{repository}/{normalized-model}-modelcar

The model repo ID is normalized for use as a tag: slashes become --, dots become _, and the string is lowercased. For example, meta-llama/Llama-3.2-3B-Instruct produces tag meta-llama--llama_3-2-3b-instruct-modelcar.

Examples:

# Build and push a model
modelcar-maker meta-llama/Llama-3.2-3B-Instruct

# Build locally without pushing
modelcar-maker BAAI/bge-large-en-v1.5 --no-push

# Explicit multi-arch build with cleanup
modelcar-maker mistralai/Mistral-7B --arch amd64 --arch arm64 --image-clean-up --model-clean-up

Configuration

Settings are resolved in layer order (later layers override earlier ones):

  1. Built-in defaults (defaults.toml)
  2. /usr/share/modelcar-maker/config.toml
  3. /etc/modelcar-maker/config.toml
  4. ~/.config/modelcar-maker/config.toml
  5. ./config.toml (current working directory)
  6. Environment variables with prefix MODELCAR_MAKER_

Any setting can be overridden via environment variable by uppercasing the section and key and joining with underscores. For example:

Env Var Overrides
MODELCAR_MAKER_IMAGE_REGISTRY image.registry
MODELCAR_MAKER_IMAGE_PUSH image.push
MODELCAR_MAKER_MODELS_DEFAULT models.default

Example config.toml:

[image]
registry = "quay.io"
repository = "myorg/models"
push = true
architectures = ["amd64"]

[models]
default = ["meta-llama/Llama-3.2-3B-Instruct", "BAAI/bge-large-en-v1.5"]

Setting default models allows running modelcar-maker with no arguments to build all listed models.

Running as a Container

The tool is available as a container image at ghcr.io/jharmison-redhat/modelcar-maker:latest (versioned tags also available).

podman run --rm ghcr.io/jharmison-redhat/modelcar-maker:latest --help

For authenticated pushes, mount a credential file. For gated downloads, provide the HF_TOKEN environment variable:

podman run --rm \
  -v "$HOME/.docker/config.json:/config.json" \
  -e HF_TOKEN="$HF_TOKEN" \
  ghcr.io/jharmison-redhat/modelcar-maker:latest \
  --authfile /config.json \
  meta-llama/Llama-3.2-3B-Instruct

To persist downloaded model files across runs, mount a volume at /modelcar-maker:

podman run --rm \
  -v modelcar-cache:/modelcar-maker \
  -v "$HOME/.docker/config.json:/config.json" \
  -e HF_TOKEN="$HF_TOKEN" \
  ghcr.io/jharmison-redhat/modelcar-maker:latest \
  --authfile /config.json \
  --skip-if-exists \
  meta-llama/Llama-3.2-3B-Instruct

docker may work but is untested.

License

ISC. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

modelcar_maker-0.4.0.tar.gz (30.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

modelcar_maker-0.4.0-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file modelcar_maker-0.4.0.tar.gz.

File metadata

  • Download URL: modelcar_maker-0.4.0.tar.gz
  • Upload date:
  • Size: 30.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for modelcar_maker-0.4.0.tar.gz
Algorithm Hash digest
SHA256 aa6bb6393841f8b517fa8f5efbd778db9f852e3c62535a6db72b0f2b38a0cdaf
MD5 48c2f2e02552aacdefafbe4504ee43e3
BLAKE2b-256 24fe4243dba60ba6eff61e12b3b52578934b3612d70be9de610faf10e021d8c3

See more details on using hashes here.

File details

Details for the file modelcar_maker-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: modelcar_maker-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for modelcar_maker-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2073ca5920933fb2bc1e98c9796240bcbb601f639e51a6a119b7138ce61f07d9
MD5 6f0d1f9abe0264894cde63b294a9a7da
BLAKE2b-256 c3390824441d85361613a4986bdd5d12c8a437f272ce86e91ce5a904a96daab5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page