prisma-api 0.4.5__tar.gz → 0.4.7__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 (23) hide show
  1. {prisma_api-0.4.5 → prisma_api-0.4.7}/PKG-INFO +111 -9
  2. {prisma_api-0.4.5 → prisma_api-0.4.7}/README.md +110 -8
  3. prisma_api-0.4.7/prisma_api/dataset_docs/SKILL.md +166 -0
  4. prisma_api-0.4.7/prisma_api/dataset_docs/manifest_guide.md +206 -0
  5. prisma_api-0.4.7/prisma_api/dataset_package.py +1073 -0
  6. {prisma_api-0.4.5 → prisma_api-0.4.7}/prisma_api/prisma_api_v2.py +620 -0
  7. prisma_api-0.4.7/prisma_api/screening_outputs.py +270 -0
  8. {prisma_api-0.4.5 → prisma_api-0.4.7}/prisma_api.egg-info/PKG-INFO +111 -9
  9. {prisma_api-0.4.5 → prisma_api-0.4.7}/prisma_api.egg-info/SOURCES.txt +8 -1
  10. prisma_api-0.4.7/prisma_api.egg-info/entry_points.txt +3 -0
  11. {prisma_api-0.4.5 → prisma_api-0.4.7}/pyproject.toml +9 -1
  12. prisma_api-0.4.7/tests/test_dataset_package.py +590 -0
  13. {prisma_api-0.4.5 → prisma_api-0.4.7}/tests/test_prisma_api_v2.py +266 -0
  14. prisma_api-0.4.7/tests/test_screening_outputs.py +177 -0
  15. {prisma_api-0.4.5 → prisma_api-0.4.7}/LICENSE +0 -0
  16. {prisma_api-0.4.5 → prisma_api-0.4.7}/prisma_api/__init__.py +0 -0
  17. {prisma_api-0.4.5 → prisma_api-0.4.7}/prisma_api/config.py +0 -0
  18. {prisma_api-0.4.5 → prisma_api-0.4.7}/prisma_api/prisma_api.py +0 -0
  19. {prisma_api-0.4.5 → prisma_api-0.4.7}/prisma_api.egg-info/dependency_links.txt +0 -0
  20. {prisma_api-0.4.5 → prisma_api-0.4.7}/prisma_api.egg-info/requires.txt +0 -0
  21. {prisma_api-0.4.5 → prisma_api-0.4.7}/prisma_api.egg-info/top_level.txt +0 -0
  22. {prisma_api-0.4.5 → prisma_api-0.4.7}/setup.cfg +0 -0
  23. {prisma_api-0.4.5 → prisma_api-0.4.7}/tests/test_prisma_api.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: prisma_api
3
- Version: 0.4.5
3
+ Version: 0.4.7
4
4
  Summary: A package for interacting with PrISMa Platform APIs. PrISMa is a holistic system for numerical synthesis and assessment of Metal-Organic Frameworks and their applications, for Direct Air Capture of CO2. For more information, see: https://prisma.hw.ac.uk.
5
5
  Author-email: RCCS-CaptureTeam <team@prisma-platform.org>
6
6
  License: GNUv3
@@ -58,6 +58,12 @@ api = prisma_api.init()
58
58
  ```
59
59
 
60
60
  On first use, the package creates a config file and prompts for an API key.
61
+ Without a terminal (e.g. CI) it raises `RuntimeError` naming the environment
62
+ variables to set instead (see below).
63
+
64
+ `init()` prints whether it connected to production or a local dev server.
65
+ Production is the default; use `prisma_api.init(local_dev=True)` for a local
66
+ dev server on `localhost:<dev_host_port>`.
61
67
 
62
68
  ### Upgrades
63
69
 
@@ -88,19 +94,26 @@ create_config_file(api_key="YOUR_API_KEY_HERE")
88
94
 
89
95
  ### Environment-variable mode
90
96
 
91
- If you do not want to use the config file:
97
+ When no config file exists, `init()` reads these environment variables
98
+ instead (nothing is written to disk):
92
99
 
93
100
  ```bash
94
101
  export PRISMA_API_KEY="YOUR_API_KEY_HERE"
95
- export PRISMA_API_DEV="False"
102
+ export PRISMA_API_DEV_API_KEY="YOUR_DEV_KEY" # optional; defaults to PRISMA_API_KEY
103
+ export PRISMA_API_DEV_HOST_PORT="8000" # optional; used with local_dev=True
96
104
  ```
97
105
 
106
+ To ignore any config file and use only the environment variables:
107
+
98
108
  ```python
99
- from prisma_api.prisma_api import prisma_api
109
+ import prisma_api
100
110
 
101
- api = prisma_api(use_config_file=False)
111
+ api = prisma_api.init(use_config_file=False)
102
112
  ```
103
113
 
114
+ The target server is chosen only by `init(local_dev=...)`; there is no
115
+ environment variable for it.
116
+
104
117
  ## Quick start
105
118
 
106
119
  ```python
@@ -129,6 +142,55 @@ flowsheet = api.v2.get_flowsheet(name="dac_min")
129
142
  ```
130
143
 
131
144
 
145
+ ## Bring your own dataset
146
+
147
+ Send a folder of your own results (CSV, JSON or YAML, organised any way) to the platform as one zip. Your files stay as they are; you add one file, `prisma_manifest.yaml`, that says what each file is and where its data goes.
148
+
149
+ 1. **Install and connect.** You need your API key from your platform profile page.
150
+ ```bash
151
+ pip install prisma_api
152
+ python -c "import prisma_api; prisma_api.init()"
153
+ ```
154
+ 2. **Find the dataset on the platform.** Data always goes to a dataset that already exists there. If yours doesn't, create it first on the web portal (from its project's page). On the dataset's page, **Add un-managed dataset** gives you the command for step 4, with the dataset's slug and a tag for its records.
155
+ 3. **Leave files out** (optional). The listing skips whatever your `.gitignore` files match, and always leaves out `.git` and cache folders and anything named `*.claude`, `*.venv` or `*.DS_Store` (such as the `.claude` folder the skill is installed in), even if `.gitignore` doesn't list them. No other ignore file counts.
156
+ 4. **Send the folder tree.** This sends only the folder structure: each file's path and size. No file contents, zip or manifest are sent. In your folder, paste the command from step 2:
157
+ ```bash
158
+ cd my_dataset_folder
159
+ prisma-dataset tree . --prod --dataset my-dataset --tag "My dataset"
160
+ ```
161
+ 5. **Tick the files.** On the dataset's page, open **View folder tree** and tick the files to send. Every file starts unticked; ticks save automatically.
162
+ 6. **Build the manifest and send, with Claude Code.** Copy the command shown above the folder tree, which has the dataset's slug and tag. In your folder:
163
+ ```bash
164
+ prisma-dataset install-skill . # once
165
+ claude # then paste the command, e.g.:
166
+ /prisma-dataset my-dataset --tag "My dataset" --prod
167
+ ```
168
+ Claude writes (or updates) `prisma_manifest.yaml` for the ticked files: what each file holds and where its data goes. It checks the manifest with the platform's dry run (nothing is written) until it is clean, summarises what would be written, and sends the data once you say yes. Agree your first write with the platform team.
169
+
170
+ To write the manifest yourself, read `prisma-dataset guide` and `prisma-dataset targets --prod`; `prisma-dataset ticked . --prod --dataset my-dataset` lists the ticked files it must cover. Then `prisma-dataset send . --prod` checks and packs the ticked files, shows the dry run and asks before writing.
171
+
172
+ When your results change, resend the tree if files were added or removed (`prisma-dataset tree . --prod`), tick any new files, and run the Claude Code command (or `send`) again. The platform updates the dataset to match and keeps a version history:
173
+
174
+ - **Same files, new data:** the tree is refreshed with your ticks kept. If the upload changes any records, the dataset goes up a minor version (1.0 → 1.1). If it changes nothing, the version stays as it is.
175
+ - **Files added or removed:** if the dataset already has data, the platform makes a new major version: a copy of the dataset called `<slug>-v2`, at version 2.0 and tagged `"<tag> v2"`. Its authors, project links and Zenodo record are copied, and your ticks are carried over. The command prints the new tree's id; `send` uploads to it. Your manifest can keep the original slug.
176
+
177
+ Each version records what its upload changed against the one before it: files added, removed or modified, and records created, updated or deleted per table and per run. A dry run reports the version it would make. To list a dataset's versions:
178
+ ```bash
179
+ prisma-dataset versions my-dataset --prod
180
+ ```
181
+ Older versions' values are not kept, only this record of the changes.
182
+
183
+ `send` does these steps in one go; you can also run them one at a time:
184
+ ```bash
185
+ prisma-dataset validate . --prod # local check of the ticked files
186
+ prisma-dataset pack . --prod --out ../my_dataset.zip # write the zip next to the folder, not inside it
187
+ prisma-dataset upload ../my_dataset.zip --prod # dry run
188
+ prisma-dataset upload ../my_dataset.zip --prod --apply # write
189
+ ```
190
+ `pack` and `upload` take `--tag "Name"` (repeatable) to tag the records with more names than `dataset.tag`.
191
+
192
+ The same steps are available in Python: `prisma_api.dataset_package.send_tree`, `ticked_files`, `send`, `fetch_selection`, `validate`, `pack`, `upload` and `load_targets`.
193
+
132
194
  ## Return formats
133
195
 
134
196
  All v2 list endpoints support two formats:
@@ -172,13 +234,14 @@ The main client exposes these v1 methods:
172
234
  Configuration helpers on the main client:
173
235
 
174
236
  - `set_return_format(fmt)`
175
- - `update_dev_mode(dev)`
237
+ - `update_dev_mode(dev)` — deprecated and no longer changes the target; use `prisma_api.init(local_dev=True|False)`
176
238
 
177
239
  Module-level helpers exported from the package:
178
240
 
179
241
  - `prisma_api.init`
242
+ - `prisma_api.__version__`
180
243
  - `prisma_api.PrismaAPIv2`
181
- - `prisma_api.update_dev_mode`
244
+ - `prisma_api.update_dev_mode` — deprecated, as above
182
245
  - `prisma_api.update_dev_host_port`
183
246
  - `prisma_api.locate_config`
184
247
  - `prisma_api.PrismaUpsertError`, `prisma_api.PrismaRowErrorWarning`, `prisma_api.PrismaUnknownFieldsWarning`, `prisma_api.PrismaNewStructureWarning`
@@ -191,11 +254,15 @@ All methods below are available on `api.v2`.
191
254
 
192
255
  - `health()`
193
256
  - `get_flowsheet(name="dac_min")`
257
+ - `get_flowsheet_bundle(name="dac_min")`
258
+ - `upsert_flowsheets(flowsheets, screening_analysis_name=None, on_exists="append", appendix="_v4")`
194
259
 
195
260
  ### Materials and bundles
196
261
 
197
262
  - `list_materials(name=None, limit=10000)`
198
- - `get_material(material_id=None, name=None, bundle=['isotherms','zeopp','water_kpis','cif'])` (`bundle=None` returns root-only material detail)
263
+ - `get_material(material_id=None, *, name=None, bundle=['isotherms','zeopp','water_kpis','cif'], sim_or_exp=None, good_structure=None, limit=500, offset=0, include_cif_text=False, cif_timeout=60)` (`bundle=None` returns root-only material detail; `name` may be a list)
264
+ - `list_cifs(tag=None)`
265
+ - `get_cifs(mof, structured=True, pandas=True, save_dir=None)` — one name or a list; `save_dir` writes the `.cif` files
199
266
  - `get_materials_psdi(name=None, limit=500, offset=0)`
200
267
  - `get_material_psdi(material_id)`
201
268
  - `get_material_property_bundle(mof, sim_or_exp=None, good_structure=None, limit=500, offset=0, query=None)`
@@ -213,6 +280,29 @@ All methods below are available on `api.v2`.
213
280
  - `build_case_pack(case_id, scenario_id=None)`
214
281
  - `list_case_packs(source=None, sink=None, region=None, study=None, include_scenarios=False, limit=100, offset=0)`
215
282
 
283
+ ### Case-study library (PrISMa_Platform sync)
284
+
285
+ - `upsert_case_study_library(document, dry_run=False, max_request_bytes=2_400_000, raise_on_error=False, timeout=600)` — sends a `prisma_v2.case_study_library.bundle.v1` document, split into requests if needed; replaces the pipeline 11 ZIP upload
286
+ - `get_case_study_library_bundle(sections=None, timeout=300)`
287
+ - `get_case_study_bundle(case_id, timeout=120)`
288
+ - `latest_case_study_library_sync()` — `None` before the first sync
289
+ - `list_case_study_library_sync_runs(status=None, limit=50, git_commit=None, offset=0)`
290
+ - `list_stale_case_study_library_records()`
291
+
292
+ ### Datasets and screening outputs
293
+
294
+ - `get_dataset_targets()` — what a dataset manifest may write on the server: targets, kinds, allowed keys and fields
295
+ - `register_dataset_tree(tree, dataset, manifest=None, tags=None, package=None, timeout=600)` — sends a folder's structure (paths and sizes only) so files can be ticked on the dataset's page; `package` refreshes an existing tree, keeping its ticks. Used by `prisma-dataset tree`
296
+ - `list_dataset_trees(dataset=None, limit=50)` / `get_dataset_tree(package)` — registered trees, and one tree's files with their ticks
297
+ - `ingest_dataset(zip_path, dry_run=True, timeout=1800, tags=None, package=None)` — sends a dataset package (files + `prisma_manifest.yaml`, built with `prisma-dataset pack`) to `POST /api/v2/datasets/ingest/`; returns the server report, including on rejection. Dry run unless `dry_run=False`. The format: `prisma-dataset guide`
298
+ - `list_dataset_versions(dataset, limit=50)` — a dataset's versions, newest first, each with what its upload changed
299
+ - `list_analysis_runs(dataset=None, limit=500, offset=0)` — runs loaded from dataset packages, with conditions, parameter set and row counts
300
+ - `get_analysis_run_rows(run_key, table='results', limit=500, offset=0)` — a run's free-form rows (`results`: metrics with no typed table; `inputs`: per-run inputs), each with its material or reference-system subject
301
+ - `ingest_screening_outputs(zip_path, timeout=7200, background=True, poll_every=15, progress=None)` — sends one batch of v1 case-study screening results (built with `prisma_api.screening_outputs.pack`) to `POST /api/v2/screening-outputs/ingest/` (pipeline 13); each case study / conditions / type becomes a scenario of the batch and its OutputKpi rows are replaced. Writes; no dry run. The server ingests in the background and the client polls until it is done, printing progress
302
+ - `screening_outputs_ingest_status(zip_upload)` — status of a screening-output batch sent earlier
303
+
304
+ From the command line: `prisma-outputs list <screening_results>` shows the batches, `prisma-outputs send <screening_results> --dev --batch NAME` (or `--all`) sends them after asking (`--yes` skips the question; `--prod` targets production; a failed batch is reported with the server's error and the next is still sent), and `prisma-outputs status <upload> --prod` checks a batch sent earlier.
305
+
216
306
  ### Catalog and reference data
217
307
 
218
308
  - `get_molecules(name=None, limit=500, offset=0)`
@@ -223,6 +313,8 @@ All methods below are available on `api.v2`.
223
313
  - `get_region(region_id)`
224
314
  - `get_sources(name=None, limit=500, offset=0)`
225
315
  - `get_source(source_id)`
316
+ - `get_scopes(name=None, limit=500, offset=0)`
317
+ - `get_scope(scope_id)`
226
318
  - `get_sinks(name=None, limit=500, offset=0)`
227
319
  - `get_sink(sink_id)`
228
320
  - `get_transport_scenarios(name=None, limit=500, offset=0)`
@@ -399,12 +491,22 @@ pytest tests/ -v --cov=prisma_api --cov-report=term-missing
399
491
  - [API_REFERENCE_V1.md](API_REFERENCE_V1.md)
400
492
  - [API_REFERENCE_V2.md](API_REFERENCE_V2.md)
401
493
  - [DEVELOPMENT_SUMMARY.md](DEVELOPMENT_SUMMARY.md)
402
- - [User Guide.md](User%20Guide.md)
494
+ - [user_guide.md](user_guide.md)
495
+ - Release notes, one file per minor series: [v0.4.x](https://github.com/RCCS-CaptureTeam/prisma_api/blob/main/docs/release_notes/v0.4.x.md), [v0.3.x](https://github.com/RCCS-CaptureTeam/prisma_api/blob/main/docs/release_notes/v0.3.x.md), [v0.2.x](https://github.com/RCCS-CaptureTeam/prisma_api/blob/main/docs/release_notes/v0.2.x.md)
496
+
497
+ ## Release notes
498
+
499
+ Plain-language notes for every release, newest first, are in
500
+ [docs/release_notes/](https://github.com/RCCS-CaptureTeam/prisma_api/tree/main/docs/release_notes). Each release section links to its
501
+ GitHub release and to the full diff from the previous release. Check them
502
+ before upgrading for breaking changes and deprecations.
403
503
 
404
504
  ## Notes
405
505
 
406
506
  - Production v2 base URL: `https://prisma-platform.org/api/v2`
407
507
  - Authentication header: `X-API-Key`
408
508
  - Local development routing is selected with `prisma_api.init(local_dev=True)`; the default targets production
509
+ - Server compatibility notes for recent releases are below; see [docs/release_notes/](https://github.com/RCCS-CaptureTeam/prisma_api/tree/main/docs/release_notes) for the full history
409
510
  - 0.4.4: the `adsorption-isotherm` endpoints and the 400/notice handling need prisma_cloud >= 0.6.16
410
511
  - 0.4.5: H2 isotherms go through `upsert_adsorption_isotherm` (prisma_cloud >= 0.6.16); the H2-only methods and the `isotherm_H2s` collection key are deprecated. New `upsert_autoprism_cifs` uses the existing bundle upsert endpoint. AutoPrism getters take `match="exact"`.
512
+ - 0.4.6: case-study library sync methods (`upsert_case_study_library` and the export, sync-run and stale-record readers) for the prisma_cloud `case-study-library` endpoints, which replace ingest pipeline 11.
@@ -38,6 +38,12 @@ api = prisma_api.init()
38
38
  ```
39
39
 
40
40
  On first use, the package creates a config file and prompts for an API key.
41
+ Without a terminal (e.g. CI) it raises `RuntimeError` naming the environment
42
+ variables to set instead (see below).
43
+
44
+ `init()` prints whether it connected to production or a local dev server.
45
+ Production is the default; use `prisma_api.init(local_dev=True)` for a local
46
+ dev server on `localhost:<dev_host_port>`.
41
47
 
42
48
  ### Upgrades
43
49
 
@@ -68,19 +74,26 @@ create_config_file(api_key="YOUR_API_KEY_HERE")
68
74
 
69
75
  ### Environment-variable mode
70
76
 
71
- If you do not want to use the config file:
77
+ When no config file exists, `init()` reads these environment variables
78
+ instead (nothing is written to disk):
72
79
 
73
80
  ```bash
74
81
  export PRISMA_API_KEY="YOUR_API_KEY_HERE"
75
- export PRISMA_API_DEV="False"
82
+ export PRISMA_API_DEV_API_KEY="YOUR_DEV_KEY" # optional; defaults to PRISMA_API_KEY
83
+ export PRISMA_API_DEV_HOST_PORT="8000" # optional; used with local_dev=True
76
84
  ```
77
85
 
86
+ To ignore any config file and use only the environment variables:
87
+
78
88
  ```python
79
- from prisma_api.prisma_api import prisma_api
89
+ import prisma_api
80
90
 
81
- api = prisma_api(use_config_file=False)
91
+ api = prisma_api.init(use_config_file=False)
82
92
  ```
83
93
 
94
+ The target server is chosen only by `init(local_dev=...)`; there is no
95
+ environment variable for it.
96
+
84
97
  ## Quick start
85
98
 
86
99
  ```python
@@ -109,6 +122,55 @@ flowsheet = api.v2.get_flowsheet(name="dac_min")
109
122
  ```
110
123
 
111
124
 
125
+ ## Bring your own dataset
126
+
127
+ Send a folder of your own results (CSV, JSON or YAML, organised any way) to the platform as one zip. Your files stay as they are; you add one file, `prisma_manifest.yaml`, that says what each file is and where its data goes.
128
+
129
+ 1. **Install and connect.** You need your API key from your platform profile page.
130
+ ```bash
131
+ pip install prisma_api
132
+ python -c "import prisma_api; prisma_api.init()"
133
+ ```
134
+ 2. **Find the dataset on the platform.** Data always goes to a dataset that already exists there. If yours doesn't, create it first on the web portal (from its project's page). On the dataset's page, **Add un-managed dataset** gives you the command for step 4, with the dataset's slug and a tag for its records.
135
+ 3. **Leave files out** (optional). The listing skips whatever your `.gitignore` files match, and always leaves out `.git` and cache folders and anything named `*.claude`, `*.venv` or `*.DS_Store` (such as the `.claude` folder the skill is installed in), even if `.gitignore` doesn't list them. No other ignore file counts.
136
+ 4. **Send the folder tree.** This sends only the folder structure: each file's path and size. No file contents, zip or manifest are sent. In your folder, paste the command from step 2:
137
+ ```bash
138
+ cd my_dataset_folder
139
+ prisma-dataset tree . --prod --dataset my-dataset --tag "My dataset"
140
+ ```
141
+ 5. **Tick the files.** On the dataset's page, open **View folder tree** and tick the files to send. Every file starts unticked; ticks save automatically.
142
+ 6. **Build the manifest and send, with Claude Code.** Copy the command shown above the folder tree, which has the dataset's slug and tag. In your folder:
143
+ ```bash
144
+ prisma-dataset install-skill . # once
145
+ claude # then paste the command, e.g.:
146
+ /prisma-dataset my-dataset --tag "My dataset" --prod
147
+ ```
148
+ Claude writes (or updates) `prisma_manifest.yaml` for the ticked files: what each file holds and where its data goes. It checks the manifest with the platform's dry run (nothing is written) until it is clean, summarises what would be written, and sends the data once you say yes. Agree your first write with the platform team.
149
+
150
+ To write the manifest yourself, read `prisma-dataset guide` and `prisma-dataset targets --prod`; `prisma-dataset ticked . --prod --dataset my-dataset` lists the ticked files it must cover. Then `prisma-dataset send . --prod` checks and packs the ticked files, shows the dry run and asks before writing.
151
+
152
+ When your results change, resend the tree if files were added or removed (`prisma-dataset tree . --prod`), tick any new files, and run the Claude Code command (or `send`) again. The platform updates the dataset to match and keeps a version history:
153
+
154
+ - **Same files, new data:** the tree is refreshed with your ticks kept. If the upload changes any records, the dataset goes up a minor version (1.0 → 1.1). If it changes nothing, the version stays as it is.
155
+ - **Files added or removed:** if the dataset already has data, the platform makes a new major version: a copy of the dataset called `<slug>-v2`, at version 2.0 and tagged `"<tag> v2"`. Its authors, project links and Zenodo record are copied, and your ticks are carried over. The command prints the new tree's id; `send` uploads to it. Your manifest can keep the original slug.
156
+
157
+ Each version records what its upload changed against the one before it: files added, removed or modified, and records created, updated or deleted per table and per run. A dry run reports the version it would make. To list a dataset's versions:
158
+ ```bash
159
+ prisma-dataset versions my-dataset --prod
160
+ ```
161
+ Older versions' values are not kept, only this record of the changes.
162
+
163
+ `send` does these steps in one go; you can also run them one at a time:
164
+ ```bash
165
+ prisma-dataset validate . --prod # local check of the ticked files
166
+ prisma-dataset pack . --prod --out ../my_dataset.zip # write the zip next to the folder, not inside it
167
+ prisma-dataset upload ../my_dataset.zip --prod # dry run
168
+ prisma-dataset upload ../my_dataset.zip --prod --apply # write
169
+ ```
170
+ `pack` and `upload` take `--tag "Name"` (repeatable) to tag the records with more names than `dataset.tag`.
171
+
172
+ The same steps are available in Python: `prisma_api.dataset_package.send_tree`, `ticked_files`, `send`, `fetch_selection`, `validate`, `pack`, `upload` and `load_targets`.
173
+
112
174
  ## Return formats
113
175
 
114
176
  All v2 list endpoints support two formats:
@@ -152,13 +214,14 @@ The main client exposes these v1 methods:
152
214
  Configuration helpers on the main client:
153
215
 
154
216
  - `set_return_format(fmt)`
155
- - `update_dev_mode(dev)`
217
+ - `update_dev_mode(dev)` — deprecated and no longer changes the target; use `prisma_api.init(local_dev=True|False)`
156
218
 
157
219
  Module-level helpers exported from the package:
158
220
 
159
221
  - `prisma_api.init`
222
+ - `prisma_api.__version__`
160
223
  - `prisma_api.PrismaAPIv2`
161
- - `prisma_api.update_dev_mode`
224
+ - `prisma_api.update_dev_mode` — deprecated, as above
162
225
  - `prisma_api.update_dev_host_port`
163
226
  - `prisma_api.locate_config`
164
227
  - `prisma_api.PrismaUpsertError`, `prisma_api.PrismaRowErrorWarning`, `prisma_api.PrismaUnknownFieldsWarning`, `prisma_api.PrismaNewStructureWarning`
@@ -171,11 +234,15 @@ All methods below are available on `api.v2`.
171
234
 
172
235
  - `health()`
173
236
  - `get_flowsheet(name="dac_min")`
237
+ - `get_flowsheet_bundle(name="dac_min")`
238
+ - `upsert_flowsheets(flowsheets, screening_analysis_name=None, on_exists="append", appendix="_v4")`
174
239
 
175
240
  ### Materials and bundles
176
241
 
177
242
  - `list_materials(name=None, limit=10000)`
178
- - `get_material(material_id=None, name=None, bundle=['isotherms','zeopp','water_kpis','cif'])` (`bundle=None` returns root-only material detail)
243
+ - `get_material(material_id=None, *, name=None, bundle=['isotherms','zeopp','water_kpis','cif'], sim_or_exp=None, good_structure=None, limit=500, offset=0, include_cif_text=False, cif_timeout=60)` (`bundle=None` returns root-only material detail; `name` may be a list)
244
+ - `list_cifs(tag=None)`
245
+ - `get_cifs(mof, structured=True, pandas=True, save_dir=None)` — one name or a list; `save_dir` writes the `.cif` files
179
246
  - `get_materials_psdi(name=None, limit=500, offset=0)`
180
247
  - `get_material_psdi(material_id)`
181
248
  - `get_material_property_bundle(mof, sim_or_exp=None, good_structure=None, limit=500, offset=0, query=None)`
@@ -193,6 +260,29 @@ All methods below are available on `api.v2`.
193
260
  - `build_case_pack(case_id, scenario_id=None)`
194
261
  - `list_case_packs(source=None, sink=None, region=None, study=None, include_scenarios=False, limit=100, offset=0)`
195
262
 
263
+ ### Case-study library (PrISMa_Platform sync)
264
+
265
+ - `upsert_case_study_library(document, dry_run=False, max_request_bytes=2_400_000, raise_on_error=False, timeout=600)` — sends a `prisma_v2.case_study_library.bundle.v1` document, split into requests if needed; replaces the pipeline 11 ZIP upload
266
+ - `get_case_study_library_bundle(sections=None, timeout=300)`
267
+ - `get_case_study_bundle(case_id, timeout=120)`
268
+ - `latest_case_study_library_sync()` — `None` before the first sync
269
+ - `list_case_study_library_sync_runs(status=None, limit=50, git_commit=None, offset=0)`
270
+ - `list_stale_case_study_library_records()`
271
+
272
+ ### Datasets and screening outputs
273
+
274
+ - `get_dataset_targets()` — what a dataset manifest may write on the server: targets, kinds, allowed keys and fields
275
+ - `register_dataset_tree(tree, dataset, manifest=None, tags=None, package=None, timeout=600)` — sends a folder's structure (paths and sizes only) so files can be ticked on the dataset's page; `package` refreshes an existing tree, keeping its ticks. Used by `prisma-dataset tree`
276
+ - `list_dataset_trees(dataset=None, limit=50)` / `get_dataset_tree(package)` — registered trees, and one tree's files with their ticks
277
+ - `ingest_dataset(zip_path, dry_run=True, timeout=1800, tags=None, package=None)` — sends a dataset package (files + `prisma_manifest.yaml`, built with `prisma-dataset pack`) to `POST /api/v2/datasets/ingest/`; returns the server report, including on rejection. Dry run unless `dry_run=False`. The format: `prisma-dataset guide`
278
+ - `list_dataset_versions(dataset, limit=50)` — a dataset's versions, newest first, each with what its upload changed
279
+ - `list_analysis_runs(dataset=None, limit=500, offset=0)` — runs loaded from dataset packages, with conditions, parameter set and row counts
280
+ - `get_analysis_run_rows(run_key, table='results', limit=500, offset=0)` — a run's free-form rows (`results`: metrics with no typed table; `inputs`: per-run inputs), each with its material or reference-system subject
281
+ - `ingest_screening_outputs(zip_path, timeout=7200, background=True, poll_every=15, progress=None)` — sends one batch of v1 case-study screening results (built with `prisma_api.screening_outputs.pack`) to `POST /api/v2/screening-outputs/ingest/` (pipeline 13); each case study / conditions / type becomes a scenario of the batch and its OutputKpi rows are replaced. Writes; no dry run. The server ingests in the background and the client polls until it is done, printing progress
282
+ - `screening_outputs_ingest_status(zip_upload)` — status of a screening-output batch sent earlier
283
+
284
+ From the command line: `prisma-outputs list <screening_results>` shows the batches, `prisma-outputs send <screening_results> --dev --batch NAME` (or `--all`) sends them after asking (`--yes` skips the question; `--prod` targets production; a failed batch is reported with the server's error and the next is still sent), and `prisma-outputs status <upload> --prod` checks a batch sent earlier.
285
+
196
286
  ### Catalog and reference data
197
287
 
198
288
  - `get_molecules(name=None, limit=500, offset=0)`
@@ -203,6 +293,8 @@ All methods below are available on `api.v2`.
203
293
  - `get_region(region_id)`
204
294
  - `get_sources(name=None, limit=500, offset=0)`
205
295
  - `get_source(source_id)`
296
+ - `get_scopes(name=None, limit=500, offset=0)`
297
+ - `get_scope(scope_id)`
206
298
  - `get_sinks(name=None, limit=500, offset=0)`
207
299
  - `get_sink(sink_id)`
208
300
  - `get_transport_scenarios(name=None, limit=500, offset=0)`
@@ -379,12 +471,22 @@ pytest tests/ -v --cov=prisma_api --cov-report=term-missing
379
471
  - [API_REFERENCE_V1.md](API_REFERENCE_V1.md)
380
472
  - [API_REFERENCE_V2.md](API_REFERENCE_V2.md)
381
473
  - [DEVELOPMENT_SUMMARY.md](DEVELOPMENT_SUMMARY.md)
382
- - [User Guide.md](User%20Guide.md)
474
+ - [user_guide.md](user_guide.md)
475
+ - Release notes, one file per minor series: [v0.4.x](https://github.com/RCCS-CaptureTeam/prisma_api/blob/main/docs/release_notes/v0.4.x.md), [v0.3.x](https://github.com/RCCS-CaptureTeam/prisma_api/blob/main/docs/release_notes/v0.3.x.md), [v0.2.x](https://github.com/RCCS-CaptureTeam/prisma_api/blob/main/docs/release_notes/v0.2.x.md)
476
+
477
+ ## Release notes
478
+
479
+ Plain-language notes for every release, newest first, are in
480
+ [docs/release_notes/](https://github.com/RCCS-CaptureTeam/prisma_api/tree/main/docs/release_notes). Each release section links to its
481
+ GitHub release and to the full diff from the previous release. Check them
482
+ before upgrading for breaking changes and deprecations.
383
483
 
384
484
  ## Notes
385
485
 
386
486
  - Production v2 base URL: `https://prisma-platform.org/api/v2`
387
487
  - Authentication header: `X-API-Key`
388
488
  - Local development routing is selected with `prisma_api.init(local_dev=True)`; the default targets production
489
+ - Server compatibility notes for recent releases are below; see [docs/release_notes/](https://github.com/RCCS-CaptureTeam/prisma_api/tree/main/docs/release_notes) for the full history
389
490
  - 0.4.4: the `adsorption-isotherm` endpoints and the 400/notice handling need prisma_cloud >= 0.6.16
390
491
  - 0.4.5: H2 isotherms go through `upsert_adsorption_isotherm` (prisma_cloud >= 0.6.16); the H2-only methods and the `isotherm_H2s` collection key are deprecated. New `upsert_autoprism_cifs` uses the existing bundle upsert endpoint. AutoPrism getters take `match="exact"`.
492
+ - 0.4.6: case-study library sync methods (`upsert_case_study_library` and the export, sync-run and stale-record readers) for the prisma_cloud `case-study-library` endpoints, which replace ingest pipeline 11.
@@ -0,0 +1,166 @@
1
+ ---
2
+ name: prisma-dataset
3
+ description: Build or update prisma_manifest.yaml for the files ticked in this folder's PrISMa folder tree, check it with the platform's dry run, and send the data, in one command such as `/prisma-dataset my-dataset --tag "My tag" --prod` (the dataset page shows it above the folder tree). Use when asked to prepare, package, send or update this dataset for PrISMa, to write or fix the manifest, or after new results were added to the folder.
4
+ argument-hint: '<dataset-slug> --tag "<tag>" [--dev | --prod]'
5
+ ---
6
+
7
+ # Build the manifest and send this folder to PrISMa
8
+
9
+ Arguments: `$ARGUMENTS`
10
+
11
+ The dataset page on the platform gives these arguments, in the command above its
12
+ **View folder tree**:
13
+
14
+ - the dataset slug (first);
15
+ - the tag the records go under (`--tag "..."`; there may be more than one);
16
+ - the server: `--prod` for the platform, `--dev` for a local development server.
17
+
18
+ If the slug or the tag is missing, ask the user to copy the command from the
19
+ dataset page; don't invent either. With no server flag, use `--prod`. Below,
20
+ `<server>`, `<slug>` and `<tag>` stand for these arguments; use them in every
21
+ command.
22
+
23
+ The folder belongs to the researchers: never move, rename or edit their files.
24
+ The only file you write is `prisma_manifest.yaml` at the folder root. The
25
+ format is in [manifest_guide.md](manifest_guide.md); read it first.
26
+
27
+ `prisma-dataset` comes with the `prisma_api` package. If it is missing, say so
28
+ and suggest `pip install prisma_api`. If commands report a missing API key,
29
+ suggest `python -c "import prisma_api; prisma_api.init()"` (with
30
+ `local_dev=True` inside `init(...)` for `--dev`).
31
+
32
+ ## 1. Find the files to send
33
+
34
+ ```bash
35
+ prisma-dataset ticked . <server> --dataset <slug>
36
+ prisma-dataset ticked . <server> --dataset <slug> --json # the same, for reading
37
+ ```
38
+
39
+ This lists the files the user ticked "in dataset" in the platform's folder tree,
40
+ with the dataset's title and tags. Only these files are sent, so the manifest
41
+ must cover every one of them; files that are not ticked need no source.
42
+
43
+ - **No tree yet:** the user first sends the folder structure with the dataset page's **Add un-managed dataset** command (`prisma-dataset tree . <server> --dataset <slug> --tag "<tag>"`), then ticks files in **View folder tree**. Give them that, and stop.
44
+ - **Nothing ticked:** ask them to tick the files to send on the dataset page, and stop.
45
+ - **"Newer than the tree":** these files are not sent. If the user wants them, they resend the tree (`prisma-dataset tree . <server>`) and tick them. Mention them in the hand-over.
46
+ - **"[by others]":** the user marked these files as data by others. Give their sources `by_others: true`.
47
+
48
+ ## 2. Learn what the platform can store
49
+
50
+ ```bash
51
+ prisma-dataset targets <server>
52
+ prisma-dataset targets <server> --json # the full catalogue, including defaults and allowed keys
53
+ ```
54
+
55
+ Base every target name, field name and key on this output, never on memory.
56
+ Targets whose fields are "any names you choose" take any columns: use them for
57
+ data with no fixed table instead of skipping it.
58
+
59
+ **A typed target beats a generic one.** Read each target's description and
60
+ decide what the data *means* before choosing where it goes. Generic targets
61
+ (`run_results`, `run_inputs`) store a JSON blob per material: nothing in them is
62
+ a queryable record, and they do not appear as the data's own table on the
63
+ dataset page. Use `run_inputs` only for values a model run *consumed*, and
64
+ `run_results` only when no typed target fits. Measurements and simulation
65
+ outputs that the catalogue has a table for (for example isotherm points)
66
+ belong in that table.
67
+
68
+ ## 3. Profile the ticked files (read-only)
69
+
70
+ Work out the following. For many files, sample rather than reading them all.
71
+
72
+ - **File families:** files grouped by naming pattern, with their counts, and the columns or keys of each family. For a git repository, also note the recent history: `git log --stat`, and any change notes the authors wrote.
73
+ - **The id column** of each family, and how ids are spelled across families: suffixes such as `.cif`, case differences, and names of benchmarks that are not materials.
74
+ - **Variants encoded in paths:** cases, conditions, model versions. Each distinct variant becomes a run.
75
+ - **PrISMa v2 flowsheet outputs:** results keyed by flowsheet node (a run store, `run_flowsheet` output, columns or JSON paths such as `tea/ncac_...` or `lca.climate_change`) are the results of a v2 screening analysis. Note the case (e.g. `cases/dac_min/dac_min.json`) and the run id; step 4 links the run to the analysis.
76
+ - **Rollups and copies:** which files summarise others (prefer the rollup where it is complete), and which are identical copies (compare hashes).
77
+ - **Units:** take them from column headers, READMEs and notebooks. Record only conditions you can source.
78
+ - **Wide files:** a file with one column per condition holding the same quantity (`223_K_5_bar`, `223_K_10_bar`, `uptake_30bar`, ...) is a *set of points*, not a set of unrelated columns. Work out the quantity (what is measured, its units), the condition each column stands for (pressure, temperature, time, ...) and the fixed conditions (gas, temperature). Several columns of one quantity at different conditions is the shape of an isotherm or any other curve.
79
+ - **How each value was obtained:** look for a column of notes or a source (`source`, `method`, `origin`) and for flag columns. Values in one file often come from different calculations: simulated or measured, rescaled from another temperature (Clausius-Clapeyron), fitted (Langmuir), interpolated, or not computed at all. Read the distinct texts (`sort | uniq -c`) and note which values each applies to, since a text may cover only some columns. This is data, not decoration: keep it with the values (step 4).
80
+
81
+ ## 4. Build or update the manifest
82
+
83
+ If `prisma_manifest.yaml` exists, update it. Keep the authors' sources, runs,
84
+ comments and decisions. Add sources for ticked files that no source reads, and
85
+ fix what is out of date. Leave sources whose files are all unticked in place;
86
+ they are simply not sent. Otherwise write a new one with these sections, in
87
+ this order:
88
+
89
+ 1. `dataset`
90
+ 2. `material_id`
91
+ 3. `reference_systems`
92
+ 4. `parameter_sets`
93
+ 5. `runs`
94
+ 6. `sources`
95
+
96
+ The `dataset` section:
97
+
98
+ - `slug`: the `<slug>` argument.
99
+ - `tag`: the `<tag>` argument (a list if there are several).
100
+ - `name`: the dataset's title from step 1.
101
+ - `by_others`: keep the manifest's value. In a new manifest write `by_others: false # our own data` and point it out in the hand-over. It decides whether the data may appear in the platform's Zenodo publications.
102
+
103
+ If an existing manifest names another slug or tag, replace it with the
104
+ argument and tell the user. The exception is a slug the step 1 output lists
105
+ under `lineage` (an older version of the same dataset); that one may stay.
106
+
107
+ For the other sections:
108
+
109
+ - Map each family to the best target in the catalogue. Map columns to the target's fields; for "any names you choose" targets, pick short snake_case names and give their `units`.
110
+ - A wide file of one quantity at several conditions goes to the catalogue's curve or point target (today `isotherms`: one stored row per material and pressure) with the condition of each column declared in the manifest, never to `run_inputs` or `run_results` as one column per condition. If the catalogue has no such target, say so in the hand-over instead of quietly storing the columns under chosen names.
111
+ - Do not drop how a value was obtained. Where the target can record a basis for each value (`isotherms` has `basis_column` and `basis_rules`), read the distinct notes from step 3 and write one rule per calculation, listing the conditions it applies to; the default basis is what the rest were. Keep the authors' own text (it is stored beside the value) and map flag columns to the target's quality column.
112
+ - For PrISMa v2 flowsheet outputs, give the run `screening_analysis: <analysis name>` (ask the user for the name if the files do not make it certain), send the per-material outputs to `run_results`, and name each column `<node_id>.<output>` after the node in the case's flowsheet, with `units` for every column. Without the node prefix an output only reaches the study page's Visualiser, not its TEA, LCA or Process tab.
113
+ - Use `rows: supplement` for per-material data that should join onto each run's records. Keep `rows: create` on the files that define which materials a run covered.
114
+ - Give every ticked file a source. Put ticked files that hold nothing to ingest (plots, notebooks, copies, partial or temporary files) under `target: skip` with a specific reason.
115
+ - Comment judgement calls in the YAML, e.g. `# 2,525 of 8,236 rows; the full file is X`.
116
+
117
+ ## 5. Check until clean
118
+
119
+ ```bash
120
+ prisma-dataset validate . <server>
121
+ prisma-dataset send . <server> --json # pack the ticked files and dry run: writes nothing
122
+ ```
123
+
124
+ Fix every error and repeat. Then read the dry-run counts critically:
125
+
126
+ - Rows per run should match the records in that run's files. For a typed target, find its own table in the dry-run counts (e.g. `adsorption_isotherm: created N`). If the data you meant to store as records only shows as `AnalysisRunInput` / `AnalysisResult`, or the table is absent, the source is on the wrong target: go back to step 4.
127
+ - Blank values make no record. The run's report gives how many were skipped (`isotherm_blank_points`); that should match the empty cells you saw when profiling.
128
+ - Unexpected "materials created" usually mean id spellings need `strip_suffixes` or reference-system `aliases`.
129
+ - Any deletions should be explained.
130
+
131
+ A refusal about the dataset or the tag (no such dataset, deprecated, tag in use
132
+ elsewhere) is not a manifest problem: tell the user what the platform said and
133
+ stop.
134
+
135
+ ## 6. Confirm, then send
136
+
137
+ Summarise for the user:
138
+
139
+ - the runs, with their row counts
140
+ - the benchmarks
141
+ - what was skipped and why
142
+ - the dataset version the upload will make (`version` in the dry run)
143
+ - `by_others`, if you set it
144
+ - files that are newer than the tree, or ticked but missing
145
+ - data problems the authors should check: outliers, files that shrank, partial runs
146
+
147
+ Then ask once: "Send this to the platform (`<server>`)?" Only on a clear yes, run:
148
+
149
+ ```bash
150
+ prisma-dataset send . <server> --apply
151
+ ```
152
+
153
+ Report the version it made and the dataset page link.
154
+
155
+ Never run `send --apply` or `upload --apply` without that yes. It writes to the
156
+ platform and removes records that are no longer in the package.
157
+
158
+ ## Later updates
159
+
160
+ Run the same command again after new results arrive. The manifest is updated
161
+ the same way, and a send that changes records makes a minor version.
162
+
163
+ If files were added or removed, the user resends the tree first
164
+ (`prisma-dataset tree . <server>`) and ticks the new files. Once data has been
165
+ sent, a changed file list makes a new major version, `<slug>-v2` tagged
166
+ `"<tag> v2"`. The tree command prints the new command to use.