Skip to main content

harbor-oci-client

Harbor REST API operations and ORAS push/pull convenience wrappers for SuperNova artifacts.

Install

pip install harbor-oci-client

Or install directly from the repository:

pip install git+https://github.com/DamitDev/harbor-oci-client.git

Requires Python >= 3.12.

Usage

HarborClient (async)

Wraps Harbor's OCI Distribution API and Harbor v2.0 REST API with token caching and automatic retries.

from harbor_oci_client import HarborClient

client = HarborClient(
    base_url="https://harbor.example.com",
    username="robot_myproject+ci",
    password="...",
)

# Verify an artifact exists (OCI Distribution HEAD)
info = await client.verify_artifact("harbor.example.com/myproject/my-model:v3")
# info.digest -> "sha256:abc123..."
# info.content_length -> 640

# Get rich metadata (Harbor v2.0 API)
detail = await client.get_artifact_info("harbor.example.com/myproject/my-model:v3")
# detail.digest, detail.size, detail.media_type, detail.push_time, detail.tags

# Delete an artifact (Harbor v2.0 API)
await client.delete_artifact("harbor.example.com/myproject/my-model:v3")

await client.close()

OrasHelper (sync)

Thin wrapper around oras-py for push/pull. Async consumers should use asyncio.to_thread().

from harbor_oci_client import OrasHelper

oras = OrasHelper(
    hostname="harbor.example.com",
    username="robot_myproject+ci",
    password="...",
)

# Pull
files = oras.pull("harbor.example.com/myproject/my-model:v3", outdir="/tmp/model")

# Push (one layer per file)
result = oras.push(
    "harbor.example.com/myproject/my-model:v4",
    files=["config.json", "model.safetensors"],
    workdir="/workspace/output",
)

# Push with custom media types
result = oras.push_custom(
    "harbor.example.com/myproject/my-model:v4",
    config_path="/workspace/config.json",
    content_path="/workspace/model-dir",
    category="model",  # or "dataset"
)

Ref Parsing

from harbor_oci_client import parse_ref

ref = parse_ref("harbor.example.com/myproject/my-model:v3")
# ref.host, ref.repository, ref.reference, ref.project, ref.repo_name

Media Types

from harbor_oci_client import media_types

media_types.MODEL_CONFIG     # "application/vnd.supernova.model.config.v1+json"
media_types.MODEL_WEIGHTS    # "application/vnd.supernova.model.weights.v1+tar+gzip"
media_types.DATASET_CONFIG   # "application/vnd.supernova.dataset.config.v1+json"
media_types.DATASET_CONTENT  # "application/vnd.supernova.dataset.content.v1+tar+gzip"
media_types.OCI_MANIFEST     # "application/vnd.oci.image.manifest.v1+json"

Exceptions

All inherit from HarborError and carry detail: str and status_code: int | None.

Exception Meaning
HarborConnectionError Registry unreachable, DNS failure, timeout
HarborAuthError 401/403 from token endpoint or API
ArtifactNotFoundError 404 — also carries .harbor_ref
HarborAPIError Any other unexpected HTTP status

Testing

# Unit tests (no Harbor needed)
pip install -e ".[dev]"
pytest

# Integration tests (live Harbor)
HARBOR_URL=https://harbor.example.com \
HARBOR_USERNAME=robot_myproject+ci \
HARBOR_PASSWORD=... \
pytest tests/test_integration.py --integration -v

License

Apache 2.0

Metadata

Release files for harbor-oci-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)

Source distribution for harbor-oci-client 0.1.0
File Size Uploaded
harbor_oci_client-0.1.0.tar.gz 17.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for harbor-oci-client 0.1.0
File Interpreter ABI Platform
harbor_oci_client-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 31.7 kB

Release files / harbor_oci_client-0.1.0.tar.gz

Download URL harbor_oci_client-0.1.0.tar.gz
Size 17.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d47b008bebe60de2ad23b850f49ae72f27627be7f4f8a97af704367d0259065a
BLAKE2b-256 checksum
How to use checksums
451c102adcaa6d1e6644e680bb257f37ae0063fb180f367032233ab80b47a55b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 31, 2026.

Transparency log

Release files / harbor_oci_client-0.1.0-py3-none-any.whl

Download URL harbor_oci_client-0.1.0-py3-none-any.whl
Size 14.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7f517a4e3cf62b8a0ecc9263885068813d5a41e0999a0cdd15f318dd63de63a4
BLAKE2b-256 checksum
How to use checksums
ae885d88a496284d79b53da0528b030254fc2c2e7a3023fd5c1a21626ed00cd8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 31, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page