superb-ai 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 (117) hide show
  1. superb_ai-0.1.0/.gitignore +54 -0
  2. superb_ai-0.1.0/AGENTS.md +257 -0
  3. superb_ai-0.1.0/CHANGELOG.md +127 -0
  4. superb_ai-0.1.0/LICENSE +202 -0
  5. superb_ai-0.1.0/PKG-INFO +24 -0
  6. superb_ai-0.1.0/README.md +3 -0
  7. superb_ai-0.1.0/STYLE.md +64 -0
  8. superb_ai-0.1.0/api-map.md +234 -0
  9. superb_ai-0.1.0/examples/team_quickstart.py +134 -0
  10. superb_ai-0.1.0/llms.txt +15 -0
  11. superb_ai-0.1.0/pyproject.toml +56 -0
  12. superb_ai-0.1.0/src/superb_ai/__init__.py +59 -0
  13. superb_ai-0.1.0/src/superb_ai/_base.py +66 -0
  14. superb_ai-0.1.0/src/superb_ai/_client.py +448 -0
  15. superb_ai-0.1.0/src/superb_ai/_errors.py +250 -0
  16. superb_ai-0.1.0/src/superb_ai/_files.py +92 -0
  17. superb_ai-0.1.0/src/superb_ai/_jobs.py +143 -0
  18. superb_ai-0.1.0/src/superb_ai/_pagination.py +115 -0
  19. superb_ai-0.1.0/src/superb_ai/_version.py +5 -0
  20. superb_ai-0.1.0/src/superb_ai/py.typed +0 -0
  21. superb_ai-0.1.0/src/superb_ai/resources/__init__.py +89 -0
  22. superb_ai-0.1.0/src/superb_ai/resources/account.py +116 -0
  23. superb_ai-0.1.0/src/superb_ai/resources/activity.py +269 -0
  24. superb_ai-0.1.0/src/superb_ai/resources/annotations.py +551 -0
  25. superb_ai-0.1.0/src/superb_ai/resources/api_keys.py +99 -0
  26. superb_ai-0.1.0/src/superb_ai/resources/assets.py +634 -0
  27. superb_ai-0.1.0/src/superb_ai/resources/auth.py +120 -0
  28. superb_ai-0.1.0/src/superb_ai/resources/auto_label.py +373 -0
  29. superb_ai-0.1.0/src/superb_ai/resources/classes.py +437 -0
  30. superb_ai-0.1.0/src/superb_ai/resources/comments.py +397 -0
  31. superb_ai-0.1.0/src/superb_ai/resources/datasets.py +267 -0
  32. superb_ai-0.1.0/src/superb_ai/resources/deployments.py +219 -0
  33. superb_ai-0.1.0/src/superb_ai/resources/exports.py +268 -0
  34. superb_ai-0.1.0/src/superb_ai/resources/foundation.py +143 -0
  35. superb_ai-0.1.0/src/superb_ai/resources/guidelines.py +124 -0
  36. superb_ai-0.1.0/src/superb_ai/resources/invitations.py +98 -0
  37. superb_ai-0.1.0/src/superb_ai/resources/jobs.py +132 -0
  38. superb_ai-0.1.0/src/superb_ai/resources/labeling_time.py +160 -0
  39. superb_ai-0.1.0/src/superb_ai/resources/members.py +134 -0
  40. superb_ai-0.1.0/src/superb_ai/resources/models.py +149 -0
  41. superb_ai-0.1.0/src/superb_ai/resources/project_assets.py +373 -0
  42. superb_ai-0.1.0/src/superb_ai/resources/projects.py +320 -0
  43. superb_ai-0.1.0/src/superb_ai/resources/revisions.py +163 -0
  44. superb_ai-0.1.0/src/superb_ai/resources/segment.py +86 -0
  45. superb_ai-0.1.0/src/superb_ai/resources/tags.py +353 -0
  46. superb_ai-0.1.0/src/superb_ai/resources/tenants.py +121 -0
  47. superb_ai-0.1.0/src/superb_ai/resources/training.py +413 -0
  48. superb_ai-0.1.0/src/superb_ai/resources/users.py +248 -0
  49. superb_ai-0.1.0/src/superb_ai/resources/versions.py +510 -0
  50. superb_ai-0.1.0/src/superb_ai/resources/visualization.py +100 -0
  51. superb_ai-0.1.0/src/superb_ai/resources/workflow.py +782 -0
  52. superb_ai-0.1.0/src/superb_ai/resources/workflow_batch.py +467 -0
  53. superb_ai-0.1.0/src/superb_ai/types/__init__.py +0 -0
  54. superb_ai-0.1.0/src/superb_ai/types/account.py +59 -0
  55. superb_ai-0.1.0/src/superb_ai/types/activity.py +48 -0
  56. superb_ai-0.1.0/src/superb_ai/types/annotations.py +134 -0
  57. superb_ai-0.1.0/src/superb_ai/types/assets.py +234 -0
  58. superb_ai-0.1.0/src/superb_ai/types/auth.py +76 -0
  59. superb_ai-0.1.0/src/superb_ai/types/auto_label.py +86 -0
  60. superb_ai-0.1.0/src/superb_ai/types/classes.py +158 -0
  61. superb_ai-0.1.0/src/superb_ai/types/comments.py +96 -0
  62. superb_ai-0.1.0/src/superb_ai/types/common.py +305 -0
  63. superb_ai-0.1.0/src/superb_ai/types/datasets.py +57 -0
  64. superb_ai-0.1.0/src/superb_ai/types/deployments.py +104 -0
  65. superb_ai-0.1.0/src/superb_ai/types/exports.py +69 -0
  66. superb_ai-0.1.0/src/superb_ai/types/foundation.py +63 -0
  67. superb_ai-0.1.0/src/superb_ai/types/guidelines.py +40 -0
  68. superb_ai-0.1.0/src/superb_ai/types/jobs.py +40 -0
  69. superb_ai-0.1.0/src/superb_ai/types/labeling_time.py +36 -0
  70. superb_ai-0.1.0/src/superb_ai/types/members.py +32 -0
  71. superb_ai-0.1.0/src/superb_ai/types/models.py +88 -0
  72. superb_ai-0.1.0/src/superb_ai/types/project_assets.py +100 -0
  73. superb_ai-0.1.0/src/superb_ai/types/projects.py +83 -0
  74. superb_ai-0.1.0/src/superb_ai/types/requests.py +397 -0
  75. superb_ai-0.1.0/src/superb_ai/types/revisions.py +82 -0
  76. superb_ai-0.1.0/src/superb_ai/types/segment.py +33 -0
  77. superb_ai-0.1.0/src/superb_ai/types/tags.py +113 -0
  78. superb_ai-0.1.0/src/superb_ai/types/tenants.py +44 -0
  79. superb_ai-0.1.0/src/superb_ai/types/training.py +206 -0
  80. superb_ai-0.1.0/src/superb_ai/types/users.py +43 -0
  81. superb_ai-0.1.0/src/superb_ai/types/versions.py +124 -0
  82. superb_ai-0.1.0/src/superb_ai/types/visualization.py +41 -0
  83. superb_ai-0.1.0/src/superb_ai/types/workflow.py +208 -0
  84. superb_ai-0.1.0/tests/integration/conftest.py +189 -0
  85. superb_ai-0.1.0/tests/integration/test_account.py +144 -0
  86. superb_ai-0.1.0/tests/integration/test_activity.py +147 -0
  87. superb_ai-0.1.0/tests/integration/test_annotations.py +265 -0
  88. superb_ai-0.1.0/tests/integration/test_assets.py +368 -0
  89. superb_ai-0.1.0/tests/integration/test_auth_keys.py +243 -0
  90. superb_ai-0.1.0/tests/integration/test_auto_label.py +480 -0
  91. superb_ai-0.1.0/tests/integration/test_classes.py +274 -0
  92. superb_ai-0.1.0/tests/integration/test_client_logging.py +154 -0
  93. superb_ai-0.1.0/tests/integration/test_comments.py +375 -0
  94. superb_ai-0.1.0/tests/integration/test_datasets.py +227 -0
  95. superb_ai-0.1.0/tests/integration/test_deployments.py +378 -0
  96. superb_ai-0.1.0/tests/integration/test_exports.py +282 -0
  97. superb_ai-0.1.0/tests/integration/test_foundation.py +173 -0
  98. superb_ai-0.1.0/tests/integration/test_gates.py +256 -0
  99. superb_ai-0.1.0/tests/integration/test_guidelines.py +85 -0
  100. superb_ai-0.1.0/tests/integration/test_labeling_time.py +90 -0
  101. superb_ai-0.1.0/tests/integration/test_members.py +134 -0
  102. superb_ai-0.1.0/tests/integration/test_models.py +180 -0
  103. superb_ai-0.1.0/tests/integration/test_project_assets.py +364 -0
  104. superb_ai-0.1.0/tests/integration/test_projects.py +163 -0
  105. superb_ai-0.1.0/tests/integration/test_revisions.py +247 -0
  106. superb_ai-0.1.0/tests/integration/test_segment.py +140 -0
  107. superb_ai-0.1.0/tests/integration/test_tags.py +213 -0
  108. superb_ai-0.1.0/tests/integration/test_tenants.py +94 -0
  109. superb_ai-0.1.0/tests/integration/test_training.py +316 -0
  110. superb_ai-0.1.0/tests/integration/test_users.py +308 -0
  111. superb_ai-0.1.0/tests/integration/test_versions.py +196 -0
  112. superb_ai-0.1.0/tests/integration/test_visualization.py +177 -0
  113. superb_ai-0.1.0/tests/integration/test_workflow.py +331 -0
  114. superb_ai-0.1.0/tests/integration/test_workflow_batch.py +367 -0
  115. superb_ai-0.1.0/tests/integration/test_zz_g2_closure.py +82 -0
  116. superb_ai-0.1.0/tests/integration/tests_recorder.py +46 -0
  117. superb_ai-0.1.0/uv.lock +292 -0
@@ -0,0 +1,54 @@
1
+ # Python
2
+ __pycache__/
3
+ *.pyc
4
+ *.pyo
5
+ *.egg-info/
6
+ .pytest_cache/
7
+ .mypy_cache/
8
+ .ruff_cache/
9
+
10
+ # uv / venv
11
+ .venv/
12
+
13
+ # CDK
14
+ cdk.out/
15
+ .cdk.staging/
16
+
17
+ # Env / secrets
18
+ .env
19
+ .env.local
20
+ .env.*.local
21
+ .env.*
22
+ # (no tracked .env* files; if an example is ever committed, add `!.env.example`)
23
+ # Migration record files hold test credentials — never commit.
24
+ workos-migration-accounts-*.md
25
+
26
+ # IDE / OS
27
+ .vscode/
28
+ .idea/
29
+ *.swp
30
+ .DS_Store
31
+
32
+ # Demo seeding artifacts (live tenant credentials + sample IDs; not for source)
33
+ demo/
34
+
35
+ # ffmpeg layer tarball — fetched at deploy time via infra/layers/ffmpeg/fetch.sh
36
+ infra/layers/ffmpeg/*.tar.xz
37
+
38
+ # Local scratch space for one-off rendering, debugging, etc.
39
+ tmp/
40
+ # FE handoff docs + test-account credentials — never commit (untracked working files).
41
+ fe-*.md
42
+
43
+ # CEO/stakeholder reports — working files, not product docs
44
+ report/
45
+ cost/
46
+ infra/sam/*.pt
47
+
48
+ # e2e seed/validation package + keyrings (untracked working files)
49
+ e2e/
50
+ sdk-plan.md
51
+
52
+ # SDK build artifacts
53
+ sdk/dist/
54
+ ops-*.md
@@ -0,0 +1,257 @@
1
+ # superb-ai — agent guide
2
+
3
+ You are using the official Python SDK for **Superb AI** (datasets → labeling →
4
+ versions → training → deployment). This file is your skill doc: auth, the client map,
5
+ worked recipes, and the gotchas that waste hours if you rediscover them.
6
+
7
+ Discovery: `api-map.md` (same dir) lists EVERY method one-line-per-method — grep it.
8
+ Every method has a full docstring (args, returns, `Raises:` with error codes).
9
+ Errors are typed: branch on `exc.code` (an `ErrorCode`), read `exc.hint`.
10
+
11
+ ## Auth (3 lines)
12
+
13
+ ```python
14
+ from superb_ai import Client
15
+ client = Client(tenant="acme", api_key="sbd_pk_...") # or set SUPERB_AI_TENANT + SUPERB_AI_API_KEY
16
+ # with both env vars set, `Client()` alone works — nothing to hardcode
17
+ assert client.projects.list().items is not None # smoke: you're in
18
+ ```
19
+
20
+ Machine keys (`sbd_pk_…`) are the primary credential. The `client.auth.*` surface is
21
+ **JWT-bootstrap-only** (browser login dance) — a key holder never calls it. Each key
22
+ acts as ONE user; multi-actor workflows need one client per user key.
23
+
24
+ ## Client map (namespaces)
25
+
26
+ `client.` → `tenants users api_keys auth account invitations datasets assets projects
27
+ classes members guidelines labeling_time tags workflow workflow_batch project_assets
28
+ annotations revisions comments versions exports jobs training models deployments
29
+ auto_label foundation segment activity visualization`
30
+
31
+ `account` (my workspaces / accept invitations) is **JWT-session-only** — an
32
+ `sbd_pk_…` key gets 401 there; machine keys already know their workspace.
33
+ `invitations` (admin: invite email + role, list, revoke) works with keys.
34
+
35
+ Pagination: list methods return `Page[T]` — iterate the page object to auto-fetch all
36
+ pages (`for x in client.annotations.list(pid): ...`). `include_total=True` adds
37
+ `.total`. Non-list collection reads (classes, tags, progress, queue stats) return
38
+ complete models, not pages.
39
+
40
+ Async jobs: kickoff methods return a `JobHandle` — call `.wait(timeout=...)`; it
41
+ raises `JobFailedError` on failure and `JobTimeoutError` (job keeps running) on
42
+ timeout. `handle.result_summary` carries per-kind outcome keys.
43
+
44
+ ## Batch first — the anti-flood rule
45
+
46
+ **Never loop a single-item call when N > ~5.** Every hot path has a batch twin
47
+ (sync, explicit ids, ≤1000) and most have a bulk twin (async job, id-list or
48
+ filter-scoped). Pick by N:
49
+
50
+ | doing this per-item? | ≤1000 → sync batch | any size → async bulk (JobHandle) |
51
+ |---------------------------------|---------------------------------------------|------------------------------------|
52
+ | create annotations | `annotations.asset_batch_create` (1 asset) / `annotations.project_batch_create` | `annotations.import_ndjson` |
53
+ | edit/delete annotations | `annotations.batch_edit` (atomic mixed) / `annotations.batch_delete` (≤500 ids) | `project_assets.bulk_delete_annotations` (+class/source predicates) |
54
+ | assign/approve/reject/unassign | `workflow_batch.batch_*` | `workflow_batch.bulk_*` (filter-scoped) |
55
+ | add/remove project assets | `project_assets.batch_add` / `batch_remove` | `project_assets.bulk_add` / `bulk_remove` |
56
+ | tag assets | `tags.batch_update` | `tags.bulk_update` |
57
+ | delete assets | `assets.batch_delete` | `assets.bulk_delete` |
58
+ | upload files | `assets.upload_paths` (does presign+PUT batching for you) | — |
59
+ | predict on many assets | — | `auto_label.create_run` (never a predict loop) |
60
+
61
+ Flood etiquette (the rate buckets in the Limits section are the budget):
62
+ - **Polling**: use the built-in waiters (`JobHandle.wait`, `versions.wait_ready`,
63
+ `training.wait_run` — they poll at ~3s). Don't hand-roll tighter loops; for
64
+ long jobs (training, big imports) pass a larger `poll_interval`.
65
+ - **Counting**: `include_total=True` on one list call — never "iterate and count",
66
+ and never per-item GETs to check existence (list with a filter instead).
67
+ - **Reading many items**: iterate the `Page` (sequential, one request per page at
68
+ the max `limit`) — don't fan out parallel GET-by-id.
69
+ - **Upload concurrency ≤16** on shared/dev tenants; the write bucket is shared
70
+ by everyone on the tenant.
71
+
72
+ ## Recipe 1 — REQUIRED READING: import a COCO dataset end-to-end
73
+
74
+ The full path: upload images → create project with class vocabulary → convert COCO
75
+ GT → bulk-import → verify. Every step below is load-bearing.
76
+
77
+ ### 1a. Upload images (never hand-roll the presign dance)
78
+
79
+ ```python
80
+ from pathlib import Path
81
+ ds = client.datasets.create(name="COCO val2017")
82
+ paths = sorted(Path("/data/val2017").glob("*.jpg"))
83
+ client.assets.upload_paths(ds.id, paths, concurrency=8) # presign→PUT, batched
84
+ # Asset rows are created ASYNCHRONOUSLY by the platform's storage events.
85
+ # Poll until they're all ready:
86
+ import time
87
+ while True:
88
+ ready = client.datasets.stats(ds.id).by_status.get("ready", 0)
89
+ if ready >= len(paths): break
90
+ time.sleep(10)
91
+ asset_by_name = {a.filename: a.id for page in [client.assets.list(ds.id, limit=100)]
92
+ for a in page} # iterate the Page for ALL assets
93
+ ```
94
+
95
+ Keep `concurrency<=16` on shared/dev environments (rate limits are per-tenant).
96
+
97
+ ### 1b. Create the project + class vocabulary
98
+
99
+ One geometry type per class (`allowed_types`). 80 COCO classes = 80 class specs:
100
+
101
+ ```python
102
+ classes = [{"name": c["name"], "color": f"#{hash(c['name']) & 0xffffff:06x}",
103
+ "allowed_types": ["bbox"]} for c in coco["categories"]]
104
+ project = client.projects.create(name="Detection", dataset_id=ds.id,
105
+ scope={"all": True}, classes=classes)
106
+ class_id = {c.name: c.id for c in client.classes.list(project.id).classes}
107
+ ```
108
+
109
+ Keypoint classes additionally need a topology (COCO person = 17 nodes; edges are
110
+ COCO's 1-indexed skeleton converted to 0-indexed pairs):
111
+
112
+ ```python
113
+ KP_NAMES = ["nose","left_eye","right_eye","left_ear","right_ear","left_shoulder",
114
+ "right_shoulder","left_elbow","right_elbow","left_wrist","right_wrist",
115
+ "left_hip","right_hip","left_knee","right_knee","left_ankle","right_ankle"]
116
+ topology = {"version": 1, "nodes": [{"id": i, "name": n} for i, n in enumerate(KP_NAMES)],
117
+ "edges": [[a-1, b-1] for a, b in coco_skeleton_1_indexed]}
118
+ classes = [{"name": "person", "color": "#ff0000", "allowed_types": ["keypoint"],
119
+ "keypoint_topology": topology}]
120
+ ```
121
+
122
+ ### 1c. Convert COCO annotations → platform geometry (ALL THREE KINDS)
123
+
124
+ ```python
125
+ def bbox_geometry(coco_ann): # COCO bbox = [x, y, w, h] pixels
126
+ x, y, w, h = coco_ann["bbox"]
127
+ if w <= 0 or h <= 0: return None # server rejects degenerate boxes
128
+ return {"type": "bbox", "x": x, "y": y, "w": w, "h": h}
129
+
130
+ def polygon_geometry(coco_ann):
131
+ if coco_ann.get("iscrowd"): return None # RLE crowds are NOT convertible — SKIP
132
+ parts = []
133
+ for flat in coco_ann["segmentation"]: # list of flat [x1,y1,x2,y2,...] rings
134
+ pts = list(zip(flat[0::2], flat[1::2]))
135
+ if len(pts) >= 3: # rings need >= 3 vertices
136
+ parts.append({"exterior": pts, "holes": []})
137
+ return {"type": "polygon", "polygons": parts} if parts else None
138
+
139
+ def keypoint_geometry(coco_ann): # [x,y,v] * 17; v in {0,1,2} maps 1:1
140
+ if coco_ann.get("num_keypoints", 0) == 0: return None
141
+ k = coco_ann["keypoints"]
142
+ return {"type": "keypoint",
143
+ "points": [{"x": k[i], "y": k[i+1], "visibility": k[i+2]}
144
+ for i in range(0, len(k), 3)]}
145
+ ```
146
+
147
+ ### 1d. Bulk import (>10k rows → the ASYNC staged path, one call does it all)
148
+
149
+ ```python
150
+ rows = [{"id": str(uuid.uuid5(NS, str(ann["id"]))), # deterministic ids => re-import
151
+ "asset_id": asset_by_name[img_name[ann["image_id"]]], # is an idempotent upsert
152
+ "class_id": class_id[cat_name[ann["category_id"]]],
153
+ "type": "bbox", "geometry": bbox_geometry(ann)}
154
+ for ann in coco["annotations"] if bbox_geometry(ann)]
155
+ job = client.annotations.import_ndjson(project.id, rows, source="imported")
156
+ job.wait(timeout=900)
157
+ total = client.annotations.list(project.id, limit=1, include_total=True).total
158
+ assert total == len(rows)
159
+ ```
160
+
161
+ (≤1000 rows? `client.annotations.project_batch_create(project.id, annotations=rows,
162
+ source="manual")` is the sync path — instant, all-or-nothing.)
163
+
164
+ ## Recipes 2-12 (each maps to docstrings — grep api-map.md for the methods)
165
+
166
+ 2. **Jobs**: kickoff → `handle.wait()`; per-tenant cap is **3 active jobs** —
167
+ serialize embed/train/export, don't parallelize. `ConflictError(JOB_PER_TENANT_CAP)`.
168
+ 3. **Workflow**: `workflow.claim/submit/approve/reject` (single, as the acting user's
169
+ key), `workflow_batch.*` (≤1000 explicit ids), bulk variants return JobHandles.
170
+ Edit-locks: a labeler editing someone else's in-progress asset → 409.
171
+ 4. **Versions**: `versions.create(project_id, name=..., selection=...)` → poll
172
+ `versions.wait_ready(...)` (freeze is an internal job, not in `/jobs`). Browse
173
+ frozen assets + shapes via `versions.assets/asset_detail`.
174
+ 5. **Exports**: `exp = exports.create(project_id, version_id, format=...)`
175
+ (idempotent per version+format+options) → `client.jobs.get(exp.job_id).wait()`
176
+ → `exports.download_to(...)`. `GoneError` = expired/failed → re-create.
177
+ 6. **Search**: `assets.search(dataset_id, parts=[{"type": "text",
178
+ "text": "a red car"}])` — requires embeddings
179
+ (`datasets.embed()` job) AND the GPU search endpoint (see gotchas).
180
+ 7. **SAM segment**: `segment.segment(project_id, asset_id,
181
+ points=[{"x": 100, "y": 200, "label": 1}])` → polygon suggestion; commit it
182
+ as a normal annotation with a class.
183
+ 8. **Training**: `training.catalog()` → `run = training.create_run(...)` (GPU,
184
+ ~minutes to hours; `training.wait_run`) → find YOUR model:
185
+ `model = next(m for m in client.models.list() if m.training_run_id == run.id)`.
186
+ 9. **Deploy + predict**: `deployments.create(model_id)` → poll ready →
187
+ `deployments.predict(deployment_id, image_url=...)` (for a platform asset,
188
+ pass `assets.download_url(...)`; local file → `image_b64`; whole-dataset
189
+ runs → the auto-label job, not a predict loop). An `UnavailableError` with
190
+ code MODEL_LOADING (~15s) / MODEL_STARTING (~60s) = warming — sleep that long
191
+ and retry (the SDK already auto-retries 5xx a couple times).
192
+ 10. **Auto-label**: `auto_label.put_config` → `auto_label.create_run(...)`
193
+ (JobHandle) or per-asset `auto_label.suggest(...)`. Runs never touch human
194
+ annotations.
195
+ 11. **Activity verification**: `activity.project_feed(project_id)` — assert your
196
+ operations produced their actions (bulk ops emit kickoff+completed pairs sharing
197
+ `correlation_id` == job id).
198
+ 12. **Errors**: catch typed exceptions; `RateLimitError` is auto-retried by the SDK;
199
+ `PayloadTooLargeError.hint` names the bulk alternative; `UnprocessableError.details`
200
+ has per-field errors.
201
+
202
+ ## Limits, quotas & concurrency (plan around these, don't discover them)
203
+
204
+ All are per-tenant unless noted. Numbers are the platform's authoritative values.
205
+
206
+ **Rate limits** (token buckets; 429 + `Retry-After`, and the SDK auto-retries):
207
+ - reads ~500/s sustained (burst 1000) · writes ~100/s (burst 200) ·
208
+ upload-init ~100/s (burst 200)
209
+ - shared-GPU inference (semantic search, foundation/ZERO): **30 burst, ~0.5/s
210
+ sustained** — deliberately tight; batch work belongs in jobs, not loops.
211
+
212
+ **Concurrency caps** (409, typed codes):
213
+ - **3 active jobs** (`JOB_PER_TENANT_CAP`) — embed/train/export/bulk compete
214
+ tenant-wide; serialize.
215
+ - 3 live model deployments · auto-label run scope ≤ 20,000 explicit asset ids ·
216
+ **1 active API key per user** (revoke before re-creating; multi-actor work
217
+ needs one key per seeded user).
218
+
219
+ **Resource quotas** (`RESOURCE_LIMIT_EXCEEDED`, 409, checked at create):
220
+ - assets: 1M per tenant AND per dataset · datasets 100 · projects 200
221
+ - per project: versions 100, classes 1,000, members 50
222
+ - per asset: annotations 5,000, comments 200
223
+ - models 100 · **users 50 per workspace — pending invitations count toward it**
224
+
225
+ **Size caps** (413/422):
226
+ - image ≤ 50 MB and ≤ 80 megapixels; > 100 MB objects need multipart (the SDK's
227
+ `upload_paths` handles this)
228
+ - sync batch endpoints: ≤ 1000 items AND ≤ 5 MB body · annotation batch-delete
229
+ ≤ 500 ids · staged NDJSON import: ≤ 500k rows / 256 MB
230
+ - guidelines: 1 MB markdown / 10 MB per image · page `limit` ≤ 100 (a few wide
231
+ list endpoints allow 200)
232
+
233
+ ## Gotchas (cost hours if unknown)
234
+
235
+ - **Every dict-shaped parameter has a TypedDict** in `superb_ai/types/requests.py`
236
+ (`AssetFilterParam`, `MappedAnnotationCreateParam`, `ProjectScopeParam`, …) —
237
+ read that file for the exact keys instead of guessing (e.g. the filename filter
238
+ key is `q`, not `filename`). Plain dict literals still work; the TypedDicts are
239
+ the reference (and a type-checker will validate your keys against them).
240
+ - **Debugging: `export SUPERB_AI_LOG=debug`** — every request logs as
241
+ `METHOD path [request-id] -> status in Nms` plus retry warnings, and the
242
+ bracketed id equals the `request_id` in error envelopes AND in the platform's
243
+ server logs (the SDK sends it as `x-request-id`). Quote it when reporting.
244
+ - **GPU endpoints are SCHEDULED**: search-embedder + SAM run weekdays ~10:00-17:00
245
+ KST and are DELETED outside the window — a 503 `EMBEDDER_UNAVAILABLE` may mean
246
+ *scheduled-off*, not cold-start. Ask the operator to bring them up; don't retry-loop.
247
+ - **Job cap 3 is per-tenant** — your parallel jobs compete with everyone on the tenant.
248
+ - **Sync caps**: batch endpoints cap at 1000 items (413 → use the bulk twin);
249
+ annotation batch-delete caps at 500 ids.
250
+ - **Uploads confirm asynchronously** — S3 PUT success ≠ asset row exists; always poll.
251
+ - **Presigned URLs**: never send your Authorization header to them (different host —
252
+ the SDK's `download_to`/`upload_paths` handle this; don't fetch them with the client).
253
+ - **`/jobs` hides `cleanup_s3_objects`** unless you filter for it explicitly.
254
+ - **Idempotency**: job kickoffs auto-generate an `Idempotency-Key`; pass your own to
255
+ make retries replay (same body) — a REUSED key with a DIFFERENT body is a 409.
256
+ - **Deletes are hard** — no undo. Version/asset/annotation deletes are permanent
257
+ (annotation revision snapshots from past submits remain readable).
@@ -0,0 +1,127 @@
1
+ # Changelog
2
+
3
+ All notable changes to `superb-ai` are documented here, newest first.
4
+
5
+ > **Public versioning starts at 0.1.0** (the first PyPI release — the
6
+ > `[Unreleased]` section below becomes it). Earlier internal, never-published
7
+ > builds were renumbered to 0.0.x when public versioning was set, to keep the
8
+ > history monotonic. 0.1.0 targets the dev environment
9
+ > (`api.bdai.dev.superb-ai.com`) for the BDAI hackathon; 0.2.0 will move to
10
+ > production + the workspace vocabulary rename.
11
+
12
+ Format: [Keep a Changelog 1.1](https://keepachangelog.com/en/1.1.0/); versioning:
13
+ [SemVer](https://semver.org/) with 0.x semantics — **minor releases may break**
14
+ (each breaking entry carries a migration note), patch releases never do. Entries
15
+ reference ADRs (the platform's decision records) rather than commits. Maintained
16
+ in lockstep: a change that alters the SDK surface adds its line under
17
+ `[Unreleased]` in the same change; a release renames that section.
18
+
19
+ ## [0.1.0] - 2026-07-10
20
+
21
+ ### Breaking
22
+
23
+ - **Account-first auth (ADR-0113).** `auth.authorize`/`callback`/`refresh`/
24
+ `logout` moved to the API root and are account-level: `authorize` no longer
25
+ scopes to the tenant's organization (new optional `state=` passthrough),
26
+ `callback` returns plain `AuthTokens` (no tenant context exists at login),
27
+ and `auth.exchange_code`/`SessionTokens` are removed — the root callback IS
28
+ the only callback now. Migration: exchange the code, then route via the new
29
+ `account` namespace.
30
+ - `users.invite` is gone. Split: `users.create(email=, first_name=,
31
+ last_name=, password=, role=)` — the programmatic-seeding path (creates a
32
+ ready-to-login account, no email) — and `invitations.create(email=, role=)`
33
+ for human invites (the invitee accepts in-app via `account`).
34
+ - `tenants.create` is now OPERATOR-only (ADR-0116): pass `bootstrap_secret=`
35
+ (or set `SUPERB_AI_BOOTSTRAP_SECRET`) — without the deployment's secret the
36
+ endpoint 404s (fail-closed). Regular users create workspaces in-app via
37
+ `account.create_tenant` after signing up.
38
+
39
+ ### Added
40
+
41
+ - `account` namespace (JWT sessions only): `tenants()`, `create_tenant(name=,
42
+ slug=)`, `invitations()`, `accept_invitation(id)`, `decline_invitation(id)`
43
+ — the cross-workspace view of the signed-in account.
44
+ - `invitations` namespace (admin): `create` (returns the copyable
45
+ `accept_url`), `list(status=)`, `revoke`.
46
+ - `users.leave()` (leave this workspace) and `users.remove(user_id)` (admin
47
+ removes a member); both guarded against removing the last admin
48
+ (`LAST_ADMIN`).
49
+ - New error codes mirrored: `INVITATION_NOT_FOUND/PENDING/NOT_PENDING/EXPIRED`,
50
+ `LAST_ADMIN`.
51
+
52
+ - `jobs.list(project_id=...)` — filter jobs to one project, mirroring the new
53
+ server filter (ADR-0111). Server-side in the same change: project-scoped job
54
+ targets now carry `dataset_id`, so `jobs.list(dataset_id=...)` also returns
55
+ auto-label / project-bulk / export / version-manifest jobs (it silently
56
+ missed them before).
57
+ - **Negative filter twins (ADR-0115)** on every `ProjectFilter` surface:
58
+ `tags_none` (carries NONE of the listed tags), `classes_none` (no annotation
59
+ of any listed class), `status_not` (exclude listed statuses), and the
60
+ `assigned`/`tagged` tri-states. Compose with the positive fields by AND —
61
+ `tags=["reviewed"], tags_none=["blurry"]` = "all of these, except those".
62
+ Same value on both sides of a pair → 400/422 (contradiction). Available as
63
+ kwargs on `workflow.list_asset_states` and `versions.list_assets`
64
+ (`tags_none`/`tagged`/`classes_none` only — workflow state isn't frozen),
65
+ and as `ProjectFilterParam` keys everywhere a filter body is accepted
66
+ (bulk ops, tag summary, version selection).
67
+
68
+ ## [0.0.3] - 2026-07-07 (internal)
69
+
70
+ ### Added
71
+
72
+ - `tenant` falls back to the `SUPERB_AI_TENANT` environment variable when omitted,
73
+ mirroring `api_key`/`base_url` — so `Client()` with no args works when both env
74
+ vars are set (agents can be told "key and tenant are in the env"). Found by
75
+ dogfooding the starter kit with an AI agent (shko@superb-ai.com).
76
+
77
+ ### Fixed
78
+
79
+ - `examples/team_quickstart.py` docstring implied a `SUPERB_AI_TENANT` env var that
80
+ nothing read while the body hardcoded the slug — now uses `Client()` + the env var.
81
+
82
+ ## [0.0.2] - 2026-07-06 (internal)
83
+
84
+ ### Breaking
85
+
86
+ - Removed `deployments.predict_batch` and `foundation.predict_batch`, and the
87
+ `s3_key` image source on both `predict` methods (ADR-0106). The endpoints were
88
+ unreachable by construction (asset rows never expose bucket keys). Migration:
89
+ single predict with `image_url=assets.download_url(...).url` (platform assets)
90
+ or `image_b64` (local bytes); whole-dataset inference is the `auto_label` job.
91
+ - `training.list_runs` now returns `Page[TrainingRun]` (cursor-paginated, was a
92
+ plain `list`). Migration: iterate the page (`for r in ...` — auto-fetches all
93
+ pages) instead of indexing; `limit=`/`cursor=` are now honored.
94
+
95
+ ### Added
96
+
97
+ - Typed request params (ADR-0107): every dict-shaped parameter has a `*Param`
98
+ TypedDict in `superb_ai.types.requests` (filters, scope/selection, geometry,
99
+ annotation rows, ontology specs, tag config, search parts, anchors, upload
100
+ items, SAM points, foundation refs, training split). Dict literals are
101
+ unchanged at runtime and now type-check; closed-vocabulary keys are `Literal`
102
+ values. Gates G5/G5b pin keys and values to the server's schemas.
103
+ - Debug logging: `SUPERB_AI_LOG=debug|info` (or the `superb_ai` logger) emits
104
+ `METHOD path [request-id] -> status in Nms` per request plus retry warnings.
105
+ - Request correlation: every request sends a client-minted `x-request-id`; the
106
+ server threads it into its logs and error envelopes, so the bracketed id in
107
+ SDK logs equals `APIError.request_id` equals the server-side log entry.
108
+ - `User-Agent: superb-ai-sdk/<version> python/<ver> httpx/<ver>` on every
109
+ request (version attribution in server logs).
110
+
111
+ ### Fixed
112
+
113
+ - Docstring corrections from the autonomous validation run: `AssetFilter`'s
114
+ filename key is `q` (not `filename`); comment anchor coords are normalized
115
+ image fractions (not pixels); `workflow.assign` leaves status `to_label`
116
+ until the assignee `claim`s (contrast `batch_assign`). `datasets.embed`'s
117
+ coarse progress reporting documented.
118
+
119
+ ## [0.0.1] - 2026-07-05 (internal)
120
+
121
+ Initial build (ADR-0105). Hand-written OpenAI/Anthropic-style client: sync +
122
+ async twins, 29 resource namespaces / 153 operations, `Page[T]` auto-pagination,
123
+ `JobHandle.wait()`, 11-class typed error taxonomy + 56-code `ErrorCode` mirror,
124
+ jittered retries honoring `Retry-After`, auto `Idempotency-Key` on job kickoffs,
125
+ presigned-upload toolkit. Python >= 3.12; runtime deps `httpx` + `pydantic`
126
+ only. Validated by an autonomous agent driving the full platform (5k-image COCO
127
+ seed, every namespace) with zero SDK defects.
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,24 @@
1
+ Metadata-Version: 2.4
2
+ Name: superb-ai
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for Superb AI — datasets, labeling, versions, training, and deployments.
5
+ Project-URL: Homepage, https://github.com/Superb-AI-Suite/superb-ai-python
6
+ Project-URL: Repository, https://github.com/Superb-AI-Suite/superb-ai-python
7
+ Project-URL: Changelog, https://github.com/Superb-AI-Suite/superb-ai-python/blob/main/CHANGELOG.md
8
+ Author: Superb AI
9
+ License: Apache-2.0
10
+ License-File: LICENSE
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Classifier: Typing :: Typed
17
+ Requires-Python: >=3.12
18
+ Requires-Dist: httpx<1,>=0.27
19
+ Requires-Dist: pydantic<3,>=2.7
20
+ Description-Content-Type: text/markdown
21
+
22
+ # superb-ai
23
+
24
+ Official Python SDK for Superb AI. Docs: AGENTS.md (agents), api-map.md (index).
@@ -0,0 +1,3 @@
1
+ # superb-ai
2
+
3
+ Official Python SDK for Superb AI. Docs: AGENTS.md (agents), api-map.md (index).