sdcmodeler 4.4.0__tar.gz → 4.5.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.
- sdcmodeler-4.5.0/PKG-INFO +241 -0
- sdcmodeler-4.5.0/README.md +215 -0
- {sdcmodeler-4.4.0 → sdcmodeler-4.5.0}/pyproject.toml +1 -1
- {sdcmodeler-4.4.0 → sdcmodeler-4.5.0}/src/sdcmodeler/__init__.py +1 -1
- {sdcmodeler-4.4.0 → sdcmodeler-4.5.0}/src/sdcmodeler/cli.py +58 -4
- {sdcmodeler-4.4.0 → sdcmodeler-4.5.0}/src/sdcmodeler/client.py +45 -7
- sdcmodeler-4.5.0/src/sdcmodeler/deliver.py +309 -0
- {sdcmodeler-4.4.0 → sdcmodeler-4.5.0}/src/sdcmodeler/kits.py +2 -2
- {sdcmodeler-4.4.0 → sdcmodeler-4.5.0}/src/sdcmodeler/mcp_server.py +142 -13
- {sdcmodeler-4.4.0 → sdcmodeler-4.5.0}/src/sdcmodeler/pricing.py +20 -4
- sdcmodeler-4.5.0/src/sdcmodeler.egg-info/PKG-INFO +241 -0
- {sdcmodeler-4.4.0 → sdcmodeler-4.5.0}/src/sdcmodeler.egg-info/SOURCES.txt +3 -0
- sdcmodeler-4.5.0/tests/test_deliver.py +210 -0
- sdcmodeler-4.5.0/tests/test_deliver_server.py +234 -0
- {sdcmodeler-4.4.0 → sdcmodeler-4.5.0}/tests/test_kits.py +10 -3
- {sdcmodeler-4.4.0 → sdcmodeler-4.5.0}/tests/test_mcp_server.py +1 -1
- sdcmodeler-4.4.0/PKG-INFO +0 -135
- sdcmodeler-4.4.0/README.md +0 -109
- sdcmodeler-4.4.0/src/sdcmodeler.egg-info/PKG-INFO +0 -135
- {sdcmodeler-4.4.0 → sdcmodeler-4.5.0}/LICENSE +0 -0
- {sdcmodeler-4.4.0 → sdcmodeler-4.5.0}/setup.cfg +0 -0
- {sdcmodeler-4.4.0 → sdcmodeler-4.5.0}/src/sdcmodeler.egg-info/dependency_links.txt +0 -0
- {sdcmodeler-4.4.0 → sdcmodeler-4.5.0}/src/sdcmodeler.egg-info/entry_points.txt +0 -0
- {sdcmodeler-4.4.0 → sdcmodeler-4.5.0}/src/sdcmodeler.egg-info/requires.txt +0 -0
- {sdcmodeler-4.4.0 → sdcmodeler-4.5.0}/src/sdcmodeler.egg-info/top_level.txt +0 -0
- {sdcmodeler-4.4.0 → sdcmodeler-4.5.0}/tests/test_cli.py +0 -0
- {sdcmodeler-4.4.0 → sdcmodeler-4.5.0}/tests/test_client.py +0 -0
- {sdcmodeler-4.4.0 → sdcmodeler-4.5.0}/tests/test_pricing.py +0 -0
- {sdcmodeler-4.4.0 → sdcmodeler-4.5.0}/tests/test_registry_launch.py +0 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sdcmodeler
|
|
3
|
+
Version: 4.5.0
|
|
4
|
+
Summary: The modeler's client for SDCStudio: search the catalog, estimate, assemble and publish SDC4 data models, generate applications; a CLI and an MCP server over one client
|
|
5
|
+
Author: Axius SDC, Inc.
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Repository, https://github.com/Axius-SDC/sdcmodeler
|
|
8
|
+
Project-URL: Documentation, https://axius-sdc.com/docs/
|
|
9
|
+
Project-URL: Issues, https://github.com/Axius-SDC/sdcmodeler/issues
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: httpx>=0.27
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
24
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
# sdcmodeler
|
|
28
|
+
|
|
29
|
+
<!-- mcp-name: io.github.Axius-SDC/sdcmodeler -->
|
|
30
|
+
|
|
31
|
+
**The modeler's client for SDCStudio.** Search the public catalog, estimate, assemble and publish an SDC4 data model, generate its package and an application. A Python client with httpx as its only dependency, a CLI, and `sdcmodeler mcp`, an MCP server for any agent.
|
|
32
|
+
|
|
33
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
34
|
+
[](https://www.python.org/downloads/)
|
|
35
|
+
|
|
36
|
+
## Why
|
|
37
|
+
|
|
38
|
+
An agent that builds a feature decides a data model at that moment. With sdcmodeler the data is modeled in SDC by default: the agent searches the catalog first, reuses published components wherever one fits, mints only what is new, publishes the model, and takes the package. The result is interoperable because it is composed from shared, published components, and verifiable because every record validates against a published schema.
|
|
39
|
+
|
|
40
|
+
The name follows the role pattern of the other Semantic Data Charter servers: sdcvalidator validates, sdcgovernance governs, sdcreader reads, sdcmodeler models. It also names what SDCStudio calls every user: a Modeler.
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install sdcmodeler
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The catalog and estimates need no account. Building needs an SDCStudio API key, created in Settings, API Keys, with the scopes and spending limit the holder should have:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
export SDCSTUDIO_API_KEY=sdcs_...
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## The three layers
|
|
55
|
+
|
|
56
|
+
### The client
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from sdcmodeler import SDCStudioClient
|
|
60
|
+
|
|
61
|
+
c = SDCStudioClient() # key from $SDCSTUDIO_API_KEY, URL from $SDCSTUDIO_URL
|
|
62
|
+
hits = c.search_components("blood pressure", type="xdquantity")
|
|
63
|
+
tree = {
|
|
64
|
+
"label": "Vitals",
|
|
65
|
+
"components": [
|
|
66
|
+
{"ct_id": hits["results"][0]["ct_id"]}, # reuse: free
|
|
67
|
+
{"label": "Pulse", "data_type": "XdCount"}, # mint: 100 credits
|
|
68
|
+
],
|
|
69
|
+
"clusters": [],
|
|
70
|
+
}
|
|
71
|
+
estimate = c.estimate(tree, "Vitals") # the server's estimate: reuse, mint, problems, total_credits, wallet, key, estimate_id
|
|
72
|
+
result = c.assemble("Vitals", tree, estimate_id=estimate["estimate_id"]) # 500 credits plus the mints
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Every leaf existing: the server assembles, publishes and generates the package in one call (`result["mode"] == "reuse"`; `published` and `generated` say so). Some leaves new: the pipeline runs and `result["job_ct_id"]` is polled with `c.job_status(...)`, or `c.wait_for_job(...)`, until `completed`, when the job has published and generated as asked and its result carries the model's links. `publish=False` leaves a draft for a person to review. The server refuses a build whose tree changed since the estimate.
|
|
76
|
+
|
|
77
|
+
A 402 is `InsufficientCredits` with the numbers in credits. A 403 from the key's policy (no `spend` scope, or past its limit) is `KeyPolicyRefused`. The client never funds a wallet; a person does that at the wallet page.
|
|
78
|
+
|
|
79
|
+
### The CLI
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
sdcmodeler search "blood pressure" --type xdquantity
|
|
83
|
+
sdcmodeler models "patient"
|
|
84
|
+
sdcmodeler model <ct_id>
|
|
85
|
+
sdcmodeler artifact <ct_id> xsd --dir ./schemas
|
|
86
|
+
sdcmodeler estimate tree.json --title "Vitals"
|
|
87
|
+
sdcmodeler build tree.json --title "Vitals" --wait
|
|
88
|
+
sdcmodeler job <job_ct_id>
|
|
89
|
+
sdcmodeler package <ct_id> --dir ./packages
|
|
90
|
+
sdcmodeler app <ct_id> --profile lightweight --dir ./apps
|
|
91
|
+
sdcmodeler kit <ct_id> --project ./my-app
|
|
92
|
+
sdcmodeler ship tree.json --title "Vitals" --deliver package,kit --project ./my-app
|
|
93
|
+
sdcmodeler wallet
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### The MCP server
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
sdcmodeler mcp
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
A JSON-RPC 2.0 stdio server, no SDK, the way sdcvalidator and sdcgovernance are built. A client configuration needs only:
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
{"command": "uvx", "args": ["sdcmodeler", "mcp"], "env": {"SDCSTUDIO_API_KEY": "sdcs_..."}}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
| Tool | Does | Spends |
|
|
109
|
+
|---|---|---|
|
|
110
|
+
| `search_components` | published components by label, type and project: with a key your own first (private included, `scope: mine`), then the public catalog | no |
|
|
111
|
+
| `list_models`, `get_model` | published models and their artifact routes | no |
|
|
112
|
+
| `estimate_model` | what a tree would reuse, mint and cost; returns `estimate_id`; with `deliver`, the whole run's total and whether the wallet and the key can pay it | no |
|
|
113
|
+
| `build_model` | assemble, publish and generate (or `publish: false` for a draft); needs the `estimate_id` the person saw; refuses past the key's limit | yes |
|
|
114
|
+
| `job_status` | one job by id: status, step, cost so far, the model's links | no |
|
|
115
|
+
| `download_package` | a model's package ZIP with the key, including a model in a private project; builds a missing package first (free, once) unless `generate` is false | no |
|
|
116
|
+
| `generate_app` | generate and download the application; needs `confirm_charge`; 1,500 credits the first time, free after | yes |
|
|
117
|
+
| `add_supabase_kit` | write a model's Supabase kit into a project (`project_dir`); needs `confirm_charge`; charged with the application, once per model | yes |
|
|
118
|
+
| `build_and_deliver` | one run: build, publish, wait, then deliver the package, application or kit; needs the `estimate_id` returned with the same `deliver`; refuses before building when the total cannot be paid | yes |
|
|
119
|
+
| `wallet` | balance in credits and the key's policy | no |
|
|
120
|
+
|
|
121
|
+
**The policy lives in the server.** No spend without an estimate shown: `build_model` takes the `estimate_id` that `estimate_model` returned for the same title and tree in this process. Stop at the key's limit: a build whose estimate exceeds what the key may still spend is refused before the server is asked. Never pay: a 402 is reported with the wallet page's address and the tool stops. One approval per run: `build_and_deliver` follows the run's total the person saw, which covers the application or kit charge, so it needs no `confirm_charge`. No tool takes a URL, a key or a payment method as an argument; the key is the environment the server starts with.
|
|
122
|
+
|
|
123
|
+
## The package or the application
|
|
124
|
+
|
|
125
|
+
`get_model` names the artifacts: the XSD 1.1 schema, the instance template, JSON, JSON-LD, SHACL, HTML, GraphQL. The package is a contract with no runtime attached; a feature inside an existing application implements on it, in any language, validating every record locally with [sdcvalidator](https://pypi.org/project/sdcvalidator/). The generated application (lightweight or enterprise profile) is a Django implementation on the same package, right when the feature is a new service. The Supabase kit is the same for a TypeScript app on Supabase: typed code for the model's records, migrations, and a gate (an Edge Function) that validates every record against the published model before storing it. `sdcmodeler kit` and `add_supabase_kit` write it into the project: the first model brings the project base, each further one adds its kit and one migration, numbered after the project's latest, and a component already in the project is never rewritten. Apply with Supabase's CLI (`supabase db push`, `supabase functions deploy gate`). [CordovaOS](https://github.com/Axius-SDC/CordovaOS) is ten of them sharing data with zero integration code.
|
|
126
|
+
|
|
127
|
+
## Walkthrough for an SDCStudio team
|
|
128
|
+
|
|
129
|
+
### Set up once
|
|
130
|
+
|
|
131
|
+
The account holder does this in SDCStudio at [sdcstudio.axius-sdc.com](https://sdcstudio.axius-sdc.com); each developer then installs the package and exports their key.
|
|
132
|
+
|
|
133
|
+
1. Fund the wallet. Building is paid in credits, 1,000 to the dollar. sdcmodeler never adds funds; a person does that at the wallet page.
|
|
134
|
+
2. Create one API key per developer or agent in Settings, API Keys. Without the `spend` scope a key can search, estimate, read models and download packages. With it, the key's spending limit caps what that holder may spend.
|
|
135
|
+
3. Check a key at any time with `sdcmodeler wallet`: the balance and that key's policy.
|
|
136
|
+
|
|
137
|
+
On an SDCStudio deployment with the build-and-deliver release, three more settings decide how far an agent goes without asking. A signed-in person makes all three; a key can spend within them and can never change them:
|
|
138
|
+
|
|
139
|
+
- **Auto-spend on the key.** The agent runs `build_and_deliver` without a person approving each estimate. A spending limit stays optional: with none, the agent spends in the wallet's reload amounts, under the monthly maximum below.
|
|
140
|
+
- **Auto-reload on the wallet, confirmed.** When a run needs more than the balance, SDCStudio tops the wallet up from the saved card, in the configured amount, before anything is published. A key may trigger a reload only after the person has confirmed auto-reload, and the person gets one email per reload a key triggers.
|
|
141
|
+
- **A monthly auto-reload maximum.** The most auto-reload adds in a calendar month. A wallet's first funding sets it to four times that amount, and sets the reload amount to the amount itself ($10 funded: $10 reloads, at most $40 a month).
|
|
142
|
+
|
|
143
|
+
| Key | Auto-reload | A run |
|
|
144
|
+
|---|---|---|
|
|
145
|
+
| no `spend` | any | searches, estimates, reads models, downloads packages; no charge |
|
|
146
|
+
| `spend` | off | the person approves each estimate; a short balance stops it before anything is published |
|
|
147
|
+
| `spend` | confirmed | the person approves each estimate; a short balance is topped up first |
|
|
148
|
+
| `spend` + auto-spend | off | no per-run approval; a short balance stops it before anything is published |
|
|
149
|
+
| `spend` + auto-spend | confirmed | no per-run approval; a short balance is topped up first, within the monthly maximum |
|
|
150
|
+
|
|
151
|
+
Organization wallets never auto-reload; the organization's admin sets each member's limit.
|
|
152
|
+
|
|
153
|
+
### With a coding agent
|
|
154
|
+
|
|
155
|
+
Add the MCP configuration above to the agent. A typical session, for a developer adding a vitals form to a clinic app:
|
|
156
|
+
|
|
157
|
+
1. The developer asks: "Add a form to record blood pressure and pulse."
|
|
158
|
+
2. The agent calls `search_components` and finds a published blood pressure component.
|
|
159
|
+
3. It drafts a tree that reuses that component and mints a new Pulse count, then calls `estimate_model`.
|
|
160
|
+
4. It shows the developer the estimate: one component reused, one minted, the total in credits.
|
|
161
|
+
5. The developer approves. The agent calls `build_model` with that `estimate_id`, follows `job_status` if a job runs, then calls `download_package` or `add_supabase_kit`.
|
|
162
|
+
6. The agent writes the feature against the published model.
|
|
163
|
+
|
|
164
|
+
The agent cannot skip step 4: `build_model` refuses without the `estimate_id` returned for the same title and tree in the same session.
|
|
165
|
+
|
|
166
|
+
### With the CLI
|
|
167
|
+
|
|
168
|
+
The one piece written by hand is the tree. A component with a `ct_id` is reused; one with a `label` and an SDC4 `data_type` (such as `XdString`, `XdCount`, `XdQuantity` or `XdTemporal`) is minted. Clusters group components and nest.
|
|
169
|
+
|
|
170
|
+
```json
|
|
171
|
+
{
|
|
172
|
+
"label": "Vitals",
|
|
173
|
+
"components": [
|
|
174
|
+
{"ct_id": "<ct_id from search>"},
|
|
175
|
+
{"label": "Pulse", "data_type": "XdCount"}
|
|
176
|
+
],
|
|
177
|
+
"clusters": []
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
sdcmodeler search "blood pressure" --type xdquantity
|
|
183
|
+
sdcmodeler estimate tree.json --title "Vitals"
|
|
184
|
+
sdcmodeler build tree.json --title "Vitals" --estimate-id <id> --wait
|
|
185
|
+
sdcmodeler package <ct_id> --dir ./packages
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Builds land in the Modeler's default project, created on first use if there is none.
|
|
189
|
+
|
|
190
|
+
### In one run
|
|
191
|
+
|
|
192
|
+
`ship` (CLI) and `build_and_deliver` (MCP) do the whole path after one approval: build, publish every new component and the model into the Modeler's private default project, wait for the job, then deliver.
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
sdcmodeler ship tree.json --title "Vitals" --deliver package,kit --project ./my-app --plan # the total; nothing spent
|
|
196
|
+
sdcmodeler ship tree.json --title "Vitals" --deliver package,kit --project ./my-app # asks once, then runs
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
The total covers the build and the deliverables: 1,500 credits once when they include an application or a kit, since one charge covers both. A run the wallet or the key cannot pay is refused before anything is built. Once the model is published, a deliverable that fails is reported under `failed`, the others still run, and `ship` exits 2; fetch the failed one with its own command. `--yes` approves without the prompt, for scripts.
|
|
200
|
+
|
|
201
|
+
On a deployment with the build-and-deliver release, SDCStudio does the run itself: it funds and holds the whole total before the first publish (a reload included, when the person allows one), delivers each item from the hold, and sdcmodeler downloads what is ready and writes the kit. On an older deployment sdcmodeler composes the run from the calls it already has. Which one is decided by what the server's estimate answers, never by a setting. With an auto-spend key, `build_and_deliver` needs no prior estimate and returns the estimate in its result; `ship` still asks at the terminal unless `--yes`.
|
|
202
|
+
|
|
203
|
+
The deliverables can live in the agent's settings instead of each call: `SDCMODELER_DELIVER` (for example `package,kit`), `SDCMODELER_OUTPUT_DIR` for the package and application, and `SDCMODELER_PROJECT_DIR` for the kit, in the environment of the CLI or of the MCP server's configuration.
|
|
204
|
+
|
|
205
|
+
### What it costs
|
|
206
|
+
|
|
207
|
+
Reuse is free, so the cheapest model is the one built most from published components. The Vitals tree costs 600 credits ($0.60): 500 to assemble, 100 to mint Pulse.
|
|
208
|
+
|
|
209
|
+
| Action | Credits | USD |
|
|
210
|
+
|---|---|---|
|
|
211
|
+
| Search, estimate, read models, download a package | 0 | $0.00 |
|
|
212
|
+
| Reuse a published component | 0 | $0.00 |
|
|
213
|
+
| Mint a component, or a new cluster below the root | 100 each | $0.10 |
|
|
214
|
+
| Assemble a model (covers its root cluster) | 500 | $0.50 |
|
|
215
|
+
| Generate an application or Supabase kit, first time per user per model | 1,500 | $1.50 |
|
|
216
|
+
|
|
217
|
+
### Review before publishing
|
|
218
|
+
|
|
219
|
+
Publishing locks a model permanently; that is what lets every Governed Data Record keep validating against the schema it was made for. A team with a data steward builds drafts (`--draft`, `publish: false` in `build_model`, or `publish=False` in the client), the steward reviews and publishes in SDCStudio, and the developer then takes the package, application or kit as usual.
|
|
220
|
+
|
|
221
|
+
### When a call is refused
|
|
222
|
+
|
|
223
|
+
| You see | It means | Do this |
|
|
224
|
+
|---|---|---|
|
|
225
|
+
| 402, `InsufficientCredits` | The wallet cannot cover the build; cost and balance are reported in credits. A run also says why (`reason`): `auto_reload_off`, `no_card`, `auto_reload_unconfirmed`, `ceiling`, `declined`, `reload_failed`, `organization_wallet`, `insufficient_funds`. Nothing was published or charged | Add funds at the wallet page, or fix what the reason names (turn on or confirm auto-reload, save or update the card, raise the monthly maximum, ask the organization admin), then run again |
|
|
226
|
+
| 403, `KeyPolicyRefused` | The key lacks a scope the call needs, or is past its spending limit | Ask the account holder to adjust the key |
|
|
227
|
+
| 409, stale estimate (`AssemblyRefused`) | The tree changed after the estimate | Estimate again and build with the new id |
|
|
228
|
+
| 409, retired component (`AssemblyRefused`) | The tree reuses a retired component | Search for its replacement and update the tree |
|
|
229
|
+
| Problems in the estimate | A component needs a `ct_id`, or a `label` and `data_type`; a cluster needs a label | Fix the tree; nothing was built |
|
|
230
|
+
|
|
231
|
+
## What is not here
|
|
232
|
+
|
|
233
|
+
Validation (sdcvalidator's server), governance (sdcgovernance's), receipt verification (sdcreceipt's) and bringing existing data across (sdc-agents) are their own registered servers. sdcmodeler composes with them; it does not re-implement them.
|
|
234
|
+
|
|
235
|
+
## Release
|
|
236
|
+
|
|
237
|
+
Two steps: merge to `main`, then push the tag `v<version>` matching `pyproject.toml`. `release.yml` runs the tests, builds, publishes to PyPI by trusted publisher and to the MCP registry.
|
|
238
|
+
|
|
239
|
+
## License
|
|
240
|
+
|
|
241
|
+
Apache License 2.0. Copyright Axius SDC, Inc.
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# sdcmodeler
|
|
2
|
+
|
|
3
|
+
<!-- mcp-name: io.github.Axius-SDC/sdcmodeler -->
|
|
4
|
+
|
|
5
|
+
**The modeler's client for SDCStudio.** Search the public catalog, estimate, assemble and publish an SDC4 data model, generate its package and an application. A Python client with httpx as its only dependency, a CLI, and `sdcmodeler mcp`, an MCP server for any agent.
|
|
6
|
+
|
|
7
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
8
|
+
[](https://www.python.org/downloads/)
|
|
9
|
+
|
|
10
|
+
## Why
|
|
11
|
+
|
|
12
|
+
An agent that builds a feature decides a data model at that moment. With sdcmodeler the data is modeled in SDC by default: the agent searches the catalog first, reuses published components wherever one fits, mints only what is new, publishes the model, and takes the package. The result is interoperable because it is composed from shared, published components, and verifiable because every record validates against a published schema.
|
|
13
|
+
|
|
14
|
+
The name follows the role pattern of the other Semantic Data Charter servers: sdcvalidator validates, sdcgovernance governs, sdcreader reads, sdcmodeler models. It also names what SDCStudio calls every user: a Modeler.
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install sdcmodeler
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The catalog and estimates need no account. Building needs an SDCStudio API key, created in Settings, API Keys, with the scopes and spending limit the holder should have:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
export SDCSTUDIO_API_KEY=sdcs_...
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## The three layers
|
|
29
|
+
|
|
30
|
+
### The client
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from sdcmodeler import SDCStudioClient
|
|
34
|
+
|
|
35
|
+
c = SDCStudioClient() # key from $SDCSTUDIO_API_KEY, URL from $SDCSTUDIO_URL
|
|
36
|
+
hits = c.search_components("blood pressure", type="xdquantity")
|
|
37
|
+
tree = {
|
|
38
|
+
"label": "Vitals",
|
|
39
|
+
"components": [
|
|
40
|
+
{"ct_id": hits["results"][0]["ct_id"]}, # reuse: free
|
|
41
|
+
{"label": "Pulse", "data_type": "XdCount"}, # mint: 100 credits
|
|
42
|
+
],
|
|
43
|
+
"clusters": [],
|
|
44
|
+
}
|
|
45
|
+
estimate = c.estimate(tree, "Vitals") # the server's estimate: reuse, mint, problems, total_credits, wallet, key, estimate_id
|
|
46
|
+
result = c.assemble("Vitals", tree, estimate_id=estimate["estimate_id"]) # 500 credits plus the mints
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Every leaf existing: the server assembles, publishes and generates the package in one call (`result["mode"] == "reuse"`; `published` and `generated` say so). Some leaves new: the pipeline runs and `result["job_ct_id"]` is polled with `c.job_status(...)`, or `c.wait_for_job(...)`, until `completed`, when the job has published and generated as asked and its result carries the model's links. `publish=False` leaves a draft for a person to review. The server refuses a build whose tree changed since the estimate.
|
|
50
|
+
|
|
51
|
+
A 402 is `InsufficientCredits` with the numbers in credits. A 403 from the key's policy (no `spend` scope, or past its limit) is `KeyPolicyRefused`. The client never funds a wallet; a person does that at the wallet page.
|
|
52
|
+
|
|
53
|
+
### The CLI
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
sdcmodeler search "blood pressure" --type xdquantity
|
|
57
|
+
sdcmodeler models "patient"
|
|
58
|
+
sdcmodeler model <ct_id>
|
|
59
|
+
sdcmodeler artifact <ct_id> xsd --dir ./schemas
|
|
60
|
+
sdcmodeler estimate tree.json --title "Vitals"
|
|
61
|
+
sdcmodeler build tree.json --title "Vitals" --wait
|
|
62
|
+
sdcmodeler job <job_ct_id>
|
|
63
|
+
sdcmodeler package <ct_id> --dir ./packages
|
|
64
|
+
sdcmodeler app <ct_id> --profile lightweight --dir ./apps
|
|
65
|
+
sdcmodeler kit <ct_id> --project ./my-app
|
|
66
|
+
sdcmodeler ship tree.json --title "Vitals" --deliver package,kit --project ./my-app
|
|
67
|
+
sdcmodeler wallet
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### The MCP server
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
sdcmodeler mcp
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
A JSON-RPC 2.0 stdio server, no SDK, the way sdcvalidator and sdcgovernance are built. A client configuration needs only:
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{"command": "uvx", "args": ["sdcmodeler", "mcp"], "env": {"SDCSTUDIO_API_KEY": "sdcs_..."}}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
| Tool | Does | Spends |
|
|
83
|
+
|---|---|---|
|
|
84
|
+
| `search_components` | published components by label, type and project: with a key your own first (private included, `scope: mine`), then the public catalog | no |
|
|
85
|
+
| `list_models`, `get_model` | published models and their artifact routes | no |
|
|
86
|
+
| `estimate_model` | what a tree would reuse, mint and cost; returns `estimate_id`; with `deliver`, the whole run's total and whether the wallet and the key can pay it | no |
|
|
87
|
+
| `build_model` | assemble, publish and generate (or `publish: false` for a draft); needs the `estimate_id` the person saw; refuses past the key's limit | yes |
|
|
88
|
+
| `job_status` | one job by id: status, step, cost so far, the model's links | no |
|
|
89
|
+
| `download_package` | a model's package ZIP with the key, including a model in a private project; builds a missing package first (free, once) unless `generate` is false | no |
|
|
90
|
+
| `generate_app` | generate and download the application; needs `confirm_charge`; 1,500 credits the first time, free after | yes |
|
|
91
|
+
| `add_supabase_kit` | write a model's Supabase kit into a project (`project_dir`); needs `confirm_charge`; charged with the application, once per model | yes |
|
|
92
|
+
| `build_and_deliver` | one run: build, publish, wait, then deliver the package, application or kit; needs the `estimate_id` returned with the same `deliver`; refuses before building when the total cannot be paid | yes |
|
|
93
|
+
| `wallet` | balance in credits and the key's policy | no |
|
|
94
|
+
|
|
95
|
+
**The policy lives in the server.** No spend without an estimate shown: `build_model` takes the `estimate_id` that `estimate_model` returned for the same title and tree in this process. Stop at the key's limit: a build whose estimate exceeds what the key may still spend is refused before the server is asked. Never pay: a 402 is reported with the wallet page's address and the tool stops. One approval per run: `build_and_deliver` follows the run's total the person saw, which covers the application or kit charge, so it needs no `confirm_charge`. No tool takes a URL, a key or a payment method as an argument; the key is the environment the server starts with.
|
|
96
|
+
|
|
97
|
+
## The package or the application
|
|
98
|
+
|
|
99
|
+
`get_model` names the artifacts: the XSD 1.1 schema, the instance template, JSON, JSON-LD, SHACL, HTML, GraphQL. The package is a contract with no runtime attached; a feature inside an existing application implements on it, in any language, validating every record locally with [sdcvalidator](https://pypi.org/project/sdcvalidator/). The generated application (lightweight or enterprise profile) is a Django implementation on the same package, right when the feature is a new service. The Supabase kit is the same for a TypeScript app on Supabase: typed code for the model's records, migrations, and a gate (an Edge Function) that validates every record against the published model before storing it. `sdcmodeler kit` and `add_supabase_kit` write it into the project: the first model brings the project base, each further one adds its kit and one migration, numbered after the project's latest, and a component already in the project is never rewritten. Apply with Supabase's CLI (`supabase db push`, `supabase functions deploy gate`). [CordovaOS](https://github.com/Axius-SDC/CordovaOS) is ten of them sharing data with zero integration code.
|
|
100
|
+
|
|
101
|
+
## Walkthrough for an SDCStudio team
|
|
102
|
+
|
|
103
|
+
### Set up once
|
|
104
|
+
|
|
105
|
+
The account holder does this in SDCStudio at [sdcstudio.axius-sdc.com](https://sdcstudio.axius-sdc.com); each developer then installs the package and exports their key.
|
|
106
|
+
|
|
107
|
+
1. Fund the wallet. Building is paid in credits, 1,000 to the dollar. sdcmodeler never adds funds; a person does that at the wallet page.
|
|
108
|
+
2. Create one API key per developer or agent in Settings, API Keys. Without the `spend` scope a key can search, estimate, read models and download packages. With it, the key's spending limit caps what that holder may spend.
|
|
109
|
+
3. Check a key at any time with `sdcmodeler wallet`: the balance and that key's policy.
|
|
110
|
+
|
|
111
|
+
On an SDCStudio deployment with the build-and-deliver release, three more settings decide how far an agent goes without asking. A signed-in person makes all three; a key can spend within them and can never change them:
|
|
112
|
+
|
|
113
|
+
- **Auto-spend on the key.** The agent runs `build_and_deliver` without a person approving each estimate. A spending limit stays optional: with none, the agent spends in the wallet's reload amounts, under the monthly maximum below.
|
|
114
|
+
- **Auto-reload on the wallet, confirmed.** When a run needs more than the balance, SDCStudio tops the wallet up from the saved card, in the configured amount, before anything is published. A key may trigger a reload only after the person has confirmed auto-reload, and the person gets one email per reload a key triggers.
|
|
115
|
+
- **A monthly auto-reload maximum.** The most auto-reload adds in a calendar month. A wallet's first funding sets it to four times that amount, and sets the reload amount to the amount itself ($10 funded: $10 reloads, at most $40 a month).
|
|
116
|
+
|
|
117
|
+
| Key | Auto-reload | A run |
|
|
118
|
+
|---|---|---|
|
|
119
|
+
| no `spend` | any | searches, estimates, reads models, downloads packages; no charge |
|
|
120
|
+
| `spend` | off | the person approves each estimate; a short balance stops it before anything is published |
|
|
121
|
+
| `spend` | confirmed | the person approves each estimate; a short balance is topped up first |
|
|
122
|
+
| `spend` + auto-spend | off | no per-run approval; a short balance stops it before anything is published |
|
|
123
|
+
| `spend` + auto-spend | confirmed | no per-run approval; a short balance is topped up first, within the monthly maximum |
|
|
124
|
+
|
|
125
|
+
Organization wallets never auto-reload; the organization's admin sets each member's limit.
|
|
126
|
+
|
|
127
|
+
### With a coding agent
|
|
128
|
+
|
|
129
|
+
Add the MCP configuration above to the agent. A typical session, for a developer adding a vitals form to a clinic app:
|
|
130
|
+
|
|
131
|
+
1. The developer asks: "Add a form to record blood pressure and pulse."
|
|
132
|
+
2. The agent calls `search_components` and finds a published blood pressure component.
|
|
133
|
+
3. It drafts a tree that reuses that component and mints a new Pulse count, then calls `estimate_model`.
|
|
134
|
+
4. It shows the developer the estimate: one component reused, one minted, the total in credits.
|
|
135
|
+
5. The developer approves. The agent calls `build_model` with that `estimate_id`, follows `job_status` if a job runs, then calls `download_package` or `add_supabase_kit`.
|
|
136
|
+
6. The agent writes the feature against the published model.
|
|
137
|
+
|
|
138
|
+
The agent cannot skip step 4: `build_model` refuses without the `estimate_id` returned for the same title and tree in the same session.
|
|
139
|
+
|
|
140
|
+
### With the CLI
|
|
141
|
+
|
|
142
|
+
The one piece written by hand is the tree. A component with a `ct_id` is reused; one with a `label` and an SDC4 `data_type` (such as `XdString`, `XdCount`, `XdQuantity` or `XdTemporal`) is minted. Clusters group components and nest.
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
{
|
|
146
|
+
"label": "Vitals",
|
|
147
|
+
"components": [
|
|
148
|
+
{"ct_id": "<ct_id from search>"},
|
|
149
|
+
{"label": "Pulse", "data_type": "XdCount"}
|
|
150
|
+
],
|
|
151
|
+
"clusters": []
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
sdcmodeler search "blood pressure" --type xdquantity
|
|
157
|
+
sdcmodeler estimate tree.json --title "Vitals"
|
|
158
|
+
sdcmodeler build tree.json --title "Vitals" --estimate-id <id> --wait
|
|
159
|
+
sdcmodeler package <ct_id> --dir ./packages
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Builds land in the Modeler's default project, created on first use if there is none.
|
|
163
|
+
|
|
164
|
+
### In one run
|
|
165
|
+
|
|
166
|
+
`ship` (CLI) and `build_and_deliver` (MCP) do the whole path after one approval: build, publish every new component and the model into the Modeler's private default project, wait for the job, then deliver.
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
sdcmodeler ship tree.json --title "Vitals" --deliver package,kit --project ./my-app --plan # the total; nothing spent
|
|
170
|
+
sdcmodeler ship tree.json --title "Vitals" --deliver package,kit --project ./my-app # asks once, then runs
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
The total covers the build and the deliverables: 1,500 credits once when they include an application or a kit, since one charge covers both. A run the wallet or the key cannot pay is refused before anything is built. Once the model is published, a deliverable that fails is reported under `failed`, the others still run, and `ship` exits 2; fetch the failed one with its own command. `--yes` approves without the prompt, for scripts.
|
|
174
|
+
|
|
175
|
+
On a deployment with the build-and-deliver release, SDCStudio does the run itself: it funds and holds the whole total before the first publish (a reload included, when the person allows one), delivers each item from the hold, and sdcmodeler downloads what is ready and writes the kit. On an older deployment sdcmodeler composes the run from the calls it already has. Which one is decided by what the server's estimate answers, never by a setting. With an auto-spend key, `build_and_deliver` needs no prior estimate and returns the estimate in its result; `ship` still asks at the terminal unless `--yes`.
|
|
176
|
+
|
|
177
|
+
The deliverables can live in the agent's settings instead of each call: `SDCMODELER_DELIVER` (for example `package,kit`), `SDCMODELER_OUTPUT_DIR` for the package and application, and `SDCMODELER_PROJECT_DIR` for the kit, in the environment of the CLI or of the MCP server's configuration.
|
|
178
|
+
|
|
179
|
+
### What it costs
|
|
180
|
+
|
|
181
|
+
Reuse is free, so the cheapest model is the one built most from published components. The Vitals tree costs 600 credits ($0.60): 500 to assemble, 100 to mint Pulse.
|
|
182
|
+
|
|
183
|
+
| Action | Credits | USD |
|
|
184
|
+
|---|---|---|
|
|
185
|
+
| Search, estimate, read models, download a package | 0 | $0.00 |
|
|
186
|
+
| Reuse a published component | 0 | $0.00 |
|
|
187
|
+
| Mint a component, or a new cluster below the root | 100 each | $0.10 |
|
|
188
|
+
| Assemble a model (covers its root cluster) | 500 | $0.50 |
|
|
189
|
+
| Generate an application or Supabase kit, first time per user per model | 1,500 | $1.50 |
|
|
190
|
+
|
|
191
|
+
### Review before publishing
|
|
192
|
+
|
|
193
|
+
Publishing locks a model permanently; that is what lets every Governed Data Record keep validating against the schema it was made for. A team with a data steward builds drafts (`--draft`, `publish: false` in `build_model`, or `publish=False` in the client), the steward reviews and publishes in SDCStudio, and the developer then takes the package, application or kit as usual.
|
|
194
|
+
|
|
195
|
+
### When a call is refused
|
|
196
|
+
|
|
197
|
+
| You see | It means | Do this |
|
|
198
|
+
|---|---|---|
|
|
199
|
+
| 402, `InsufficientCredits` | The wallet cannot cover the build; cost and balance are reported in credits. A run also says why (`reason`): `auto_reload_off`, `no_card`, `auto_reload_unconfirmed`, `ceiling`, `declined`, `reload_failed`, `organization_wallet`, `insufficient_funds`. Nothing was published or charged | Add funds at the wallet page, or fix what the reason names (turn on or confirm auto-reload, save or update the card, raise the monthly maximum, ask the organization admin), then run again |
|
|
200
|
+
| 403, `KeyPolicyRefused` | The key lacks a scope the call needs, or is past its spending limit | Ask the account holder to adjust the key |
|
|
201
|
+
| 409, stale estimate (`AssemblyRefused`) | The tree changed after the estimate | Estimate again and build with the new id |
|
|
202
|
+
| 409, retired component (`AssemblyRefused`) | The tree reuses a retired component | Search for its replacement and update the tree |
|
|
203
|
+
| Problems in the estimate | A component needs a `ct_id`, or a `label` and `data_type`; a cluster needs a label | Fix the tree; nothing was built |
|
|
204
|
+
|
|
205
|
+
## What is not here
|
|
206
|
+
|
|
207
|
+
Validation (sdcvalidator's server), governance (sdcgovernance's), receipt verification (sdcreceipt's) and bringing existing data across (sdc-agents) are their own registered servers. sdcmodeler composes with them; it does not re-implement them.
|
|
208
|
+
|
|
209
|
+
## Release
|
|
210
|
+
|
|
211
|
+
Two steps: merge to `main`, then push the tag `v<version>` matching `pyproject.toml`. `release.yml` runs the tests, builds, publishes to PyPI by trusted publisher and to the MCP registry.
|
|
212
|
+
|
|
213
|
+
## License
|
|
214
|
+
|
|
215
|
+
Apache License 2.0. Copyright Axius SDC, Inc.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "sdcmodeler"
|
|
7
|
-
version = "4.
|
|
7
|
+
version = "4.5.0"
|
|
8
8
|
description = "The modeler's client for SDCStudio: search the catalog, estimate, assemble and publish SDC4 data models, generate applications; a CLI and an MCP server over one client"
|
|
9
9
|
license = "Apache-2.0"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -17,7 +17,7 @@ servers: sdcvalidator validates, sdcgovernance governs, sdcreader reads,
|
|
|
17
17
|
sdcmodeler models. It also names the concept SDCStudio already has: every user
|
|
18
18
|
is a Modeler, and the Modeler's projects scope every call.
|
|
19
19
|
"""
|
|
20
|
-
__version__ = "4.
|
|
20
|
+
__version__ = "4.5.0"
|
|
21
21
|
|
|
22
22
|
from sdcmodeler.client import ( # noqa: E402
|
|
23
23
|
AssemblyRefused,
|
|
@@ -3,11 +3,13 @@ from __future__ import annotations
|
|
|
3
3
|
|
|
4
4
|
import argparse
|
|
5
5
|
import json
|
|
6
|
+
import os
|
|
6
7
|
import sys
|
|
7
8
|
from pathlib import Path
|
|
8
9
|
|
|
9
10
|
from sdcmodeler import __version__
|
|
10
11
|
from sdcmodeler.client import SDCStudioClient, SDCStudioError
|
|
12
|
+
from sdcmodeler import deliver as runs
|
|
11
13
|
from sdcmodeler.kits import KitConflictError, write_kit
|
|
12
14
|
|
|
13
15
|
|
|
@@ -19,6 +21,41 @@ def _load_tree(path: str) -> dict:
|
|
|
19
21
|
return json.loads(Path(path).read_text(encoding="utf-8"))
|
|
20
22
|
|
|
21
23
|
|
|
24
|
+
def _ship(c, a):
|
|
25
|
+
tree = _load_tree(a.tree)
|
|
26
|
+
plan = runs.plan(c, tree, a.title, a.deliver)
|
|
27
|
+
shown = {k: v for k, v in plan.items() if k != "estimate"}
|
|
28
|
+
if a.plan:
|
|
29
|
+
return shown
|
|
30
|
+
if plan["refusals"]:
|
|
31
|
+
raise runs.RunRefused("Nothing was built. " + " ".join(plan["refusals"]))
|
|
32
|
+
authorized_by = "yes_flag" if a.yes else "prompt"
|
|
33
|
+
if not a.yes:
|
|
34
|
+
sys.stderr.write(
|
|
35
|
+
f"{plan['title']}: {plan['build_credits']} credits to build and publish into {plan['publishes_into']}"
|
|
36
|
+
+ (f", {plan['deliver_credits']} for {', '.join(i for i in plan['deliver'] if i in runs.CHARGED)}" if plan["deliver_credits"] else "")
|
|
37
|
+
+ f"; {plan['total_credits']} in all. Deliver: {', '.join(plan['deliver']) or 'nothing'}.\n"
|
|
38
|
+
+ _funding_line(plan)
|
|
39
|
+
+ "Publishing is permanent. Proceed? [y/N] "
|
|
40
|
+
)
|
|
41
|
+
sys.stderr.flush()
|
|
42
|
+
if not sys.stdin.isatty() or sys.stdin.readline().strip().lower() not in ("y", "yes"):
|
|
43
|
+
raise runs.RunRefused("Not approved; nothing was built. Use --yes to approve without the prompt.")
|
|
44
|
+
out_dir = a.dir or os.environ.get("SDCMODELER_OUTPUT_DIR") or "."
|
|
45
|
+
project = a.project or os.environ.get("SDCMODELER_PROJECT_DIR") or out_dir
|
|
46
|
+
result = runs.run(c, tree, a.title, plan, output_dir=out_dir, project_dir=project, description=a.description)
|
|
47
|
+
result["authorized_by"] = authorized_by
|
|
48
|
+
return result
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _funding_line(plan) -> str:
|
|
52
|
+
reload = (plan.get("funding") or {}).get("auto_reload") or {}
|
|
53
|
+
if plan.get("funding") and not plan["funding"].get("covered") and reload.get("would_cover"):
|
|
54
|
+
return (f"The wallet is {plan['funding'].get('shortfall_credits')} credits short: auto-reload will add "
|
|
55
|
+
f"${reload.get('reload_total_usd')} ({reload.get('reloads_needed')} reload(s)) before anything is published.\n")
|
|
56
|
+
return ""
|
|
57
|
+
|
|
58
|
+
|
|
22
59
|
def build_parser() -> argparse.ArgumentParser:
|
|
23
60
|
p = argparse.ArgumentParser(
|
|
24
61
|
prog="sdcmodeler",
|
|
@@ -31,7 +68,9 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
31
68
|
|
|
32
69
|
s = sub.add_parser("search", help="search the public catalog of published components")
|
|
33
70
|
s.add_argument("query"); s.add_argument("--type"); s.add_argument("--project"); s.add_argument("--page-size", type=int, default=25)
|
|
34
|
-
s.
|
|
71
|
+
s.add_argument("--scope", choices=["mine", "public"], default=None,
|
|
72
|
+
help="mine: your own published components first, then public (needs a key; the default with one); public: the catalog only")
|
|
73
|
+
s.set_defaults(func=lambda c, a: c.search_components(a.query, type=a.type, project=a.project, scope=a.scope, page_size=a.page_size))
|
|
35
74
|
|
|
36
75
|
s = sub.add_parser("models", help="published models in the public catalog")
|
|
37
76
|
s.add_argument("query", nargs="?", default="")
|
|
@@ -63,6 +102,16 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
63
102
|
return result
|
|
64
103
|
s.set_defaults(func=_build)
|
|
65
104
|
|
|
105
|
+
s = sub.add_parser("ship", help="build, publish and deliver in one run, after one approval of the run's total; spends credits")
|
|
106
|
+
s.add_argument("tree"); s.add_argument("--title", required=True); s.add_argument("--description", default="")
|
|
107
|
+
s.add_argument("--deliver", default=None,
|
|
108
|
+
help="comma-separated: package, app:lightweight, app:enterprise, kit (default: $SDCMODELER_DELIVER, else package)")
|
|
109
|
+
s.add_argument("--dir", default=None, help="where the package and application land (default: $SDCMODELER_OUTPUT_DIR, else here)")
|
|
110
|
+
s.add_argument("--project", default=None, help="for kit: the project holding supabase/ (default: $SDCMODELER_PROJECT_DIR, else --dir)")
|
|
111
|
+
s.add_argument("--plan", action="store_true", help="print the run's total and stop; nothing is spent")
|
|
112
|
+
s.add_argument("--yes", action="store_true", help="approve without the prompt (for scripts); the run is still refused when it cannot be paid")
|
|
113
|
+
s.set_defaults(func=_ship)
|
|
114
|
+
|
|
66
115
|
s = sub.add_parser("job", help="one job by id (from build), or every job with --list")
|
|
67
116
|
s.add_argument("job_ct_id", nargs="?")
|
|
68
117
|
s.add_argument("--list", action="store_true")
|
|
@@ -108,9 +157,14 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
108
157
|
return 0
|
|
109
158
|
client = SDCStudioClient(base_url=args.url)
|
|
110
159
|
try:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
160
|
+
result = args.func(client, args)
|
|
161
|
+
_print(result)
|
|
162
|
+
# ship: 3 when the run is still building on the server (do not run it again), 2 when the model is
|
|
163
|
+
# published but a deliverable failed; a script should notice either.
|
|
164
|
+
if isinstance(result, dict) and result.get("status") == "in_flight":
|
|
165
|
+
return 3
|
|
166
|
+
return 2 if isinstance(result, dict) and result.get("failed") else 0
|
|
167
|
+
except (SDCStudioError, KitConflictError, runs.RunRefused) as exc:
|
|
114
168
|
sys.stderr.write(f"{exc}\n")
|
|
115
169
|
return 1
|
|
116
170
|
finally:
|