simplismart-sdk 0.1.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.
Files changed (30) hide show
  1. simplismart_sdk-0.1.0/PKG-INFO +450 -0
  2. simplismart_sdk-0.1.0/README.md +433 -0
  3. simplismart_sdk-0.1.0/pyproject.toml +43 -0
  4. simplismart_sdk-0.1.0/setup.cfg +4 -0
  5. simplismart_sdk-0.1.0/src/simplismart/__init__.py +40 -0
  6. simplismart_sdk-0.1.0/src/simplismart/api/__init__.py +9 -0
  7. simplismart_sdk-0.1.0/src/simplismart/api/deployments.py +218 -0
  8. simplismart_sdk-0.1.0/src/simplismart/api/model_repos.py +75 -0
  9. simplismart_sdk-0.1.0/src/simplismart/api/secrets.py +41 -0
  10. simplismart_sdk-0.1.0/src/simplismart/cli/__init__.py +1 -0
  11. simplismart_sdk-0.1.0/src/simplismart/cli/common.py +93 -0
  12. simplismart_sdk-0.1.0/src/simplismart/cli/deployments.py +231 -0
  13. simplismart_sdk-0.1.0/src/simplismart/cli/main.py +46 -0
  14. simplismart_sdk-0.1.0/src/simplismart/cli/model_repos.py +290 -0
  15. simplismart_sdk-0.1.0/src/simplismart/cli/secrets.py +88 -0
  16. simplismart_sdk-0.1.0/src/simplismart/client.py +228 -0
  17. simplismart_sdk-0.1.0/src/simplismart/config.py +27 -0
  18. simplismart_sdk-0.1.0/src/simplismart/exceptions.py +13 -0
  19. simplismart_sdk-0.1.0/src/simplismart/http.py +89 -0
  20. simplismart_sdk-0.1.0/src/simplismart/models/__init__.py +19 -0
  21. simplismart_sdk-0.1.0/src/simplismart/models/_shared.py +24 -0
  22. simplismart_sdk-0.1.0/src/simplismart/models/deployment.py +184 -0
  23. simplismart_sdk-0.1.0/src/simplismart/models/model_repo.py +365 -0
  24. simplismart_sdk-0.1.0/src/simplismart/models/secret.py +26 -0
  25. simplismart_sdk-0.1.0/src/simplismart_sdk.egg-info/PKG-INFO +450 -0
  26. simplismart_sdk-0.1.0/src/simplismart_sdk.egg-info/SOURCES.txt +28 -0
  27. simplismart_sdk-0.1.0/src/simplismart_sdk.egg-info/dependency_links.txt +1 -0
  28. simplismart_sdk-0.1.0/src/simplismart_sdk.egg-info/entry_points.txt +2 -0
  29. simplismart_sdk-0.1.0/src/simplismart_sdk.egg-info/requires.txt +2 -0
  30. simplismart_sdk-0.1.0/src/simplismart_sdk.egg-info/top_level.txt +1 -0
@@ -0,0 +1,450 @@
1
+ Metadata-Version: 2.4
2
+ Name: simplismart-sdk
3
+ Version: 0.1.0
4
+ Summary: Python SDK scaffold for Simplismart API
5
+ Author-email: Simplismart <developers@simplismart.ai>
6
+ Project-URL: Homepage, https://simplismart.ai
7
+ Project-URL: Source, https://docs.simplismart.ai/sdk/python
8
+ Keywords: simplismart,sdk,api,deployments,models
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3 :: Only
11
+ Classifier: License :: Other/Proprietary License
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.9
14
+ Description-Content-Type: text/markdown
15
+ Requires-Dist: requests>=2.31
16
+ Requires-Dist: pydantic<3,>=2.0
17
+
18
+ # Simplismart Python SDK
19
+
20
+ [![PyPI version](https://img.shields.io/pypi/v/simplismart-sdk.svg)](https://pypi.org/project/simplismart-sdk/)
21
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
22
+
23
+ Official Python SDK and CLI for the [Simplismart](https://simplismart.ai) MLOps platform. Deploy and manage AI/ML models and containers with an idiomatic Python client and a full-featured CLI.
24
+
25
+ ## Features
26
+
27
+ - **Model repos** - List, create (Bring Your Own Container), create private compile jobs, get, profile lookup, delete
28
+ - **Deployments** - Create private or BYOC deployments; list, update, start, stop, scale, delete; health checks and autoscaling
29
+ - **Secrets** - Create and manage registry credentials (e.g. Docker Hub) for secure image pulls
30
+ - **CLI** - Same capabilities from the terminal with `simplismart` for scripts and CI/CD
31
+
32
+ ## Requirements
33
+
34
+ - **Python 3.9+**
35
+ - A Simplismart **Playground token** (PG token) and **organization ID**
36
+
37
+ ## Installation
38
+
39
+ ```bash
40
+ pip install simplismart-sdk
41
+ ```
42
+
43
+ ## Authentication
44
+
45
+ ```bash
46
+ export SIMPLISMART_PG_TOKEN="<YOUR_PG_TOKEN>"
47
+ export ORG_ID="<YOUR_ORG_UUID>"
48
+
49
+ # Optional
50
+ export SIMPLISMART_BASE_URL="https://api.app.simplismart.ai"
51
+ export SIMPLISMART_TIMEOUT="300"
52
+ ```
53
+
54
+ ### Configuration Reference
55
+
56
+ | Variable | Required | Default | Description |
57
+ |---|---|---|---|
58
+ | `SIMPLISMART_PG_TOKEN` | Yes* | - | Playground API token |
59
+ | `ORG_ID` | Recommended | - | Organization UUID used in create/list examples |
60
+ | `SIMPLISMART_BASE_URL` | No | `https://api.app.simplismart.ai` | API base URL |
61
+ | `SIMPLISMART_TIMEOUT` | No | `300` | Optional request timeout in seconds |
62
+ | `SIMPLISMART_TRACE_ID` | No | (none) | Default trace ID value; if unset, SDK auto-generates one per request |
63
+
64
+ \* Required unless passed in constructor (`Simplismart(pg_token=...)`).
65
+
66
+ ## Quick Start (Python)
67
+
68
+ ```python
69
+ from simplismart import ModelRepoListParams, Simplismart
70
+
71
+ client = Simplismart() # uses SIMPLISMART_PG_TOKEN from environment
72
+
73
+ repos = client.list_model_repos(
74
+ ModelRepoListParams(
75
+ org_id="<YOUR_ORG_UUID>",
76
+ offset=0,
77
+ count=5,
78
+ )
79
+ )
80
+
81
+ print(repos)
82
+ ```
83
+
84
+ ### Explicit Client Constructor
85
+
86
+ Use explicit parameters instead of environment variables when needed.
87
+ Trace IDs are set per request. If you don't pass `trace_id`, the SDK auto-generates one.
88
+
89
+ ```python
90
+ from simplismart import Simplismart
91
+
92
+ client = Simplismart(
93
+ pg_token="<YOUR_PG_TOKEN>",
94
+ base_url="https://api.app.simplismart.ai", # optional
95
+ timeout=300, # optional
96
+ )
97
+ ```
98
+
99
+ ### Tracing (Trace ID)
100
+
101
+ Every request sends an `X-Trace-Id` header.
102
+
103
+ - Python: pass `trace_id=...` on the SDK method call.
104
+ - CLI: pass `--trace-id ...` once per CLI invocation.
105
+ - Optional: set `SIMPLISMART_TRACE_ID` to define a default trace ID when you don't pass `trace_id`.
106
+ - If omitted, the SDK generates a new trace ID per request.
107
+
108
+ ```python
109
+ repo = client.get_model_repo(model_id="<MODEL_REPO_ID>", trace_id="my-correlation-id")
110
+ print(repo)
111
+ ```
112
+
113
+ ```bash
114
+ simplismart --trace-id my-correlation-id model-repos get --model-id "<MODEL_REPO_ID>"
115
+ ```
116
+
117
+ ## Model Repositories
118
+
119
+ ### List and Get
120
+
121
+ #### CLI
122
+
123
+ ```bash
124
+ # List
125
+ simplismart model-repos list --org-id "$ORG_ID" --offset 0 --count 5
126
+
127
+ # Print only model repo IDs
128
+ simplismart model-repos list --org-id "$ORG_ID" | jq -r '.results[].uuid'
129
+ # Note: `jq` is optional. If you don't have it installed, remove the pipe and inspect the JSON output.
130
+
131
+ # Get one model repo
132
+ simplismart model-repos get --model-id "<MODEL_REPO_ID>"
133
+
134
+ # Model profiles
135
+ simplismart model-repos profiles --type hf --path "meta-llama/Llama-3.2-1B-Instruct"
136
+ # Optional: pass a secret if the source requires it
137
+ simplismart model-repos profiles --type hf --path "meta-llama/Llama-3.2-1B-Instruct" --secret-id "<SECRET_ID>"
138
+ ```
139
+
140
+ #### Python
141
+
142
+ ```python
143
+ from simplismart import ModelRepoListParams, Simplismart
144
+
145
+ client = Simplismart()
146
+
147
+ data = client.list_model_repos(ModelRepoListParams(org_id="<YOUR_ORG_UUID>", count=5))
148
+ print(data)
149
+
150
+ one = client.get_model_repo(model_id="<MODEL_REPO_ID>")
151
+ print(one)
152
+ ```
153
+
154
+ ### Create Container (Bring Your Own Container)
155
+
156
+ Use this flow when you already have an image in a supported registry.
157
+
158
+ #### CLI
159
+
160
+ ```bash
161
+ simplismart model-repos create-container \
162
+ --name "byom-1" \
163
+ --org-id "$ORG_ID" \
164
+ --source-type "docker_hub" \
165
+ --source-secret "<SECRET_ID>" \
166
+ --registry-path "my-org/my-image" \
167
+ --docker-tag "latest" \
168
+ --runtime-gpus 0
169
+ ```
170
+
171
+ #### Python
172
+
173
+ ```python
174
+ from simplismart import ModelRepoCreate, Simplismart
175
+
176
+ client = Simplismart()
177
+
178
+ resp = client.create_model_repo(
179
+ ModelRepoCreate(
180
+ name="byom-1",
181
+ org_id="<YOUR_ORG_UUID>",
182
+ source_type="docker_hub",
183
+ source_secret="<SECRET_ID>",
184
+ registry_path="my-org/my-image",
185
+ docker_tag="latest",
186
+ runtime_gpus=0,
187
+ )
188
+ )
189
+
190
+ print(resp)
191
+ ```
192
+
193
+ ### Create Private Compile Model Repo
194
+
195
+ Use this flow when Simplismart should compile/optimize and package the model.
196
+
197
+ Notes:
198
+ - This method always sends `use_simplismart_infrastructure=true`.
199
+ - `org` is optional in payload for compile flow because backend can infer it from PG token.
200
+ - You should pass full JSON for `model_config`, `optimisation_config`, and `pipeline_config`.
201
+
202
+ #### CLI
203
+
204
+ ```bash
205
+ simplismart model-repos create-private-compile \
206
+ --name "llama-model" \
207
+ --description "llama-model - A model deployed using Simplismart" \
208
+ --avatar-url "https://ui-avatars.com/api/?background=f3f3f3&color=000000&name=llama-model" \
209
+ --source-type "huggingface" \
210
+ --source-url "meta-llama/Llama-3.2-1B-Instruct" \
211
+ --model-class "LlamaForCausalLM" \
212
+ --accelerator-type "nvidia-h100" \
213
+ --accelerator-count 0 \
214
+ --cloud-account "<CLOUD_ACCOUNT_UUID>" \
215
+ --model-config '{"architectures":["LlamaForCausalLM"],"model_type":"llama","hidden_size":2048}' \
216
+ --optimisation-config '{"model_type":"llm","quantization":"float16","tensor_parallel_size":2}' \
217
+ --pipeline-config '{"type":"llm","mode":"chat","extra_params":{}}'
218
+ ```
219
+
220
+ You can also pass JSON via files using the `@path.json` form:
221
+
222
+ ```bash
223
+ simplismart model-repos create-private-compile \
224
+ --name "llama-model" \
225
+ --avatar-url "https://ui-avatars.com/api/?background=f3f3f3&color=000000&name=llama-model" \
226
+ --source-type "huggingface" \
227
+ --source-url "meta-llama/Llama-3.2-1B-Instruct" \
228
+ --model-class "LlamaForCausalLM" \
229
+ --accelerator-type "nvidia-h100" \
230
+ --cloud-account "<CLOUD_ACCOUNT_UUID>" \
231
+ --model-config @model_config.json \
232
+ --optimisation-config @optimisation_config.json \
233
+ --pipeline-config @pipeline_config.json
234
+ ```
235
+
236
+ #### Python
237
+
238
+ ```python
239
+ from simplismart import (
240
+ ModelRepoCompileAvatar,
241
+ ModelRepoCompileCreate,
242
+ Simplismart,
243
+ )
244
+
245
+ client = Simplismart()
246
+
247
+ resp = client.create_model_repo_private_compile(
248
+ ModelRepoCompileCreate(
249
+ name="llama-model",
250
+ description="llama-model - A model deployed using Simplismart",
251
+ avatar=ModelRepoCompileAvatar(
252
+ image_url="https://ui-avatars.com/api/?background=f3f3f3&color=000000&name=llama-model"
253
+ ),
254
+ source_type="huggingface",
255
+ source_url="meta-llama/Llama-3.2-1B-Instruct",
256
+ model_class="LlamaForCausalLM",
257
+ accelerator_type="nvidia-h100",
258
+ accelerator_count=0,
259
+ cloud_account="<CLOUD_ACCOUNT_UUID>",
260
+ model_config_data={
261
+ "architectures": ["LlamaForCausalLM"],
262
+ "model_type": "llama",
263
+ "hidden_size": 2048,
264
+ },
265
+ optimisation_config={
266
+ "model_type": "llm",
267
+ "quantization": "float16",
268
+ "tensor_parallel_size": 2,
269
+ },
270
+ pipeline_config={
271
+ "type": "llm",
272
+ "mode": "chat",
273
+ "extra_params": {},
274
+ },
275
+ )
276
+ )
277
+
278
+ print(resp)
279
+ ```
280
+
281
+ ### Delete
282
+
283
+ ```bash
284
+ simplismart model-repos delete --model-id "<MODEL_REPO_ID>"
285
+ ```
286
+
287
+ ## Deployments
288
+
289
+ ### Create Private Deployment
290
+
291
+ #### CLI
292
+
293
+ ```bash
294
+ simplismart deployments create-private --model-repo <MODEL_REPO_ID> --org "$ORG_ID" \
295
+ --gpu-id nvidia-h100 --name my-deploy --min-pod-replicas 1 --max-pod-replicas 2 \
296
+ --autoscale-config '{"targets":[{"metric":"gpu","target":80}]}'
297
+
298
+ # Update (payload from file)
299
+ simplismart deployments update --deployment-id <DEPLOYMENT_ID> --payload @edit-payload.json
300
+ ```
301
+
302
+ #### Python
303
+
304
+ ```python
305
+ from simplismart import DeploymentCreate, Simplismart
306
+
307
+ client = Simplismart()
308
+
309
+ resp = client.create_private_deployment(
310
+ DeploymentCreate(
311
+ model_repo="<MODEL_REPO_ID>",
312
+ org="<YOUR_ORG_UUID>",
313
+ gpu_id="nvidia-h100",
314
+ name="my-deployment",
315
+ min_pod_replicas=1,
316
+ max_pod_replicas=2,
317
+ autoscale_config={"targets": [{"metric": "gpu", "target": 80}]},
318
+ )
319
+ )
320
+
321
+ print(resp)
322
+ ```
323
+
324
+ ### Common Deployment Commands
325
+
326
+ ```bash
327
+ simplismart deployments list --offset 0 --count 20
328
+ simplismart deployments get --deployment-id "<DEPLOYMENT_ID>"
329
+ simplismart deployments stop --deployment-id "<DEPLOYMENT_ID>"
330
+ simplismart deployments start --deployment-id "<DEPLOYMENT_ID>"
331
+ simplismart deployments scale --deployment-id "<DEPLOYMENT_ID>" --min-replicas 1 --max-replicas 3
332
+ simplismart deployments delete --deployment-id "<DEPLOYMENT_ID>"
333
+ ```
334
+
335
+ ## Secrets
336
+
337
+ ### Create, List, Get
338
+
339
+ #### CLI
340
+
341
+ ```bash
342
+ simplismart secrets create \
343
+ --org-id "$ORG_ID" \
344
+ --name "dockerhub-secret" \
345
+ --secret-type "docker_hub" \
346
+ --data '{"username":"my-user","token":"my-token"}'
347
+
348
+ simplismart secrets list --org-id "$ORG_ID"
349
+ simplismart secrets get --secret-id "<SECRET_ID>"
350
+
351
+ # Secret config schema from PG token context
352
+ simplismart secrets config
353
+ ```
354
+
355
+ #### Python
356
+
357
+ ```python
358
+ from simplismart import SecretCreate, Simplismart
359
+
360
+ client = Simplismart()
361
+
362
+ resp = client.create_secret(
363
+ SecretCreate(
364
+ org="<YOUR_ORG_UUID>",
365
+ name="dockerhub-secret",
366
+ secret_type="docker_hub",
367
+ data={"username": "my-user", "token": "my-token"},
368
+ )
369
+ )
370
+
371
+ print(resp)
372
+ ```
373
+
374
+ ## CLI Reference
375
+
376
+ ### Global Options
377
+
378
+ | Option | Description |
379
+ |---|---|
380
+ | `--pg-token` | Override `SIMPLISMART_PG_TOKEN` |
381
+ | `--base-url` | Override `SIMPLISMART_BASE_URL` |
382
+ | `--timeout` | Optional request timeout in seconds |
383
+ | `--trace-id` | Optional trace/correlation ID (auto-generated if omitted) |
384
+
385
+ ### Command Groups
386
+
387
+ | Group | Purpose |
388
+ |---|---|
389
+ | `model-repos` | List/get/create/delete model repositories |
390
+ | `deployments` | Create/update/list/manage deployments |
391
+ | `secrets` | Create/list/get secrets and list secret config schemas |
392
+
393
+ Use:
394
+
395
+ ```bash
396
+ simplismart <group> --help
397
+ simplismart <group> <command> --help
398
+ ```
399
+
400
+ ## Python API Reference
401
+
402
+ | Area | Methods |
403
+ |---|---|
404
+ | Model repos | `list_model_repos`, `get_model_repo`, `create_model_repo`, `create_model_repo_private_compile`, `get_model_repo_profiles`, `delete_model_repo` |
405
+ | Deployments | `create_private_deployment`, `create_deployment` (alias), `list_deployments`, `list_model_deployments`, `create_byoc_deployment`, `get_model_deployment`, `get_deployment` (alias), `update_deployment`, `stop_deployment`, `start_deployment`, `restart_deployment`, `fetch_deployment_health`, `update_deployment_autoscaling`, `delete_deployment`, `delete_model_deployment` (alias) |
406
+ | Secrets | `create_secret`, `list_secrets`, `get_secret`, `list_secret_configs` |
407
+
408
+ Exported request models:
409
+ - `ModelRepoListParams`
410
+ - `ModelRepoCreate`
411
+ - `ModelRepoCompileCreate`
412
+ - `ModelRepoCompileAvatar`
413
+ - `ModelRepoProfilesRequest`
414
+ - `DeploymentCreate`
415
+ - `SecretCreate`
416
+
417
+ ## Error Handling
418
+
419
+ The SDK raises `SimplismartError` for non-2xx responses.
420
+
421
+ ```python
422
+ from simplismart import Simplismart, SimplismartError
423
+
424
+ client = Simplismart()
425
+
426
+ try:
427
+ client.get_model_repo("<MODEL_REPO_ID>")
428
+ except SimplismartError as exc:
429
+ print(exc.message)
430
+ print(exc.status_code)
431
+ print(exc.payload)
432
+ ```
433
+
434
+ CLI errors are printed as JSON.
435
+
436
+ ## Security Notes
437
+
438
+ - Do not hardcode tokens or cloud credentials in source code.
439
+ - Use environment variables or a secret manager in CI/CD.
440
+ - Rotate credentials immediately if exposed.
441
+
442
+ ## Troubleshooting
443
+
444
+ - **Missing or invalid token:** Ensure `SIMPLISMART_PG_TOKEN` is set (or pass `pg_token` to `Simplismart(...)`). Get your Playground token from the Simplismart dashboard.
445
+ - **Wrong base URL:** Use `https://api.app.simplismart.ai` (no trailing slash) unless you have a custom endpoint.
446
+ - **4xx/5xx errors:** Check `SimplismartError.status_code` and `SimplismartError.payload` for details; refer to the API docs for required fields.
447
+
448
+ ## License
449
+
450
+ Proprietary. See your Simplismart agreement for terms.