SDK API Reference¶
Auto-generated from source code docstrings.
rahcp-client¶
HCPClient¶
HCPClient(endpoint='http://localhost:8000/api/v1', username='', password='', tenant=None, *, timeout=30.0, max_retries=4, retry_base_delay=1.0, multipart_threshold=100 * 1024 * 1024, multipart_chunk=64 * 1024 * 1024, multipart_concurrency=6, verify_ssl=True)
¶
Async HTTP client for the HCP Unified API.
Usage::
async with HCPClient.from_env() as hcp:
buckets = await hcp.s3.list_objects("bucket", "prefix/")
ns = await hcp.mapi.list_namespaces("tenant")
Initialize the HCP client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
Base URL for the HCP Unified API. |
'http://localhost:8000/api/v1'
|
username
|
str
|
Username for authentication. |
''
|
password
|
str
|
Password for authentication. |
''
|
tenant
|
str | None
|
HCP tenant name (routes requests to the correct tenant). |
None
|
timeout
|
float
|
HTTP request timeout in seconds. |
30.0
|
max_retries
|
int
|
Maximum number of retry attempts for transient errors. |
4
|
retry_base_delay
|
float
|
Base delay between retries in seconds (doubles each attempt). |
1.0
|
multipart_threshold
|
int
|
File size in bytes above which multipart upload is used. |
100 * 1024 * 1024
|
multipart_chunk
|
int
|
Part size in bytes for multipart uploads. |
64 * 1024 * 1024
|
verify_ssl
|
bool
|
Whether to verify TLS certificates. |
True
|
Source code in packages/rahcp-client/src/rahcp_client/client.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
token
property
¶
The current bearer token (set after login).
s3
property
¶
S3 data-plane operations.
mapi
property
¶
MAPI management-plane operations.
transfer_settings
property
¶
Settings needed by the bulk transfer engine.
from_env()
classmethod
¶
Create a client configured from HCP_* environment variables.
Source code in packages/rahcp-client/src/rahcp_client/client.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
request(method, path, *, params=None, json=None, data=None, content=None, headers=None)
async
¶
Send an HTTP request with retry, tracing, and automatic 401 refresh.
Source code in packages/rahcp-client/src/rahcp_client/client.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | |
S3Ops¶
S3Ops(client)
¶
S3 data-plane operations — presigned-first, multipart for large files.
All data transfer prefers presigned URLs. Files above
client.multipart_threshold automatically use multipart upload.
Path mapping to the backend API (all under /api/v1): GET /buckets — list buckets GET /buckets/{b}/objects — list objects POST /presign — single presigned URL POST /buckets/{b}/objects/presign — bulk presigned URLs POST /buckets/{b}/multipart/{key} — initiate multipart POST /buckets/{b}/multipart/{key}/presign — presign parts POST /buckets/{b}/multipart/{key}/complete — complete multipart DELETE /buckets/{b}/objects/{key} — delete object POST /buckets/{b}/objects/delete — bulk delete POST /buckets/{b}/objects/{key}/copy — copy object HEAD /buckets/{b}/objects/{key} — head object
Source code in packages/rahcp-client/src/rahcp_client/s3.py
51 52 | |
presign_get(bucket, key, *, expires=3600)
async
¶
Get a presigned download URL.
Source code in packages/rahcp-client/src/rahcp_client/s3.py
62 63 64 65 66 67 68 69 70 71 72 73 74 | |
presign_put(bucket, key, *, expires=3600)
async
¶
Get a presigned upload URL.
Source code in packages/rahcp-client/src/rahcp_client/s3.py
76 77 78 79 80 81 82 83 84 85 86 87 88 | |
presign_bulk(bucket, keys, *, method='get_object', expires=3600)
async
¶
Presign multiple keys in one API call. Returns {key: url} mapping.
Source code in packages/rahcp-client/src/rahcp_client/s3.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
upload(bucket, key, data)
async
¶
Upload data — auto-selects presigned PUT or multipart based on size.
Returns the ETag of the uploaded object.
Source code in packages/rahcp-client/src/rahcp_client/s3.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
download(bucket, key, dest)
async
¶
Download an object via presigned GET. Returns byte count.
Source code in packages/rahcp-client/src/rahcp_client/s3.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
download_bytes(bucket, key)
async
¶
Download an object as bytes via presigned GET.
Source code in packages/rahcp-client/src/rahcp_client/s3.py
159 160 161 162 163 164 165 | |
upload_multipart(bucket, key, path, *, concurrency=None)
async
¶
Presigned multipart upload for large files.
- Initiate multipart → upload_id
- Presign each part
- Upload parts in parallel (bounded semaphore)
- Complete multipart (or abort on failure)
Source code in packages/rahcp-client/src/rahcp_client/s3.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | |
list_buckets()
async
¶
List all S3 buckets.
Source code in packages/rahcp-client/src/rahcp_client/s3.py
286 287 288 289 | |
list_objects(bucket, prefix='', *, max_keys=1000, continuation_token=None, delimiter=None)
async
¶
List objects in a bucket with optional prefix and pagination.
Source code in packages/rahcp-client/src/rahcp_client/s3.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | |
delete(bucket, key)
async
¶
Delete a single object.
Source code in packages/rahcp-client/src/rahcp_client/s3.py
330 331 332 | |
delete_bulk(bucket, keys)
async
¶
Delete multiple objects.
Source code in packages/rahcp-client/src/rahcp_client/s3.py
334 335 336 337 338 339 340 341 | |
copy(bucket, key, source_bucket, source_key)
async
¶
Copy an object.
Source code in packages/rahcp-client/src/rahcp_client/s3.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 | |
head(bucket, key)
async
¶
Get object metadata (content-length, content-type, etag, last-modified).
Source code in packages/rahcp-client/src/rahcp_client/s3.py
360 361 362 363 | |
commit_staging(bucket, staging_prefix, dest_prefix)
async
¶
Move objects from staging prefix to destination. Returns count.
Source code in packages/rahcp-client/src/rahcp_client/s3.py
367 368 369 370 371 372 373 374 375 376 377 378 | |
cleanup_staging(bucket, staging_prefix)
async
¶
Delete all objects under a staging prefix. Paginates. Returns count.
Source code in packages/rahcp-client/src/rahcp_client/s3.py
380 381 382 383 384 385 386 387 388 389 390 391 392 393 | |
MapiOps¶
MapiOps(client)
¶
MAPI management-plane — tenant admin and namespace operations only.
This is intentionally thin: user/group CRUD, statistics, chargeback, and system-level admin are handled by the backend directly.
HTTP method mapping (matches HCP MAPI conventions): GET — read PUT — create POST — update/modify DELETE — delete
Source code in packages/rahcp-client/src/rahcp_client/mapi.py
27 28 | |
list_namespaces(tenant, *, verbose=False)
async
¶
List all namespaces for a tenant.
Source code in packages/rahcp-client/src/rahcp_client/mapi.py
30 31 32 33 34 35 36 37 38 39 40 | |
get_namespace(tenant, ns, *, verbose=False)
async
¶
Get namespace details.
Source code in packages/rahcp-client/src/rahcp_client/mapi.py
42 43 44 45 46 47 48 49 50 51 52 | |
create_namespace(tenant, ns_data)
async
¶
Create a namespace. Uses PUT (MAPI convention).
Source code in packages/rahcp-client/src/rahcp_client/mapi.py
54 55 56 57 58 59 60 61 | |
update_namespace(tenant, ns, data)
async
¶
Update namespace settings. Uses POST (MAPI convention).
Source code in packages/rahcp-client/src/rahcp_client/mapi.py
63 64 65 66 67 68 69 | |
delete_namespace(tenant, ns)
async
¶
Delete a namespace.
Source code in packages/rahcp-client/src/rahcp_client/mapi.py
71 72 73 | |
export_namespace(tenant, ns)
async
¶
Export a namespace as a reusable template.
Source code in packages/rahcp-client/src/rahcp_client/mapi.py
75 76 77 78 79 80 | |
export_namespaces(tenant, names)
async
¶
Export multiple namespaces as templates.
Source code in packages/rahcp-client/src/rahcp_client/mapi.py
82 83 84 85 86 87 88 89 | |
Configuration¶
HCPSettings
¶
Bases: BaseSettings
Configuration for the HCP client.
All values can be set via HCP_-prefixed environment variables,
e.g. HCP_ENDPOINT, HCP_USERNAME, HCP_TENANT.
Errors¶
errors
¶
HCPError hierarchy — maps HTTP status codes to typed exceptions.
HCPError(message, *, status_code=None)
¶
Bases: Exception
Base error for all rahcp operations.
Source code in packages/rahcp-client/src/rahcp_client/errors.py
9 10 11 12 | |
AuthenticationError(message, *, status_code=None)
¶
Bases: HCPError
401 — bad credentials or expired token.
Source code in packages/rahcp-client/src/rahcp_client/errors.py
9 10 11 12 | |
NotFoundError(message, *, status_code=None)
¶
Bases: HCPError
404 — tenant, namespace, or object not found.
Source code in packages/rahcp-client/src/rahcp_client/errors.py
9 10 11 12 | |
ConflictError(message, *, status_code=None)
¶
Bases: HCPError
409 — resource already exists.
Source code in packages/rahcp-client/src/rahcp_client/errors.py
9 10 11 12 | |
RetryableError(message, *, status_code=None)
¶
Bases: HCPError
408, 429, 500, 503, 504 — transient failure after all retries exhausted.
Source code in packages/rahcp-client/src/rahcp_client/errors.py
9 10 11 12 | |
UpstreamError(message, *, status_code=None)
¶
Bases: HCPError
502 — backend's upstream service is unreachable. Not retried.
Source code in packages/rahcp-client/src/rahcp_client/errors.py
9 10 11 12 | |
error_for_status(status_code, message)
¶
Map an HTTP status code to the appropriate HCPError subclass.
Source code in packages/rahcp-client/src/rahcp_client/errors.py
40 41 42 43 | |
Tracing¶
tracing
¶
Optional OpenTelemetry tracing — no-op when OTEL is not installed.
Automatically initializes the OTEL SDK when OTEL_EXPORTER_OTLP_ENDPOINT
is set (or when configure_tracing() is called explicitly).
Supports both grpc and http/protobuf protocols via the standard
OTEL_EXPORTER_OTLP_PROTOCOL env var.
Usage::
from rahcp_client.tracing import tracer
with tracer.start_as_current_span("s3.upload") as span:
span.set_attribute("s3.bucket", bucket)
...
If opentelemetry-api is not installed, tracer is a no-op.
configure_tracing(service_name='rahcp-client', endpoint=None, protocol=None)
¶
Initialize the OTEL SDK with OTLP exporter.
Called automatically if OTEL_EXPORTER_OTLP_ENDPOINT env var is set.
Safe to call multiple times — only initializes once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
service_name
|
str
|
Service name in traces (default: rahcp-client). |
'rahcp-client'
|
endpoint
|
str | None
|
OTLP endpoint. Defaults to |
None
|
protocol
|
str | None
|
|
None
|
Source code in packages/rahcp-client/src/rahcp_client/tracing.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
rahcp-cli¶
S3 Commands¶
s3
¶
S3 CLI subcommands — thin wrappers over rahcp_client.
ls(ctx, bucket=typer.Argument(None), prefix=typer.Option('', '--prefix', '-p', help='Filter by key prefix'), max_keys=typer.Option(100, '--max-keys', '-n', help='Max results per page'), page=typer.Option(None, '--page', help='Continuation token for next page'), delimiter=typer.Option(None, '--delimiter', '-d', help='Group by delimiter (e.g. /)'), filter_key=typer.Option(None, '--filter', '-f', help='Filter keys containing this string'))
¶
List buckets (no args) or objects in a bucket.
Source code in packages/rahcp-cli/src/rahcp_cli/s3.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
upload(ctx, bucket=typer.Argument(...), key=typer.Argument(...), file=typer.Argument(..., exists=True))
¶
Upload a local file (auto multipart if large).
Source code in packages/rahcp-cli/src/rahcp_cli/s3.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
download(ctx, bucket=typer.Argument(...), key=typer.Argument(...), output=typer.Option(None, '--output', '-o'))
¶
Download an object via presigned URL.
Source code in packages/rahcp-cli/src/rahcp_cli/s3.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
rm(ctx, bucket=typer.Argument(...), keys=typer.Argument(...))
¶
Delete one or more objects.
Source code in packages/rahcp-cli/src/rahcp_cli/s3.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
presign(ctx, bucket=typer.Argument(...), key=typer.Argument(...), expires=typer.Option(3600, '--expires'))
¶
Get a presigned download URL.
Source code in packages/rahcp-cli/src/rahcp_cli/s3.py
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
upload_all(ctx, bucket=typer.Argument(...), source_dir=typer.Argument(..., help='Local directory to upload'), prefix=typer.Option('', '--prefix', '-p', help='Key prefix to prepend'), workers=typer.Option(0, '--workers', '-w', help='Concurrent workers (0 = use config)'), skip_existing=typer.Option(True, '--skip-existing/--overwrite', help='Skip files that already exist with matching size'), retry_errors=typer.Option(False, '--retry-errors', help='Only retry previously failed files'), include=typer.Option([], '--include', '-I', help="Only upload files matching these glob patterns (e.g. '*.jpg')"), exclude=typer.Option([], '--exclude', '-E', help="Skip files matching these glob patterns (e.g. '*.tmp')"), validate=typer.Option(False, '--validate', help='Validate each file before upload (auto-detects format by extension)'), verify=typer.Option(False, '--verify', help='Verify each upload by checking remote size after transfer'), tracker_db=typer.Option(None, '--tracker-db', help='Tracker DB path (overrides prefix and default)'), tracker_prefix=typer.Option(None, '--tracker-prefix', help="Prefix for tracker DB name (e.g. 'andraarkiv' → andraarkiv.upload-tracker.db)"), presign_batch_size=typer.Option(0, '--presign-batch-size', help='Presign URLs in batches of this size (0 = use config default)'))
¶
Upload a directory to S3 with tracked resume and parallel workers.
Source code in packages/rahcp-cli/src/rahcp_cli/s3.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | |
download_all(ctx, bucket=typer.Argument(...), prefix=typer.Option('', '--prefix', '-p', help='Only download keys under this prefix'), dest_dir=typer.Option('.', '--output', '-o', help='Local destination directory'), workers=typer.Option(0, '--workers', '-w', help='Concurrent workers (0 = use config)'), retry_errors=typer.Option(False, '--retry-errors', help='Only retry previously failed files'), include=typer.Option([], '--include', '-I', help="Only download keys matching these glob patterns (e.g. '*.jpg')"), exclude=typer.Option([], '--exclude', '-E', help="Skip keys matching these glob patterns (e.g. '*.tmp')"), validate=typer.Option(False, '--validate', help='Validate each file after download (auto-detects format by extension)'), verify=typer.Option(False, '--verify', help='Verify each download by checking file size after transfer'), tracker_db=typer.Option(None, '--tracker-db', help='Tracker DB path (overrides prefix and default)'), tracker_prefix=typer.Option(None, '--tracker-prefix', help="Prefix for tracker DB name (e.g. 'backup' → backup.download-tracker.db)"), presign_batch_size=typer.Option(0, '--presign-batch-size', help='Presign URLs in batches of this size (0 = use config default)'))
¶
Download a bucket to a local directory with tracked resume and parallel workers.
Source code in packages/rahcp-cli/src/rahcp_cli/s3.py
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 | |
verify(ctx, bucket=typer.Argument(...), source_dir=typer.Argument(..., help='Local directory to compare against'), prefix=typer.Option('', '--prefix', '-p', help='Key prefix (same as upload-all)'))
¶
Verify all local files exist in the bucket with matching sizes.
Source code in packages/rahcp-cli/src/rahcp_cli/s3.py
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 | |
Auth Commands¶
auth
¶
Auth commands — whoami.
whoami(ctx)
¶
Show current user info by decoding the JWT token.
Source code in packages/rahcp-cli/src/rahcp_cli/auth.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
Namespace Commands¶
namespace
¶
Namespace subcommands.
list_namespaces(ctx, tenant=typer.Argument(...), verbose=typer.Option(False, '--verbose', '-v'))
¶
List namespaces for a tenant.
Source code in packages/rahcp-cli/src/rahcp_cli/namespace.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
get_namespace(ctx, tenant=typer.Argument(...), ns=typer.Argument(...), verbose=typer.Option(False, '--verbose', '-v'))
¶
Get namespace details.
Source code in packages/rahcp-cli/src/rahcp_cli/namespace.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
create_namespace(ctx, tenant=typer.Argument(...), name=typer.Option(..., '--name'), quota=typer.Option(None, '--quota'))
¶
Create a namespace.
Source code in packages/rahcp-cli/src/rahcp_cli/namespace.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
delete_namespace(ctx, tenant=typer.Argument(...), ns=typer.Argument(...))
¶
Delete a namespace.
Source code in packages/rahcp-cli/src/rahcp_cli/namespace.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
import_namespace(ctx, tenant=typer.Argument(...), file=typer.Argument(..., exists=True, help='Exported template JSON file'))
¶
Create namespace(s) from an exported template file.
Examples:
rahcp ns export dev-ai my-ns > template.json rahcp ns import prod-tenant template.json
Source code in packages/rahcp-cli/src/rahcp_cli/namespace.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
export_namespace(ctx, tenant=typer.Argument(...), ns=typer.Argument(...), output=typer.Option(None, '--output', '-o'))
¶
Export namespace as a reusable template.
Source code in packages/rahcp-cli/src/rahcp_cli/namespace.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
Configuration¶
config
¶
YAML config file with named profiles.
Config file: ~/.rahcp/config.yaml (or --config / RAHCP_CONFIG)
Example::
default: dev
profiles:
dev:
endpoint: http://localhost:8000/api/v1
username: admin
password: secret
tenant: dev-ai
verify_ssl: false
prod:
endpoint: http://localhost:8000/api/v1
username: prod-user
password: secret
tenant: prod-archive
Profile
¶
Bases: BaseModel
A named connection profile.
CLIConfig
¶
Bases: BaseModel
Config with named profiles.
resolve(name=None)
¶
Resolve a profile by name, falling back to default.
Source code in packages/rahcp-cli/src/rahcp_cli/config.py
83 84 85 86 87 88 89 90 | |
load_config(path=None)
¶
Load config from a YAML file.
Resolution: explicit path > RAHCP_CONFIG env > ~/.rahcp/config.yaml
Source code in packages/rahcp-cli/src/rahcp_cli/config.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
rahcp-lance¶
LanceDataset¶
LanceDataset(client, bucket, prefix='')
¶
Manage Lance datasets stored on HCP S3.
Uses presigned S3 credentials from the HCP backend to connect lancedb to the remote storage.
Source code in packages/rahcp-lance/src/rahcp_lance/dataset.py
26 27 28 29 30 | |
list_tables()
async
¶
List all tables in the dataset.
Source code in packages/rahcp-lance/src/rahcp_lance/dataset.py
43 44 45 46 | |
open(table_name)
async
¶
Open an existing table.
Source code in packages/rahcp-lance/src/rahcp_lance/dataset.py
48 49 50 51 | |
create(table_name, schema=None, data=None)
async
¶
Create a new table with schema and optional initial data.
Source code in packages/rahcp-lance/src/rahcp_lance/dataset.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
drop(table_name)
async
¶
Drop a table.
Source code in packages/rahcp-lance/src/rahcp_lance/dataset.py
71 72 73 74 75 | |
table_info(table_name)
async
¶
Get metadata about a table.
Source code in packages/rahcp-lance/src/rahcp_lance/dataset.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
ingest(table_name, data)
async
¶
Add data to an existing table. Returns ingest summary.
Source code in packages/rahcp-lance/src/rahcp_lance/dataset.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
Query Helpers¶
query
¶
Read helpers — scan, take, vector search.
scan(table, params=None)
async
¶
Scan a table with optional projection, filter, and pagination.
Source code in packages/rahcp-lance/src/rahcp_lance/query.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |
take(table, indices)
async
¶
Take specific rows by index.
Source code in packages/rahcp-lance/src/rahcp_lance/query.py
30 31 32 33 34 35 36 37 38 39 | |
vector_search(table, params)
async
¶
Perform vector similarity search.
Source code in packages/rahcp-lance/src/rahcp_lance/query.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
Schemas¶
schemas
¶
Pydantic schemas for Lance dataset operations.
TableInfo
¶
Bases: BaseModel
Metadata about a Lance table.
FieldInfo
¶
Bases: BaseModel
A single field in a Lance table schema.
IngestResult
¶
Bases: BaseModel
Result of a batch ingest operation.
ScanParams
¶
Bases: BaseModel
Parameters for scanning a Lance table.
VectorSearchParams
¶
Bases: BaseModel
Parameters for vector similarity search.
SearchResult
¶
Bases: BaseModel
A single vector search result row.
rahcp-etl¶
Pipeline¶
pipeline
¶
Pipeline DAG — stage registration, retry policy, checkpoint resume.
Stage(name, handler, retries=3, backoff=2.0)
dataclass
¶
A single pipeline stage with retry configuration.
Pipeline(checkpoint_store=None)
¶
Composable ETL pipeline with retry policy per stage.
Register stages with the @pipeline.stage() decorator, then run
with pipeline.run(payload). Each stage receives the output of
the previous stage. Checkpoints are saved after each successful stage
so the pipeline can resume on failure.
Example::
pipeline = Pipeline()
@pipeline.stage("extract", retries=3)
async def extract(payload):
...
return {"records": [...]}
@pipeline.stage("transform")
async def transform(payload):
...
return {"transformed": [...]}
result = await pipeline.run({"source": "s3://..."})
Source code in packages/rahcp-etl/src/rahcp_etl/pipeline.py
52 53 54 | |
stage(name, *, retries=3, backoff=2.0)
¶
Decorator to register a pipeline stage.
Source code in packages/rahcp-etl/src/rahcp_etl/pipeline.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
run(payload, *, pipeline_id=None)
async
¶
Execute all stages in order with retry and checkpointing.
Source code in packages/rahcp-etl/src/rahcp_etl/pipeline.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
Consumer¶
consumer
¶
JetStream durable consumer for ETL work items.
ETLConsumer(nats_url, stream, subject, durable, *, max_deliver=5, ack_wait=30.0)
¶
Durable JetStream consumer with auto-reconnect.
Connects to NATS, binds a durable consumer on the given stream/subject, and dispatches messages to the handler. Acks on success, naks on failure.
Source code in packages/rahcp-etl/src/rahcp_etl/consumer.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
start(handler)
async
¶
Connect and start consuming messages.
handler receives the message payload as bytes and should
return a dict (success) or raise an exception (triggers nak/retry).
Source code in packages/rahcp-etl/src/rahcp_etl/consumer.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
stop()
async
¶
Stop consuming and disconnect.
Source code in packages/rahcp-etl/src/rahcp_etl/consumer.py
85 86 87 88 89 90 91 92 | |
Checkpointing¶
checkpointing
¶
KV-backed checkpoint storage for pipeline state.
CheckpointStore(kv)
¶
KV-backed progress checkpoints using NATS JetStream KV.
Each pipeline run gets a key: {pipeline_id} with value containing
the last completed stage and its output state. On failure, the pipeline
can resume from the last checkpoint instead of restarting.
Source code in packages/rahcp-etl/src/rahcp_etl/checkpointing.py
23 24 | |
create(nc, bucket='etl-checkpoints')
async
classmethod
¶
Create or bind to a KV bucket.
Source code in packages/rahcp-etl/src/rahcp_etl/checkpointing.py
26 27 28 29 30 31 32 33 34 35 | |
save(pipeline_id, stage, state)
async
¶
Save a checkpoint after a successful stage.
Source code in packages/rahcp-etl/src/rahcp_etl/checkpointing.py
37 38 39 40 41 42 43 44 45 46 | |
load(pipeline_id)
async
¶
Load the last checkpoint for a pipeline run.
Returns {"stage": str, "state": dict} or None if no
checkpoint exists.
Source code in packages/rahcp-etl/src/rahcp_etl/checkpointing.py
48 49 50 51 52 53 54 55 56 57 58 | |
clear(pipeline_id)
async
¶
Clear the checkpoint for a pipeline run.
Source code in packages/rahcp-etl/src/rahcp_etl/checkpointing.py
60 61 62 63 64 65 | |
Dead Letter Queue¶
dlq
¶
Dead-letter queue handler — route failed messages for inspection/replay.
DeadLetterHandler(js)
¶
Route permanently-failed messages to a DLQ stream for inspection/replay.
Messages in the DLQ include the original payload, the error message, and the original subject for targeted replay.
Source code in packages/rahcp-etl/src/rahcp_etl/dlq.py
24 25 | |
create(nc)
async
classmethod
¶
Create the DLQ handler, ensuring the DLQ stream exists.
Source code in packages/rahcp-etl/src/rahcp_etl/dlq.py
27 28 29 30 31 32 | |
send(subject, payload, error)
async
¶
Send a failed message to the DLQ.
Source code in packages/rahcp-etl/src/rahcp_etl/dlq.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
replay(*, filter_subject=None)
async
¶
Replay DLQ messages back to their original subjects.
Returns the number of messages replayed.
Source code in packages/rahcp-etl/src/rahcp_etl/dlq.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
purge(*, older_than=None)
async
¶
Purge DLQ messages. Returns count purged.
Source code in packages/rahcp-etl/src/rahcp_etl/dlq.py
84 85 86 87 88 89 90 | |
rahcp-validate¶
Image Validation¶
images
¶
Image integrity checks — TIFF and JPEG corruption detection.
ValidationError(path, reason)
¶
Bases: Exception
Raised when a file fails validation.
Source code in packages/rahcp-validate/src/rahcp_validate/images.py
14 15 16 17 | |
validate_tiff(path)
¶
Verify a TIFF file is not corrupt and meets basic requirements.
Checks magic bytes, IFD structure, and that Pillow can fully load it.
Raises ValidationError on failure.
Source code in packages/rahcp-validate/src/rahcp_validate/images.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
validate_jpg(path)
¶
Verify a JPEG file is not corrupt.
Checks SOI/EOI markers and that Pillow can fully load it.
Raises ValidationError on failure.
Source code in packages/rahcp-validate/src/rahcp_validate/images.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
validate_png(path)
¶
Verify a PNG file is not corrupt.
Checks PNG signature and that Pillow can fully load it.
Raises ValidationError on failure.
Source code in packages/rahcp-validate/src/rahcp_validate/images.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
validate_by_extension(path)
¶
Auto-detect file type by extension and validate.
Supported: .jpg, .jpeg, .tif, .tiff, .png.
Unknown extensions are skipped (no error).
Raises ValidationError if the file is corrupt.
Source code in packages/rahcp-validate/src/rahcp_validate/images.py
111 112 113 114 115 116 117 118 119 120 121 122 | |
Rules¶
rules
¶
Pluggable validation rules — size, dimensions, extensions.
Rule(name, check)
dataclass
¶
A named validation check.
max_file_size(limit_bytes)
¶
Reject files larger than limit_bytes.
Source code in packages/rahcp-validate/src/rahcp_validate/rules.py
20 21 22 23 24 25 26 27 28 29 30 31 | |
image_dimensions(*, min_w=1, min_h=1, max_w=65535, max_h=65535)
¶
Check image dimensions are within bounds.
Source code in packages/rahcp-validate/src/rahcp_validate/rules.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
allowed_extensions(*exts)
¶
Only allow files with the given extensions (case-insensitive).
Source code in packages/rahcp-validate/src/rahcp_validate/rules.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
validate(path, rules)
¶
Run all rules against a file, collecting all failures.
Does not stop on the first failure — returns all validation errors.
Source code in packages/rahcp-validate/src/rahcp_validate/rules.py
81 82 83 84 85 86 87 88 89 90 91 92 | |