Metadata-Version: 2.1
Name: hopper-dataset-release-kit
Version: 0.3.0
Summary: Zero-dependency Python client and CLI for streaming download, SHA-256 and Ed25519 verification, signed release following, contract-aware diffing, private-mirror authentication, and typed warehouse ingestion of pinned Hopper dataset releases.
Keywords: hopper,dataset,parquet,duckdb,snowflake,databricks,bigquery,athena,sha256,ed25519,data-contract
Author: Hopper Labs AI
License: Apache-2.0
Project-URL: Homepage, https://jobs.hopperlabs.ai/enterprise
Project-URL: Repository, https://github.com/hopperlabs-ai-leadops/hopper-leadops-service-storage-transport
Project-URL: Issues, https://github.com/hopperlabs-ai-leadops/hopper-leadops-service-storage-transport/issues
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Database
Classifier: Topic :: Security :: Cryptography
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# Hopper Dataset Release Kit for Python (`0.3.0`)

Zero-dependency Python 3.9+ library and CLI (`hopper-dataset-py`) for pinned Hopper dataset releases: verified
download (SHA-256), signed release following (Ed25519, verified in pure Python), data contracts with per-table
rights, release diffs, and typed loads into DuckDB, Polars, PyArrow, pandas, Snowflake, BigQuery, Databricks or
S3/Athena. Same features and the same test vectors as the Node kit (`@hopperlabs/dataset-release-kit`).

Licensed under **Apache-2.0** (software only; each dataset carries its own source or contracted rights, stated per
table in its `contract.json`).

## Install from a verified wheel

The publisher states the wheel's SHA-256 next to it (`https://jobs.hopperlabs.ai/data/jobs/operations.json`,
`datasetReleaseKit`). Check it, then install the local file:

```sh
curl -fLO https://jobs.hopperlabs.ai/data/kits/hopper_dataset_release_kit-0.3.0-py3-none-any.whl
shasum -a 256 hopper_dataset_release_kit-0.3.0-py3-none-any.whl   # must equal the published sha256
pip install --no-deps ./hopper_dataset_release_kit-0.3.0-py3-none-any.whl
```

## CLI

```sh
hopper-dataset-py inspect career.json
hopper-dataset-py restore career.json ./editions
hopper-dataset-py verify career.json ./editions/<revision>
hopper-dataset-py warehouse career.json ./editions/<revision> --target duckdb --sql-only | duckdb
hopper-dataset-py diff previous-edition.json next-edition.json
hopper-dataset-py latest career.json --config-out career.json
```

- `latest` reads every place in the config's `head` (R2 `latest.json` `revision`, the Hub API `sha`) and walks each
  answer's signed statements back to the pinned revision. Every hop must verify: receipt digest, the signature by a
  known `publisherKeys` entry valid at `builtAt`, `builtAt` at most 300 seconds ahead of your clock (`at=` sets the
  clock), `dataSha256`, `sourcesSha256` against `sources.lock.json` when the release carries one, sequence continuity,
  `builtAt` never earlier than the release before, and honest contract labels. It follows the furthest head whose chain verifies and stops before the first `breaking` release unless
  `--allow-breaking`. `places` reports each head against the returned pin (`ahead`, `equal`, `behind`, `unreachable`,
  `refused`); lagging mirrors (a release of the pin's own chain below it) are listed in `mirrorsBehind`, and a refused
  place (fork, rewrite, unknown or revoked key, a release dated in the future) is never followed. It refuses when no place answers, none names a verified release, or two places name signed
  releases on different branches. `--max-hops N` bounds it, `--publisher-keys FILE` supplies keys from a
  `hopper.dataset-publisher-keys.v1` file.
- `inspect` shows `contractVersion` and per-table keys, rows, typed columns and rights when the release carries
  `contract.json`, and `sourcesLock` (digest and inputs count) when it carries `sources.lock.json`. `diff` refuses two
  different datasets and reports the contract change between two releases.
- `restore`, `verify` and `warehouse` take `--tables a,b` and `--exclude-commercial excluded|restricted`: only those
  tables' members plus the card, the receipt and the format members the release carries (`contract.json`,
  `changes.json`, `release.json`, `release.sig`, `sources.lock.json`). `excluded` skips tables not offered for commercial ingestion; `restricted` also
  skips tables with conditions. Restoring again into the same output adds the members a new selection (or the whole
  release) lacks, each verified and moved in whole.
- With a contract, `warehouse` emits explicit typed columns for every target (`s3` writes Athena external tables),
  `NOT NULL` only where the contract says a column is non-null;
  unknown Arrow types load as text and are reported. Releases published before contracts keep working exactly as
  before.

## Private feeds

Private feeds are provisioned per engagement: Hopper supplies the mirror base URL and an access token to the
customer. Name the environment variable in the config; the token is sent only to that mirror's origin:

```json
{ "provider": "private-mirror", "baseUrl": "<base URL supplied for your engagement>/<revision>/",
  "auth": { "type": "bearer", "env": "HOPPER_DATASET_TOKEN" } }
```

A `head` entry accepts the same `auth` and reads its own variable. The `auth_token` argument replaces the token only
for entries on the first mirror's origin; a head or mirror elsewhere always uses its own variable.

## Python API

```python
import json
from pathlib import Path
from hopper_dataset_kit import latest, restore_dataset, verify_dataset_cache, generate_warehouse_sql

pinned = json.loads(Path("career.json").read_text())
followed = latest(pinned)
config = followed["config"]
Path("career.json").write_text(json.dumps(config, indent=2))
restored = restore_dataset(config, "./editions", exclude_commercial="excluded")
proof = verify_dataset_cache(config, restored["directory"], exclude_commercial="excluded")
ddl = generate_warehouse_sql(config, restored["directory"], target="snowflake", schema="hopper_data", exclude_commercial="excluded")
```

`verify_release_statement`, `compare_contracts`, `validate_contract`, `compute_data_sha256` and `verify_ed25519` are
exported for offline checks. Requests carry `User-Agent: hopper-dataset-release-kit/<version> (python)`.
