alkirawy / blobz

A lazy Python library for OCI artifact storage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

logo

A lazy Python utility to store arbitrary artifacts in any docker image repository

Install

pip install blobz

Prerequisites

  • Working authentication to your image registry of choice e.g. ~/.docker/config.json

Quick Start

Push some files to a docker repository and add labels to the artifact

import blobz

blobz.push("myrepo/foo:v1", file="./tests/data/test.yaml", labels={"qux": "baz"})

Pull them back out

blobz.pull("myrepo/foo:v1", "./out/")

Push an arbitrary python object to a repository

bar_obj = Bar("bar", 1, {"qux": "baz"})

blobz.push("myrepo/bar:v1", obj=bar_obj)

Pull the object back out and load it

import jsonpickle 

str_dict = blobz.pull_str("myrepo/bar:v1")
bar_obj = jsonpickle.decode(str_dict["BarObj.json"])

Push an object in pickle format with a designated filename

blobz.push(
    "myrepo/bar:v2",
    obj_map={"my_obj.pkl": bar_obj},
    obj_encoder=blobz.ObjEncoderType.PICKLE,
)

Pull it back out as bytes and load it with pickle

import pickle

byte_dict = blobz.pull_bytes("myrepo/bar:v2")
bar_obj = pickle.loads(byte_dict["my_obj.pkl"])

More complete examples can be found in the tests

FAQ

What about OCI artifacts?

OCI artifacts are amazing and will be the future, but many registries don't support them yet, this tool will work with any docker registry.

About

A lazy Python library for OCI artifact storage

License:Apache License 2.0


Languages

Language:Python 98.8%Language:Makefile 1.2%