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
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d47b008bebe60de2ad23b850f49ae72f27627be7f4f8a97af704367d0259065a
|
|
| MD5 |
6e9eef2972f3c01839f2f39e6d9de278
|
|
| BLAKE2b-256 |
451c102adcaa6d1e6644e680bb257f37ae0063fb180f367032233ab80b47a55b
|
Provenance
The following attestation bundles were made for harbor_oci_client-0.1.0.tar.gz:
Publisher:
publish.yml on DamitDev/harbor-oci-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
harbor_oci_client-0.1.0.tar.gz -
Subject digest:
d47b008bebe60de2ad23b850f49ae72f27627be7f4f8a97af704367d0259065a - Sigstore transparency entry: 1202850799
- Sigstore integration time:
-
Permalink:
DamitDev/harbor-oci-client@5acc8112f659714bb3a77981fff55c95514eba22 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/DamitDev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5acc8112f659714bb3a77981fff55c95514eba22 -
Trigger Event:
release
-
Statement type:
File details
Details for the file harbor_oci_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: harbor_oci_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f517a4e3cf62b8a0ecc9263885068813d5a41e0999a0cdd15f318dd63de63a4
|
|
| MD5 |
2263f94f2ce70bc054dcc929536434af
|
|
| BLAKE2b-256 |
ae885d88a496284d79b53da0528b030254fc2c2e7a3023fd5c1a21626ed00cd8
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
harbor_oci_client-0.1.0-py3-none-any.whl -
Subject digest:
7f517a4e3cf62b8a0ecc9263885068813d5a41e0999a0cdd15f318dd63de63a4 - Sigstore transparency entry: 1202850802
- Sigstore integration time:
-
Permalink:
DamitDev/harbor-oci-client@5acc8112f659714bb3a77981fff55c95514eba22 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/DamitDev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5acc8112f659714bb3a77981fff55c95514eba22 -
Trigger Event:
release
-
Statement type: