oci layers on top
Project description
oci layers on top
olot
is a python-based tool to append layers (files) onto an OCI-compatible image. It is meant to be used in conjunction with command-line based tools to fetch and upload these images. Tools such as skopeo or oras. It can be used either as a CLI tool, or via standard python interface. The package is published to pypy.
Usage
As a CLI
- use simple tool like
skopeo
( ororas cp
, or ...) and produce an oci image layout of the base image for the Modelcar (ie base image could be: A.ubi-micro
, B.busybox
, or C. even simple base image for KServe Modelcar, etc.) - (this project) use pure python way to add layers of the ML models, and any metadata like ModelCarD
- use simple tool from step 1 to push the resulting layout to the remote registry (i.e.
simpletool cp ... quay.io/mmortari/model:car
) - ... you now have a Modelcar inside of your OCI registry that can be used with KServe and more!
IMAGE_DIR=download
OCI_REGISTRY_SOURCE=quay.io/mmortari/hello-world-wait:latest
OCI_REGISTRY_DESTINATION=quay.io/mmortari/demo20241208:latest
rm -rf $IMAGE_DIR
# Downloads the image `/quay.io/mmortari/hello-world-wait:latest` to the folder `download` with tag `latest`
skopeo copy --multi-arch all docker://${OCI_REGISTRY_SOURCE} oci:${IMAGE_DIR}:latest
# If using oras, you will need to also need to add write permissions
# oras copy --to-oci-layout $OCI_REGISTRY_SOURCE ./${IMAGE_DIR}:latest
# chmod +w ${IMAGE_DIR}/blobs/sha256/*
# Appends to the image found in `download` the files `model.joblib` and as ModelCarD the `README.md`
poetry run olot $IMAGE_DIR --modelcard tests/data/sample-model/README.md tests/data/sample-model/model.joblib
# Pushes the (updated) image found in `download` folder to the registry `quay.io/mmortari/demo20241208` with tag `latest`
skopeo copy --multi-arch all oci:${IMAGE_DIR}:latest docker://${OCI_REGISTRY_DESTINATION}
# If using oras
# oras cp --from-oci-layout ./${IMAGE_DIR}:latest $OCI_REGISTRY_DESTINATION
You can now test the image to validate the files exist in it
podman run --rm -it $OCI_REGISTRY_DESTINATION ls -la /models/
Expected Output:
Unable to find image 'quay.io/mmortari/demo20241208:latest' locally
latest: Pulling from mmortari/demo20241208
6163eebc9af4: Download complete
1933e30a3373: Download complete
3dc1903f1fc8: Download complete
Digest: sha256:6effaec653c4ba4711c8bda5d18211014016e543e6657eb36ced186fb9aed9e4
Status: Downloaded newer image for quay.io/mmortari/demo20241208:latest
total 20
drwxr-xr-x 1 root root 4096 Feb 13 15:17 .
drwxr-xr-x 1 root root 4096 Feb 13 15:17 ..
-rw-rw-r-- 1 root root 6625 Dec 24 09:24 README.md
-rw-rw-r-- 1 root root 3299 Dec 24 09:24 model.joblib
Cleanup your local image
podman image rm quay.io/mmortari/demo20241208:latest
Dev notes
If copying the resulting image to local filesystem oci-layout using skopeo, make sure to enable --dest-oci-accept-uncompressed-layers
option.
As a Python Package
Install the package
pip install olot
# poetry add olot
Import and add layers onto a locally available model (using skopeo):
from olot.basic import oci_layers_on_top
from olot.backend.skopeo import skopeo_pull, skopeo_push
model_dir = 'download'
oci_registry_source='quay.io/mmortari/hello-world-wait:latest'
oci_registry_destination='quay.io/mmortari/demo20241208:latest'
model_files = [
'tests/data/sample-model/model.joblib',
'tests/data/sample-model/README.md',
]
# Download the model
skopeo_pull(oci_registry_source, model_dir)
# Add the layers
oci_layers_on_top(model_dir, model_files)
# Push the model
skopeo_push(model_dir, oci_registry_destination)
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
Built Distribution
File details
Details for the file olot-0.1.4.tar.gz
.
File metadata
- Download URL: olot-0.1.4.tar.gz
- Upload date:
- Size: 17.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 650910f1cbbdb18833a1acb63ecc6b22ca2cc7fe78a0ea0eeb15ca23b59ad39e |
|
MD5 | e600c1ee8577214f2246da52029b08cf |
|
BLAKE2b-256 | 3de4acf94425a529d5baf7c59f12a3d77246f6ca38e33a249945a6a3add0e7fa |
Provenance
The following attestation bundles were made for olot-0.1.4.tar.gz
:
Publisher:
release.yaml
on containers/olot
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
olot-0.1.4.tar.gz
- Subject digest:
650910f1cbbdb18833a1acb63ecc6b22ca2cc7fe78a0ea0eeb15ca23b59ad39e
- Sigstore transparency entry: 177874362
- Sigstore integration time:
- Permalink:
containers/olot@2b85361b65652053b0486abad85ef8470b36ec02
- Branch / Tag:
refs/tags/v0.1.4
- Owner: https://github.com/containers
- Access:
public
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
release.yaml@2b85361b65652053b0486abad85ef8470b36ec02
- Trigger Event:
push
- Statement type:
File details
Details for the file olot-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: olot-0.1.4-py3-none-any.whl
- Upload date:
- Size: 22.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e62a806935efea89d9d20a02245a7ca4f0b690aacf48d1f2c9adf926d42545b |
|
MD5 | 7d710d8d49125123ba8bf29a10c8be8d |
|
BLAKE2b-256 | 8991935d165a33c8643f1a61cb40a62ece2d0e9a4045eae3572e8dd29ba248c9 |
Provenance
The following attestation bundles were made for olot-0.1.4-py3-none-any.whl
:
Publisher:
release.yaml
on containers/olot
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
olot-0.1.4-py3-none-any.whl
- Subject digest:
2e62a806935efea89d9d20a02245a7ca4f0b690aacf48d1f2c9adf926d42545b
- Sigstore transparency entry: 177874376
- Sigstore integration time:
- Permalink:
containers/olot@2b85361b65652053b0486abad85ef8470b36ec02
- Branch / Tag:
refs/tags/v0.1.4
- Owner: https://github.com/containers
- Access:
public
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
release.yaml@2b85361b65652053b0486abad85ef8470b36ec02
- Trigger Event:
push
- Statement type: