prisma-api 0.3.0__tar.gz → 0.3.1__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.
- prisma_api-0.3.1/PKG-INFO +396 -0
- prisma_api-0.3.1/README.md +376 -0
- {prisma_api-0.3.0 → prisma_api-0.3.1}/prisma_api/__init__.py +1 -1
- prisma_api-0.3.1/prisma_api.egg-info/PKG-INFO +396 -0
- {prisma_api-0.3.0 → prisma_api-0.3.1}/pyproject.toml +1 -1
- prisma_api-0.3.0/PKG-INFO +0 -245
- prisma_api-0.3.0/README.md +0 -225
- prisma_api-0.3.0/prisma_api.egg-info/PKG-INFO +0 -245
- {prisma_api-0.3.0 → prisma_api-0.3.1}/LICENSE +0 -0
- {prisma_api-0.3.0 → prisma_api-0.3.1}/prisma_api/config.py +0 -0
- {prisma_api-0.3.0 → prisma_api-0.3.1}/prisma_api/prisma_api.py +0 -0
- {prisma_api-0.3.0 → prisma_api-0.3.1}/prisma_api/prisma_api_v2.py +0 -0
- {prisma_api-0.3.0 → prisma_api-0.3.1}/prisma_api.egg-info/SOURCES.txt +0 -0
- {prisma_api-0.3.0 → prisma_api-0.3.1}/prisma_api.egg-info/dependency_links.txt +0 -0
- {prisma_api-0.3.0 → prisma_api-0.3.1}/prisma_api.egg-info/requires.txt +0 -0
- {prisma_api-0.3.0 → prisma_api-0.3.1}/prisma_api.egg-info/top_level.txt +0 -0
- {prisma_api-0.3.0 → prisma_api-0.3.1}/setup.cfg +0 -0
- {prisma_api-0.3.0 → prisma_api-0.3.1}/tests/test_prisma_api.py +0 -0
- {prisma_api-0.3.0 → prisma_api-0.3.1}/tests/test_prisma_api_v2.py +0 -0
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: prisma_api
|
|
3
|
+
Version: 0.3.1
|
|
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
|
+
Author-email: RCCS-CaptureTeam <team@prisma-platform.org>
|
|
6
|
+
License: GNUv3
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: numpy>=1.21.0
|
|
11
|
+
Requires-Dist: pandas>=1.3.0
|
|
12
|
+
Requires-Dist: pyyaml>=6.0
|
|
13
|
+
Requires-Dist: platformdirs>=2.5.0
|
|
14
|
+
Requires-Dist: requests>=2.27.0
|
|
15
|
+
Provides-Extra: dev
|
|
16
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
17
|
+
Requires-Dist: pytest-cov>=5.0; extra == "dev"
|
|
18
|
+
Requires-Dist: responses>=0.25; extra == "dev"
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# PrISMa API
|
|
22
|
+
|
|
23
|
+
Python client for the PrISMa platform APIs.
|
|
24
|
+
|
|
25
|
+
This package provides:
|
|
26
|
+
|
|
27
|
+
- legacy v1 wrappers on the main `api` object
|
|
28
|
+
- a larger v2 REST client on `api.v2`
|
|
29
|
+
- local config-based API-key management
|
|
30
|
+
- optional local development routing via `api.update_dev_mode(True)`
|
|
31
|
+
|
|
32
|
+
PrISMa is a platform for numerical synthesis and assessment of metal-organic frameworks and related carbon-capture workflows.
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
### From PyPI
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install prisma_api
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### From source
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
git clone https://github.com/RCCS-CaptureTeam/prisma_api.git
|
|
46
|
+
cd prisma_api
|
|
47
|
+
pip install .
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Development install
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
git clone https://github.com/RCCS-CaptureTeam/prisma_api.git
|
|
54
|
+
cd prisma_api
|
|
55
|
+
pip install -e ".[dev]"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Requirements
|
|
59
|
+
|
|
60
|
+
- Python 3.10+
|
|
61
|
+
- Runtime dependencies are installed automatically from `pyproject.toml`
|
|
62
|
+
|
|
63
|
+
## Authentication and configuration
|
|
64
|
+
|
|
65
|
+
The client uses an API key stored in a local config file.
|
|
66
|
+
|
|
67
|
+
### First-time setup
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
import prisma_api
|
|
71
|
+
|
|
72
|
+
api = prisma_api.init()
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
On first use, the package creates a config file and prompts for an API key.
|
|
76
|
+
|
|
77
|
+
### Find the config path
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
from prisma_api.config import locate_config
|
|
81
|
+
|
|
82
|
+
print(locate_config())
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Typical locations:
|
|
86
|
+
|
|
87
|
+
- macOS/Linux: `~/.config/prisma_api/config.yaml`
|
|
88
|
+
- Windows: `%APPDATA%/prisma-api/prisma_api/config.yaml`
|
|
89
|
+
|
|
90
|
+
### Create or update the config programmatically
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
from prisma_api.config import create_config_file
|
|
94
|
+
|
|
95
|
+
create_config_file(api_key="YOUR_API_KEY_HERE")
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Environment-variable mode
|
|
99
|
+
|
|
100
|
+
If you do not want to use the config file:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
export PRISMA_API_KEY="YOUR_API_KEY_HERE"
|
|
104
|
+
export PRISMA_API_DEV="False"
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from prisma_api.prisma_api import prisma_api
|
|
109
|
+
|
|
110
|
+
api = prisma_api(use_config_file=False)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Quick start
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
import prisma_api
|
|
117
|
+
|
|
118
|
+
api = prisma_api.init()
|
|
119
|
+
|
|
120
|
+
# v2 list endpoints return JSON by default in the main client
|
|
121
|
+
materials = api.v2.list_materials(name="ABEX")
|
|
122
|
+
print(materials[:2])
|
|
123
|
+
|
|
124
|
+
# switch list endpoints to pandas DataFrames if preferred
|
|
125
|
+
api.set_return_format("dataframe")
|
|
126
|
+
materials_df = api.v2.list_materials(name="ABEX")
|
|
127
|
+
print(materials_df.head())
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Dev mode
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
import prisma_api
|
|
134
|
+
|
|
135
|
+
api = prisma_api.init()
|
|
136
|
+
api.update_dev_mode(True)
|
|
137
|
+
api = prisma_api.init()
|
|
138
|
+
|
|
139
|
+
flowsheet = api.v2.get_flowsheet(name="dac_min")
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Disable dev mode the same way:
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
api.update_dev_mode(False)
|
|
146
|
+
api = prisma_api.init()
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Return formats
|
|
150
|
+
|
|
151
|
+
All v2 list endpoints support two formats:
|
|
152
|
+
|
|
153
|
+
- `json`: returns `list[dict]`
|
|
154
|
+
- `dataframe`: returns `pandas.DataFrame`
|
|
155
|
+
|
|
156
|
+
Detail endpoints always return `dict`.
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
api.set_return_format("json")
|
|
160
|
+
records = api.v2.get_molecules()
|
|
161
|
+
|
|
162
|
+
api.set_return_format("dataframe")
|
|
163
|
+
df = api.v2.get_molecules()
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Main objects
|
|
167
|
+
|
|
168
|
+
- `prisma_api.init()`
|
|
169
|
+
Returns the main client object.
|
|
170
|
+
- `api`
|
|
171
|
+
Legacy v1 wrappers plus configuration helpers.
|
|
172
|
+
- `api.v2`
|
|
173
|
+
`PrismaAPIv2` instance with the v2 REST surface.
|
|
174
|
+
|
|
175
|
+
## v1 wrappers
|
|
176
|
+
|
|
177
|
+
The main client exposes these v1 methods:
|
|
178
|
+
|
|
179
|
+
- `get_mofs(payload={})`
|
|
180
|
+
- `get_carbon_isotherms(payload={})`
|
|
181
|
+
- `get_carbon_data_nested(payload={}, safe_names=False)`
|
|
182
|
+
- `get_materials_data(payload={}, separate_experimental=True)`
|
|
183
|
+
- `update_adsorption_singlepoint(df)`
|
|
184
|
+
- `update_heat_capacity_all_tidy(df)`
|
|
185
|
+
- `update_isotherm_h2(df)`
|
|
186
|
+
- `update_mofchecker(df)`
|
|
187
|
+
- `update_zeopp_metrics(df)`
|
|
188
|
+
|
|
189
|
+
Configuration helpers on the main client:
|
|
190
|
+
|
|
191
|
+
- `set_return_format(fmt)`
|
|
192
|
+
- `update_dev_mode(dev)`
|
|
193
|
+
|
|
194
|
+
Module-level helpers exported from the package:
|
|
195
|
+
|
|
196
|
+
- `prisma_api.init`
|
|
197
|
+
- `prisma_api.PrismaAPIv2`
|
|
198
|
+
- `prisma_api.update_dev_mode`
|
|
199
|
+
- `prisma_api.update_dev_host_port`
|
|
200
|
+
- `prisma_api.locate_config`
|
|
201
|
+
|
|
202
|
+
## v2 wrapper list
|
|
203
|
+
|
|
204
|
+
All methods below are available on `api.v2`.
|
|
205
|
+
|
|
206
|
+
### Health and flowsheets
|
|
207
|
+
|
|
208
|
+
- `health()`
|
|
209
|
+
- `get_flowsheet(name="dac_min")`
|
|
210
|
+
|
|
211
|
+
### Materials and bundles
|
|
212
|
+
|
|
213
|
+
- `list_materials(name=None, limit=10000)`
|
|
214
|
+
- `get_material(material_id)`
|
|
215
|
+
- `get_materials_psdi(name=None, limit=500, offset=0)`
|
|
216
|
+
- `get_material_psdi(material_id)`
|
|
217
|
+
- `get_material_property_bundle(mof, sim_or_exp=None, good_structure=None, limit=500, offset=0, query=None)`
|
|
218
|
+
- `preflight_material_check(name)`
|
|
219
|
+
|
|
220
|
+
### Case bundles and pack builders
|
|
221
|
+
|
|
222
|
+
- `get_cases_bundle(name=None, source=None, sink=None, region=None, limit_cases=100, limit_props=2000)`
|
|
223
|
+
- `build_case_spec(case_id)`
|
|
224
|
+
- `build_scenario_spec(scenario_id)`
|
|
225
|
+
- `build_case_pack(case_id, scenario_id=None)`
|
|
226
|
+
- `list_case_packs(source=None, sink=None, region=None, study=None, include_scenarios=False, limit=100, offset=0)`
|
|
227
|
+
|
|
228
|
+
### Catalog and reference data
|
|
229
|
+
|
|
230
|
+
- `get_molecules(name=None, limit=500, offset=0)`
|
|
231
|
+
- `get_molecule(molecule_id)`
|
|
232
|
+
- `get_elements(symbol=None, name=None, limit=500, offset=0)`
|
|
233
|
+
- `get_element(element_id)`
|
|
234
|
+
- `get_regions(code=None, name=None, limit=500, offset=0)`
|
|
235
|
+
- `get_region(region_id)`
|
|
236
|
+
- `get_sources(name=None, limit=500, offset=0)`
|
|
237
|
+
- `get_source(source_id)`
|
|
238
|
+
- `get_sinks(name=None, limit=500, offset=0)`
|
|
239
|
+
- `get_sink(sink_id)`
|
|
240
|
+
- `get_transport_scenarios(name=None, limit=500, offset=0)`
|
|
241
|
+
- `get_transport_scenario(ts_id)`
|
|
242
|
+
- `get_utilities(name=None, limit=500, offset=0)`
|
|
243
|
+
- `get_utility(utility_id)`
|
|
244
|
+
- `get_references(name=None, doi=None, limit=500, offset=0)`
|
|
245
|
+
- `get_reference(ref_id)`
|
|
246
|
+
- `get_transports(name=None, limit=500, offset=0)`
|
|
247
|
+
- `get_transport(transport_id)`
|
|
248
|
+
- `get_subsystems(name=None, type=None, limit=500, offset=0)`
|
|
249
|
+
- `get_subsystem(subsystem_id)`
|
|
250
|
+
- `get_properties(name=None, domain=None, category=None, object_id=None, limit=500, offset=0)`
|
|
251
|
+
- `get_property(property_id)`
|
|
252
|
+
- `get_equipment(name=None, group=None, limit=500, offset=0)`
|
|
253
|
+
- `get_equipment_item(equipment_id)`
|
|
254
|
+
- `get_equipment_costs(equipment_id=None, limit=500, offset=0)`
|
|
255
|
+
- `get_equipment_cost(cost_id)`
|
|
256
|
+
- `get_equipment_designs(equipment_id=None, key=None, limit=500, offset=0)`
|
|
257
|
+
- `get_equipment_design(design_id)`
|
|
258
|
+
- `get_process_conditions(name=None, type=None, limit=500, offset=0)`
|
|
259
|
+
- `get_process_condition(condition_id)`
|
|
260
|
+
- `get_process_configurations(name=None, type=None, limit=500, offset=0)`
|
|
261
|
+
- `get_process_configuration(config_id)`
|
|
262
|
+
- `get_contactor_configurations(name=None, type=None, limit=500, offset=0)`
|
|
263
|
+
- `get_contactor_configuration(config_id)`
|
|
264
|
+
- `get_cost_indices(year=None, limit=500, offset=0)`
|
|
265
|
+
- `get_cost_index(index_id)`
|
|
266
|
+
- `get_constants(param=None, limit=500, offset=0)`
|
|
267
|
+
- `get_constant(constant_id)`
|
|
268
|
+
- `get_mea_baselines(name=None, limit=500, offset=0)`
|
|
269
|
+
- `get_mea_baseline(mea_id)`
|
|
270
|
+
- `get_mea_kpis(name=None, category=None, limit=500, offset=0)`
|
|
271
|
+
- `get_mea_kpi(kpi_id)`
|
|
272
|
+
|
|
273
|
+
### Science data
|
|
274
|
+
|
|
275
|
+
- `get_isotherm(mof=None, molecule=None, temperature_min=None, temperature_max=None, sim_or_exp=None, good_structure=None, limit=500, offset=0)`
|
|
276
|
+
- `get_water_kpis(mof=None, molecule=None, source=None, sim_or_exp=None, good_structure=None, limit=500, offset=0)`
|
|
277
|
+
- `get_carbon_zeopp(mof=None, good_structure=None, limit=500, offset=0)`
|
|
278
|
+
- `get_carbon_zeopp_item(item_id)`
|
|
279
|
+
- `get_carbon_zeopp_experimental(mof=None, limit=500, offset=0)`
|
|
280
|
+
- `get_carbon_zeopp_experimental_item(item_id)`
|
|
281
|
+
|
|
282
|
+
### TEA, LCA, cases, and scenarios
|
|
283
|
+
|
|
284
|
+
- `get_output_kpis(scenario_id=None, mof=None, good_structure=None, limit=500, offset=0)`
|
|
285
|
+
- `get_output_kpi(kpi_id)`
|
|
286
|
+
- `upsert_output_kpis(df)`
|
|
287
|
+
- `get_region_costs(region=None, name=None, year=None, limit=500, offset=0)`
|
|
288
|
+
- `get_region_cost(rc_id)`
|
|
289
|
+
- `upsert_region_costs(df)`
|
|
290
|
+
- `get_ambient_parameters(name=None, limit=500, offset=0)`
|
|
291
|
+
- `get_ambient_parameter(ap_id)`
|
|
292
|
+
- `upsert_ambient_parameters(df)`
|
|
293
|
+
- `get_cases(source=None, sink=None, region=None, study=None, limit=500, offset=0)`
|
|
294
|
+
- `get_case(case_id)`
|
|
295
|
+
- `get_scenarios(case_id=None, name=None, type=None, limit=500, offset=0)`
|
|
296
|
+
- `get_scenario(scenario_id)`
|
|
297
|
+
- `get_screening_summaries(scenario_id=None, limit=500, offset=0)`
|
|
298
|
+
- `get_screening_summary(summary_id)`
|
|
299
|
+
|
|
300
|
+
## Examples
|
|
301
|
+
|
|
302
|
+
### Materials
|
|
303
|
+
|
|
304
|
+
```python
|
|
305
|
+
import prisma_api
|
|
306
|
+
|
|
307
|
+
api = prisma_api.init()
|
|
308
|
+
|
|
309
|
+
materials = api.v2.list_materials(name="ABEX")
|
|
310
|
+
first = materials[0]
|
|
311
|
+
detail = api.v2.get_material(first["id"])
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### PSDI detail
|
|
315
|
+
|
|
316
|
+
```python
|
|
317
|
+
psdi = api.v2.get_materials_psdi(name="Lewatit")
|
|
318
|
+
first_psdi = psdi[0]
|
|
319
|
+
record = api.v2.get_material_psdi(first_psdi["id"])
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Flowsheet retrieval
|
|
323
|
+
|
|
324
|
+
```python
|
|
325
|
+
flowsheet = api.v2.get_flowsheet(name="dac_min")
|
|
326
|
+
print(flowsheet["template_id"])
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Advanced property-bundle query
|
|
330
|
+
|
|
331
|
+
`get_material_property_bundle` supports a generic query dictionary for more complex endpoint-specific filtering.
|
|
332
|
+
|
|
333
|
+
Supported keys are:
|
|
334
|
+
|
|
335
|
+
- `common`
|
|
336
|
+
- `materials`
|
|
337
|
+
- `isotherms`
|
|
338
|
+
- `zeopp_simulated`
|
|
339
|
+
- `zeopp_experimental`
|
|
340
|
+
- `water_kpis`
|
|
341
|
+
|
|
342
|
+
Merge precedence is:
|
|
343
|
+
|
|
344
|
+
- defaults
|
|
345
|
+
- `common`
|
|
346
|
+
- endpoint-specific filters
|
|
347
|
+
|
|
348
|
+
```python
|
|
349
|
+
bundle = api.v2.get_material_property_bundle(
|
|
350
|
+
"HKUST",
|
|
351
|
+
good_structure=True,
|
|
352
|
+
query={
|
|
353
|
+
"common": {"limit": 50},
|
|
354
|
+
"materials": {"limit": 20},
|
|
355
|
+
"isotherms": {
|
|
356
|
+
"molecule": "CO2",
|
|
357
|
+
"temperature_min": 273,
|
|
358
|
+
"temperature_max": 350,
|
|
359
|
+
},
|
|
360
|
+
"water_kpis": {"source": "DAC"},
|
|
361
|
+
},
|
|
362
|
+
)
|
|
363
|
+
|
|
364
|
+
print(bundle.keys())
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
### Cases and scenarios
|
|
368
|
+
|
|
369
|
+
```python
|
|
370
|
+
cases = api.v2.get_cases(region="GB", limit=10)
|
|
371
|
+
case_id = cases[0]["id"]
|
|
372
|
+
|
|
373
|
+
case_detail = api.v2.get_case(case_id)
|
|
374
|
+
scenario_list = api.v2.get_scenarios(case_id=case_id)
|
|
375
|
+
case_pack = api.v2.build_case_pack(case_id)
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
## Testing
|
|
379
|
+
|
|
380
|
+
Run the test suite with:
|
|
381
|
+
|
|
382
|
+
```bash
|
|
383
|
+
pytest tests/ -v --cov=prisma_api --cov-report=term-missing
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
## Additional documentation
|
|
387
|
+
|
|
388
|
+
- [API_REFERENCE.md](API_REFERENCE.md)
|
|
389
|
+
- [DEVELOPMENT_SUMMARY.md](DEVELOPMENT_SUMMARY.md)
|
|
390
|
+
- [User Guide.md](User%20Guide.md)
|
|
391
|
+
|
|
392
|
+
## Notes
|
|
393
|
+
|
|
394
|
+
- Production v2 base URL: `https://prisma-platform.org/api/v2`
|
|
395
|
+
- Authentication header: `X-API-Key`
|
|
396
|
+
- Local development routing is controlled through config and `api.update_dev_mode(True)`
|