HTTP client for the JuniperData dataset generation service
Project description
juniper-data-client
Python client library for the JuniperData REST API.
Overview
juniper-data-client provides a simple, robust client for interacting with the JuniperData dataset generation service. It is the official client library used by both JuniperCascor (neural network backend) and juniper-canopy (web dashboard).
Ecosystem Compatibility
This package is part of the Juniper ecosystem. Compatible with:
| juniper-data | juniper-cascor | juniper-canopy |
|---|---|---|
| 0.4.x | 0.3.x | 0.2.x |
Installation
pip install juniper-data-client
Or install from source:
cd juniper-data-client
pip install -e .
Quick Start
from juniper_data_client import JuniperDataClient
# Create client (default: localhost:8100)
client = JuniperDataClient("http://localhost:8100")
# Check service health
health = client.health_check()
print(f"Service status: {health['status']}")
# Create a spiral dataset
result = client.create_spiral_dataset(
n_spirals=2,
n_points_per_spiral=100,
noise=0.1,
seed=42,
)
dataset_id = result["dataset_id"]
print(f"Created dataset: {dataset_id}")
# Download as numpy arrays
arrays = client.download_artifact_npz(dataset_id)
X_train = arrays["X_train"] # (160, 2) float32
y_train = arrays["y_train"] # (160, 2) float32 one-hot
X_test = arrays["X_test"] # (40, 2) float32
y_test = arrays["y_test"] # (40, 2) float32 one-hot
print(f"Training samples: {len(X_train)}")
print(f"Test samples: {len(X_test)}")
Features
- Simple API: Easy-to-use methods for all JuniperData endpoints
- Automatic Retries: Built-in retry logic for transient failures (429, 5xx)
- Connection Pooling: Efficient HTTP connection reuse
- Type Hints: Full type annotations for IDE support
- Context Manager: Resource cleanup with
withstatement - Custom Exceptions: Granular error handling
Usage Examples
Context Manager
with JuniperDataClient("http://localhost:8100") as client:
result = client.create_spiral_dataset(seed=42)
arrays = client.download_artifact_npz(result["dataset_id"])
# Session automatically closed
Wait for Service
client = JuniperDataClient("http://localhost:8100")
# Wait up to 30 seconds for service to be ready
if client.wait_for_ready(timeout=30):
result = client.create_spiral_dataset(seed=42)
else:
print("Service not available")
Custom Parameters
# Using the general create_dataset method
result = client.create_dataset(
generator="spiral",
params={
"n_spirals": 3,
"n_points_per_spiral": 200,
"noise": 0.2,
"seed": 12345,
"algorithm": "legacy_cascor",
"radius": 10.0,
}
)
Error Handling
from juniper_data_client import (
JuniperDataClient,
JuniperDataConnectionError,
JuniperDataNotFoundError,
JuniperDataValidationError,
)
client = JuniperDataClient()
try:
result = client.create_dataset("spiral", {"n_spirals": -1})
except JuniperDataValidationError as e:
print(f"Invalid parameters: {e}")
except JuniperDataConnectionError as e:
print(f"Service unreachable: {e}")
PyTorch Integration
import torch
from juniper_data_client import JuniperDataClient
client = JuniperDataClient()
result = client.create_spiral_dataset(seed=42)
arrays = client.download_artifact_npz(result["dataset_id"])
# Convert to PyTorch tensors
X_train = torch.from_numpy(arrays["X_train"]) # torch.float32
y_train = torch.from_numpy(arrays["y_train"]) # torch.float32
API Reference
JuniperDataClient
| Method | Description |
|---|---|
health_check() |
Get service health status |
is_ready() |
Check if service is ready (boolean) |
wait_for_ready(timeout) |
Wait for service to become ready |
list_generators() |
List available generators |
get_generator_schema(name) |
Get parameter schema for generator |
create_dataset(generator, params) |
Create dataset with generator |
create_spiral_dataset(**kwargs) |
Convenience method for spiral datasets |
list_datasets(limit, offset) |
List dataset IDs |
get_dataset_metadata(id) |
Get dataset metadata |
download_artifact_npz(id) |
Download NPZ as dict of arrays |
download_artifact_bytes(id) |
Download raw NPZ bytes |
get_preview(id, n) |
Get JSON preview of samples |
delete_dataset(id) |
Delete a dataset |
list_versions(name) |
List version history for a dataset |
get_latest(name) |
Get latest version by name |
batch_delete(dataset_ids) |
Delete multiple datasets |
batch_create(datasets) |
Create multiple datasets |
batch_update_tags(dataset_ids, add_tags, remove_tags) |
Update tags on multiple datasets |
batch_export(dataset_ids) |
Export multiple datasets as ZIP |
close() |
Close the client session |
Exceptions
| Exception | Description |
|---|---|
JuniperDataClientError |
Base exception for all errors |
JuniperDataConnectionError |
Connection to service failed |
JuniperDataTimeoutError |
Request timed out |
JuniperDataNotFoundError |
Resource not found (404) |
JuniperDataValidationError |
Invalid parameters (400/422) |
NPZ Artifact Schema
Downloaded artifacts contain the following numpy arrays (all float32):
| Key | Shape | Description |
|---|---|---|
X_train |
(n_train, 2) |
Training features |
y_train |
(n_train, n_classes) |
Training labels (one-hot) |
X_test |
(n_test, 2) |
Test features |
y_test |
(n_test, n_classes) |
Test labels (one-hot) |
X_full |
(n_total, 2) |
Full dataset features |
y_full |
(n_total, n_classes) |
Full dataset labels (one-hot) |
Configuration
| Parameter | Default | Description |
|---|---|---|
base_url |
http://localhost:8100 |
JuniperData service URL |
timeout |
30 |
Request timeout in seconds |
retries |
3 |
Number of retry attempts |
backoff_factor |
0.5 |
Backoff multiplier between retries |
Requirements
- Python >=3.12
- numpy >=1.24.0
- requests >=2.28.0
- urllib3 >=2.0.0
License
MIT License - Copyright (c) 2024-2026 Paul Calnon
Juniper Ecosystem
This package is part of the Juniper Cascade Correlation Neural Network Research Platform.
| Package | Description | Install |
|---|---|---|
| juniper-data-client | Dataset service client (this package) | pip install juniper-data-client |
| juniper-cascor-client | Neural network service client | pip install juniper-cascor-client |
| juniper-cascor-worker | Distributed training worker | pip install juniper-cascor-worker |
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 juniper_data_client-0.4.0.tar.gz.
File metadata
- Download URL: juniper_data_client-0.4.0.tar.gz
- Upload date:
- Size: 34.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27b311d1b3add71ccf0a57d466ed2fa88d86c26cb6143dd38bd0918a5a39e12c
|
|
| MD5 |
62e166d577c2bf8133f19d549dc4fead
|
|
| BLAKE2b-256 |
1c7c1513f94a3f9e8c680573810df8ace693a5ccac12c6dc2eef7929eb93fc01
|
Provenance
The following attestation bundles were made for juniper_data_client-0.4.0.tar.gz:
Publisher:
publish.yml on pcalnon/juniper-data-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
juniper_data_client-0.4.0.tar.gz -
Subject digest:
27b311d1b3add71ccf0a57d466ed2fa88d86c26cb6143dd38bd0918a5a39e12c - Sigstore transparency entry: 1263949545
- Sigstore integration time:
-
Permalink:
pcalnon/juniper-data-client@554bf3db44125492bc89565ea10eeef260042a25 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/pcalnon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@554bf3db44125492bc89565ea10eeef260042a25 -
Trigger Event:
release
-
Statement type:
File details
Details for the file juniper_data_client-0.4.0-py3-none-any.whl.
File metadata
- Download URL: juniper_data_client-0.4.0-py3-none-any.whl
- Upload date:
- Size: 20.4 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 |
7ab70f892632cff5e50936082f53b46bd8ed990b5ed5224048f2c790a5d0278b
|
|
| MD5 |
1805dab5140ab13b4407b440fc899bf6
|
|
| BLAKE2b-256 |
b9b814249f5f056c5b484dea71eb7e5a438b2bdf172ef2d73d3f76b61e7d387a
|
Provenance
The following attestation bundles were made for juniper_data_client-0.4.0-py3-none-any.whl:
Publisher:
publish.yml on pcalnon/juniper-data-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
juniper_data_client-0.4.0-py3-none-any.whl -
Subject digest:
7ab70f892632cff5e50936082f53b46bd8ed990b5ed5224048f2c790a5d0278b - Sigstore transparency entry: 1263949604
- Sigstore integration time:
-
Permalink:
pcalnon/juniper-data-client@554bf3db44125492bc89565ea10eeef260042a25 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/pcalnon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@554bf3db44125492bc89565ea10eeef260042a25 -
Trigger Event:
release
-
Statement type: