|
| 1 | +--- |
| 2 | +name: raincloud-load |
| 3 | +description: Load a Raincloud dataset via the lightweight Python loader API (`raincloud.load(slug)`). Use when the user wants to read a prepared parquet/vortex artifact, inspect a slug's metadata, or pull a dataset for downstream analysis from cache → mirror → local build. |
| 4 | +argument-hint: <slug> [--format vortex|parquet] [--materialize to_arrow|scan|to_pandas] |
| 5 | +disable-model-invocation: true |
| 6 | +allowed-tools: Bash(python -c *), Bash(python -m raincloud *), Bash(python examples/use_loader.py *) |
| 7 | +--- |
| 8 | + |
| 9 | +The Raincloud loader is a separate, lightweight Python package (`raincloud`) for reading **already-prepared** artifacts. Resolution order is `local cache → mirror → local build`; nothing is fetched until you call an accessor. |
| 10 | + |
| 11 | +## Most common shape |
| 12 | + |
| 13 | +```bash |
| 14 | +python -c " |
| 15 | +import raincloud |
| 16 | +ds = raincloud.load('$ARGUMENTS') # default format='vortex' with parquet fallback |
| 17 | +print('rows :', ds.num_rows) |
| 18 | +print('cols :', ds.column_names[:5]) |
| 19 | +print('source :', ds.info.get('source_url')) |
| 20 | +print('path :', ds.path()) # triggers cache/mirror/build resolution |
| 21 | +" |
| 22 | +``` |
| 23 | + |
| 24 | +## Materialization |
| 25 | + |
| 26 | +| Accessor | Returns | Notes | |
| 27 | +|---|---|---| |
| 28 | +| `ds.path()` | `pathlib.Path` to the on-disk artifact | First call resolves; subsequent calls are cache hits. | |
| 29 | +| `ds.to_arrow()` | `pyarrow.Table` | Materializes the whole table; expensive on multi-GB slugs. | |
| 30 | +| `ds.to_vortex()` | `vortex.VortexFile` (lazy) | Vortex-native handle. | |
| 31 | +| `ds.scan()` | `duckdb.DuckDBPyRelation` | Requires `raincloud[duckdb]`. Always reads the parquet sibling — if the slug was loaded as vortex, you'll see a `[raincloud]` stderr note before the parquet is resolved. | |
| 32 | +| `ds.to_pandas()` | `pandas.DataFrame` | Requires `raincloud[pandas]`. | |
| 33 | +| `ds.schema` | `pyarrow.Schema` | Footer-only read for parquet; opens the file for vortex. | |
| 34 | + |
| 35 | +## Config via env vars |
| 36 | + |
| 37 | +| Env var | Effect | |
| 38 | +|---|---| |
| 39 | +| `RAINCLOUD_CACHE` | Local artifact cache dir (default `~/.cache/raincloud`). | |
| 40 | +| `RAINCLOUD_MIRROR` | Mirror URL (`s3://…`, `https://…`, `file://…`). Tried before the local build. | |
| 41 | +| `RAINCLOUD_OFFLINE=1` | Block mirror + build; raise `OfflineMiss` on cache miss. | |
| 42 | +| `RAINCLOUD_SNAPSHOT` | Override `docs/v1/snapshot.json` (catalog). | |
| 43 | +| `RAINCLOUD_MANIFEST` | Override `sources.json`. | |
| 44 | + |
| 45 | +## Drift semantics |
| 46 | + |
| 47 | +When a slug has a `sha256` pinned in the snapshot and the mirror or local build produces bytes that disagree, the loader prints a `[raincloud] WARN: <slug> from <mirror|build> sha256 drifted ...` to stderr and adopts the new bytes anyway. Upstream content drifts; that's not a panic case. Catch + escalate via `raincloud.ChecksumMismatch` only if you want a hard gate (e.g. `_cache.adopt(..., strict=True)` — used by `python -m scripts.pipeline.publish`). |
| 48 | + |
| 49 | +## Errors (all subclass `raincloud.RaincloudError`) |
| 50 | + |
| 51 | +`UnknownSlug`, `FormatUnavailable`, `ArtifactNotFound`, `OfflineMiss`, `BuildToolingMissing`, `MissingDependency`, `ChecksumMismatch`. |
| 52 | + |
| 53 | +## Worked example |
| 54 | + |
| 55 | +```bash |
| 56 | +python examples/use_loader.py --slug $ARGUMENTS # metadata only |
| 57 | +python examples/use_loader.py --slug $ARGUMENTS --materialize # full path |
| 58 | +``` |
| 59 | + |
| 60 | +[`examples/use_loader.py`](../../../examples/use_loader.py) walks the full API end-to-end against the packaged catalog with no network. |
| 61 | + |
| 62 | +## Install tiers |
| 63 | + |
| 64 | +```bash |
| 65 | +pip install raincloud # lightweight loader |
| 66 | +pip install 'raincloud[duckdb]' # adds .scan() |
| 67 | +pip install 'raincloud[pandas]' # adds .to_pandas() |
| 68 | +pip install 'raincloud[s3]' # s3:// mirror transport |
| 69 | +pip install 'raincloud[http]' # https:// mirror transport |
| 70 | +pip install 'raincloud[build]' # adds local-build fallback (heavyweight) |
| 71 | +``` |
| 72 | + |
| 73 | +Context: [AGENTS.md "The loader package"](../../../AGENTS.md), [`examples/use_loader.py`](../../../examples/use_loader.py). |
0 commit comments