juniper-data-client 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-2026 Paul Calnon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,250 @@
1
+ Metadata-Version: 2.4
2
+ Name: juniper-data-client
3
+ Version: 0.3.0
4
+ Summary: HTTP client for the JuniperData dataset generation service
5
+ Author: Paul Calnon
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/pcalnon/juniper-data-client
8
+ Project-URL: Repository, https://github.com/pcalnon/juniper-data-client
9
+ Project-URL: Documentation, https://github.com/pcalnon/juniper-data-client#readme
10
+ Project-URL: Issues, https://github.com/pcalnon/juniper-data-client/issues
11
+ Keywords: juniper,dataset,machine-learning,api-client
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.11
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: numpy>=1.24.0
28
+ Requires-Dist: requests>=2.28.0
29
+ Requires-Dist: urllib3>=2.0.0
30
+ Provides-Extra: test
31
+ Requires-Dist: pytest>=7.0.0; extra == "test"
32
+ Requires-Dist: pytest-cov>=4.0.0; extra == "test"
33
+ Requires-Dist: pytest-timeout>=2.2.0; extra == "test"
34
+ Requires-Dist: responses>=0.23.0; extra == "test"
35
+ Provides-Extra: dev
36
+ Requires-Dist: juniper-data-client[test]; extra == "dev"
37
+ Requires-Dist: black>=23.0.0; extra == "dev"
38
+ Requires-Dist: isort>=5.12.0; extra == "dev"
39
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
40
+ Requires-Dist: flake8>=7.0.0; extra == "dev"
41
+ Requires-Dist: types-requests>=2.28.0; extra == "dev"
42
+ Dynamic: license-file
43
+
44
+ # juniper-data-client
45
+
46
+ Python client library for the JuniperData REST API.
47
+
48
+ ## Overview
49
+
50
+ `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 JuniperCanopy (web dashboard).
51
+
52
+ ## Installation
53
+
54
+ ```bash
55
+ pip install juniper-data-client
56
+ ```
57
+
58
+ Or install from source:
59
+
60
+ ```bash
61
+ cd juniper-data-client
62
+ pip install -e .
63
+ ```
64
+
65
+ ## Quick Start
66
+
67
+ ```python
68
+ from juniper_data_client import JuniperDataClient
69
+
70
+ # Create client (default: localhost:8100)
71
+ client = JuniperDataClient("http://localhost:8100")
72
+
73
+ # Check service health
74
+ health = client.health_check()
75
+ print(f"Service status: {health['status']}")
76
+
77
+ # Create a spiral dataset
78
+ result = client.create_spiral_dataset(
79
+ n_spirals=2,
80
+ n_points_per_spiral=100,
81
+ noise=0.1,
82
+ seed=42,
83
+ )
84
+ dataset_id = result["dataset_id"]
85
+ print(f"Created dataset: {dataset_id}")
86
+
87
+ # Download as numpy arrays
88
+ arrays = client.download_artifact_npz(dataset_id)
89
+ X_train = arrays["X_train"] # (160, 2) float32
90
+ y_train = arrays["y_train"] # (160, 2) float32 one-hot
91
+ X_test = arrays["X_test"] # (40, 2) float32
92
+ y_test = arrays["y_test"] # (40, 2) float32 one-hot
93
+
94
+ print(f"Training samples: {len(X_train)}")
95
+ print(f"Test samples: {len(X_test)}")
96
+ ```
97
+
98
+ ## Features
99
+
100
+ - **Simple API**: Easy-to-use methods for all JuniperData endpoints
101
+ - **Automatic Retries**: Built-in retry logic for transient failures (429, 5xx)
102
+ - **Connection Pooling**: Efficient HTTP connection reuse
103
+ - **Type Hints**: Full type annotations for IDE support
104
+ - **Context Manager**: Resource cleanup with `with` statement
105
+ - **Custom Exceptions**: Granular error handling
106
+
107
+ ## Usage Examples
108
+
109
+ ### Context Manager
110
+
111
+ ```python
112
+ with JuniperDataClient("http://localhost:8100") as client:
113
+ result = client.create_spiral_dataset(seed=42)
114
+ arrays = client.download_artifact_npz(result["dataset_id"])
115
+ # Session automatically closed
116
+ ```
117
+
118
+ ### Wait for Service
119
+
120
+ ```python
121
+ client = JuniperDataClient("http://localhost:8100")
122
+
123
+ # Wait up to 30 seconds for service to be ready
124
+ if client.wait_for_ready(timeout=30):
125
+ result = client.create_spiral_dataset(seed=42)
126
+ else:
127
+ print("Service not available")
128
+ ```
129
+
130
+ ### Custom Parameters
131
+
132
+ ```python
133
+ # Using the general create_dataset method
134
+ result = client.create_dataset(
135
+ generator="spiral",
136
+ params={
137
+ "n_spirals": 3,
138
+ "n_points_per_spiral": 200,
139
+ "noise": 0.2,
140
+ "seed": 12345,
141
+ "algorithm": "legacy_cascor",
142
+ "radius": 10.0,
143
+ }
144
+ )
145
+ ```
146
+
147
+ ### Error Handling
148
+
149
+ ```python
150
+ from juniper_data_client import (
151
+ JuniperDataClient,
152
+ JuniperDataConnectionError,
153
+ JuniperDataNotFoundError,
154
+ JuniperDataValidationError,
155
+ )
156
+
157
+ client = JuniperDataClient()
158
+
159
+ try:
160
+ result = client.create_dataset("spiral", {"n_spirals": -1})
161
+ except JuniperDataValidationError as e:
162
+ print(f"Invalid parameters: {e}")
163
+ except JuniperDataConnectionError as e:
164
+ print(f"Service unreachable: {e}")
165
+ ```
166
+
167
+ ### PyTorch Integration
168
+
169
+ ```python
170
+ import torch
171
+ from juniper_data_client import JuniperDataClient
172
+
173
+ client = JuniperDataClient()
174
+ result = client.create_spiral_dataset(seed=42)
175
+ arrays = client.download_artifact_npz(result["dataset_id"])
176
+
177
+ # Convert to PyTorch tensors
178
+ X_train = torch.from_numpy(arrays["X_train"]) # torch.float32
179
+ y_train = torch.from_numpy(arrays["y_train"]) # torch.float32
180
+ ```
181
+
182
+ ## API Reference
183
+
184
+ ### JuniperDataClient
185
+
186
+ | Method | Description |
187
+ | ----------------------------------- | -------------------------------------- |
188
+ | `health_check()` | Get service health status |
189
+ | `is_ready()` | Check if service is ready (boolean) |
190
+ | `wait_for_ready(timeout)` | Wait for service to become ready |
191
+ | `list_generators()` | List available generators |
192
+ | `get_generator_schema(name)` | Get parameter schema for generator |
193
+ | `create_dataset(generator, params)` | Create dataset with generator |
194
+ | `create_spiral_dataset(**kwargs)` | Convenience method for spiral datasets |
195
+ | `list_datasets(limit, offset)` | List dataset IDs |
196
+ | `get_dataset_metadata(id)` | Get dataset metadata |
197
+ | `download_artifact_npz(id)` | Download NPZ as dict of arrays |
198
+ | `download_artifact_bytes(id)` | Download raw NPZ bytes |
199
+ | `get_preview(id, n)` | Get JSON preview of samples |
200
+ | `delete_dataset(id)` | Delete a dataset |
201
+ | `close()` | Close the client session |
202
+
203
+ ### Exceptions
204
+
205
+ | Exception | Description |
206
+ | ---------------------------- | ----------------------------- |
207
+ | `JuniperDataClientError` | Base exception for all errors |
208
+ | `JuniperDataConnectionError` | Connection to service failed |
209
+ | `JuniperDataTimeoutError` | Request timed out |
210
+ | `JuniperDataNotFoundError` | Resource not found (404) |
211
+ | `JuniperDataValidationError` | Invalid parameters (400/422) |
212
+
213
+ ## NPZ Artifact Schema
214
+
215
+ Downloaded artifacts contain the following numpy arrays (all `float32`):
216
+
217
+ | Key | Shape | Description |
218
+ | --------- | ---------------------- | ----------------------------- |
219
+ | `X_train` | `(n_train, 2)` | Training features |
220
+ | `y_train` | `(n_train, n_classes)` | Training labels (one-hot) |
221
+ | `X_test` | `(n_test, 2)` | Test features |
222
+ | `y_test` | `(n_test, n_classes)` | Test labels (one-hot) |
223
+ | `X_full` | `(n_total, 2)` | Full dataset features |
224
+ | `y_full` | `(n_total, n_classes)` | Full dataset labels (one-hot) |
225
+
226
+ ## Configuration
227
+
228
+ | Parameter | Default | Description |
229
+ | ---------------- | ----------------------- | ---------------------------------- |
230
+ | `base_url` | `http://localhost:8100` | JuniperData service URL |
231
+ | `timeout` | `30` | Request timeout in seconds |
232
+ | `retries` | `3` | Number of retry attempts |
233
+ | `backoff_factor` | `0.5` | Backoff multiplier between retries |
234
+
235
+ ## Requirements
236
+
237
+ - Python >=3.11
238
+ - numpy >=1.24.0
239
+ - requests >=2.28.0
240
+ - urllib3 >=2.0.0
241
+
242
+ ## License
243
+
244
+ MIT License - Copyright (c) 2024-2026 Paul Calnon
245
+
246
+ ## See Also
247
+
248
+ - [JuniperData](https://github.com/pcalnon/Juniper/tree/main/JuniperData)
249
+ - [JuniperCascor](https://github.com/pcalnon/Juniper/tree/main/JuniperCascor)
250
+ - [JuniperCanopy](https://github.com/pcalnon/Juniper/tree/main/JuniperCanopy)
@@ -0,0 +1,207 @@
1
+ # juniper-data-client
2
+
3
+ Python client library for the JuniperData REST API.
4
+
5
+ ## Overview
6
+
7
+ `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 JuniperCanopy (web dashboard).
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ pip install juniper-data-client
13
+ ```
14
+
15
+ Or install from source:
16
+
17
+ ```bash
18
+ cd juniper-data-client
19
+ pip install -e .
20
+ ```
21
+
22
+ ## Quick Start
23
+
24
+ ```python
25
+ from juniper_data_client import JuniperDataClient
26
+
27
+ # Create client (default: localhost:8100)
28
+ client = JuniperDataClient("http://localhost:8100")
29
+
30
+ # Check service health
31
+ health = client.health_check()
32
+ print(f"Service status: {health['status']}")
33
+
34
+ # Create a spiral dataset
35
+ result = client.create_spiral_dataset(
36
+ n_spirals=2,
37
+ n_points_per_spiral=100,
38
+ noise=0.1,
39
+ seed=42,
40
+ )
41
+ dataset_id = result["dataset_id"]
42
+ print(f"Created dataset: {dataset_id}")
43
+
44
+ # Download as numpy arrays
45
+ arrays = client.download_artifact_npz(dataset_id)
46
+ X_train = arrays["X_train"] # (160, 2) float32
47
+ y_train = arrays["y_train"] # (160, 2) float32 one-hot
48
+ X_test = arrays["X_test"] # (40, 2) float32
49
+ y_test = arrays["y_test"] # (40, 2) float32 one-hot
50
+
51
+ print(f"Training samples: {len(X_train)}")
52
+ print(f"Test samples: {len(X_test)}")
53
+ ```
54
+
55
+ ## Features
56
+
57
+ - **Simple API**: Easy-to-use methods for all JuniperData endpoints
58
+ - **Automatic Retries**: Built-in retry logic for transient failures (429, 5xx)
59
+ - **Connection Pooling**: Efficient HTTP connection reuse
60
+ - **Type Hints**: Full type annotations for IDE support
61
+ - **Context Manager**: Resource cleanup with `with` statement
62
+ - **Custom Exceptions**: Granular error handling
63
+
64
+ ## Usage Examples
65
+
66
+ ### Context Manager
67
+
68
+ ```python
69
+ with JuniperDataClient("http://localhost:8100") as client:
70
+ result = client.create_spiral_dataset(seed=42)
71
+ arrays = client.download_artifact_npz(result["dataset_id"])
72
+ # Session automatically closed
73
+ ```
74
+
75
+ ### Wait for Service
76
+
77
+ ```python
78
+ client = JuniperDataClient("http://localhost:8100")
79
+
80
+ # Wait up to 30 seconds for service to be ready
81
+ if client.wait_for_ready(timeout=30):
82
+ result = client.create_spiral_dataset(seed=42)
83
+ else:
84
+ print("Service not available")
85
+ ```
86
+
87
+ ### Custom Parameters
88
+
89
+ ```python
90
+ # Using the general create_dataset method
91
+ result = client.create_dataset(
92
+ generator="spiral",
93
+ params={
94
+ "n_spirals": 3,
95
+ "n_points_per_spiral": 200,
96
+ "noise": 0.2,
97
+ "seed": 12345,
98
+ "algorithm": "legacy_cascor",
99
+ "radius": 10.0,
100
+ }
101
+ )
102
+ ```
103
+
104
+ ### Error Handling
105
+
106
+ ```python
107
+ from juniper_data_client import (
108
+ JuniperDataClient,
109
+ JuniperDataConnectionError,
110
+ JuniperDataNotFoundError,
111
+ JuniperDataValidationError,
112
+ )
113
+
114
+ client = JuniperDataClient()
115
+
116
+ try:
117
+ result = client.create_dataset("spiral", {"n_spirals": -1})
118
+ except JuniperDataValidationError as e:
119
+ print(f"Invalid parameters: {e}")
120
+ except JuniperDataConnectionError as e:
121
+ print(f"Service unreachable: {e}")
122
+ ```
123
+
124
+ ### PyTorch Integration
125
+
126
+ ```python
127
+ import torch
128
+ from juniper_data_client import JuniperDataClient
129
+
130
+ client = JuniperDataClient()
131
+ result = client.create_spiral_dataset(seed=42)
132
+ arrays = client.download_artifact_npz(result["dataset_id"])
133
+
134
+ # Convert to PyTorch tensors
135
+ X_train = torch.from_numpy(arrays["X_train"]) # torch.float32
136
+ y_train = torch.from_numpy(arrays["y_train"]) # torch.float32
137
+ ```
138
+
139
+ ## API Reference
140
+
141
+ ### JuniperDataClient
142
+
143
+ | Method | Description |
144
+ | ----------------------------------- | -------------------------------------- |
145
+ | `health_check()` | Get service health status |
146
+ | `is_ready()` | Check if service is ready (boolean) |
147
+ | `wait_for_ready(timeout)` | Wait for service to become ready |
148
+ | `list_generators()` | List available generators |
149
+ | `get_generator_schema(name)` | Get parameter schema for generator |
150
+ | `create_dataset(generator, params)` | Create dataset with generator |
151
+ | `create_spiral_dataset(**kwargs)` | Convenience method for spiral datasets |
152
+ | `list_datasets(limit, offset)` | List dataset IDs |
153
+ | `get_dataset_metadata(id)` | Get dataset metadata |
154
+ | `download_artifact_npz(id)` | Download NPZ as dict of arrays |
155
+ | `download_artifact_bytes(id)` | Download raw NPZ bytes |
156
+ | `get_preview(id, n)` | Get JSON preview of samples |
157
+ | `delete_dataset(id)` | Delete a dataset |
158
+ | `close()` | Close the client session |
159
+
160
+ ### Exceptions
161
+
162
+ | Exception | Description |
163
+ | ---------------------------- | ----------------------------- |
164
+ | `JuniperDataClientError` | Base exception for all errors |
165
+ | `JuniperDataConnectionError` | Connection to service failed |
166
+ | `JuniperDataTimeoutError` | Request timed out |
167
+ | `JuniperDataNotFoundError` | Resource not found (404) |
168
+ | `JuniperDataValidationError` | Invalid parameters (400/422) |
169
+
170
+ ## NPZ Artifact Schema
171
+
172
+ Downloaded artifacts contain the following numpy arrays (all `float32`):
173
+
174
+ | Key | Shape | Description |
175
+ | --------- | ---------------------- | ----------------------------- |
176
+ | `X_train` | `(n_train, 2)` | Training features |
177
+ | `y_train` | `(n_train, n_classes)` | Training labels (one-hot) |
178
+ | `X_test` | `(n_test, 2)` | Test features |
179
+ | `y_test` | `(n_test, n_classes)` | Test labels (one-hot) |
180
+ | `X_full` | `(n_total, 2)` | Full dataset features |
181
+ | `y_full` | `(n_total, n_classes)` | Full dataset labels (one-hot) |
182
+
183
+ ## Configuration
184
+
185
+ | Parameter | Default | Description |
186
+ | ---------------- | ----------------------- | ---------------------------------- |
187
+ | `base_url` | `http://localhost:8100` | JuniperData service URL |
188
+ | `timeout` | `30` | Request timeout in seconds |
189
+ | `retries` | `3` | Number of retry attempts |
190
+ | `backoff_factor` | `0.5` | Backoff multiplier between retries |
191
+
192
+ ## Requirements
193
+
194
+ - Python >=3.11
195
+ - numpy >=1.24.0
196
+ - requests >=2.28.0
197
+ - urllib3 >=2.0.0
198
+
199
+ ## License
200
+
201
+ MIT License - Copyright (c) 2024-2026 Paul Calnon
202
+
203
+ ## See Also
204
+
205
+ - [JuniperData](https://github.com/pcalnon/Juniper/tree/main/JuniperData)
206
+ - [JuniperCascor](https://github.com/pcalnon/Juniper/tree/main/JuniperCascor)
207
+ - [JuniperCanopy](https://github.com/pcalnon/Juniper/tree/main/JuniperCanopy)
@@ -0,0 +1,28 @@
1
+ """JuniperData Client - Python client library for the JuniperData REST API.
2
+
3
+ This package provides a simple, robust client for interacting with the JuniperData
4
+ dataset generation service, used by both JuniperCascor and JuniperCanopy.
5
+ """
6
+
7
+ from juniper_data_client.client import JuniperDataClient
8
+ from juniper_data_client.exceptions import (
9
+ JuniperDataClientError,
10
+ JuniperDataConfigurationError,
11
+ JuniperDataConnectionError,
12
+ JuniperDataNotFoundError,
13
+ JuniperDataTimeoutError,
14
+ JuniperDataValidationError,
15
+ )
16
+
17
+ __version__ = "0.3.0"
18
+
19
+ __all__ = [
20
+ "JuniperDataClient",
21
+ "JuniperDataClientError",
22
+ "JuniperDataConfigurationError",
23
+ "JuniperDataConnectionError",
24
+ "JuniperDataNotFoundError",
25
+ "JuniperDataTimeoutError",
26
+ "JuniperDataValidationError",
27
+ "__version__",
28
+ ]