Skip to main content

Harbor REST API and ORAS push/pull client for SuperNova artifacts

Project description

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

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

harbor_oci_client-0.1.0.tar.gz (17.7 kB view details)

Uploaded Source

Built Distribution

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

harbor_oci_client-0.1.0-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file harbor_oci_client-0.1.0.tar.gz.

File metadata

  • Download URL: harbor_oci_client-0.1.0.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for harbor_oci_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d47b008bebe60de2ad23b850f49ae72f27627be7f4f8a97af704367d0259065a
MD5 6e9eef2972f3c01839f2f39e6d9de278
BLAKE2b-256 451c102adcaa6d1e6644e680bb257f37ae0063fb180f367032233ab80b47a55b

See more details on using hashes here.

Provenance

The following attestation bundles were made for harbor_oci_client-0.1.0.tar.gz:

Publisher: publish.yml on DamitDev/harbor-oci-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file harbor_oci_client-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for harbor_oci_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7f517a4e3cf62b8a0ecc9263885068813d5a41e0999a0cdd15f318dd63de63a4
MD5 2263f94f2ce70bc054dcc929536434af
BLAKE2b-256 ae885d88a496284d79b53da0528b030254fc2c2e7a3023fd5c1a21626ed00cd8

See more details on using hashes here.

Provenance

The following attestation bundles were made for harbor_oci_client-0.1.0-py3-none-any.whl:

Publisher: publish.yml on DamitDev/harbor-oci-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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