prisma-api 0.3.4__tar.gz → 0.3.5__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.4 → prisma_api-0.3.5}/PKG-INFO +1 -1
- {prisma_api-0.3.4 → prisma_api-0.3.5}/prisma_api/__init__.py +1 -1
- {prisma_api-0.3.4 → prisma_api-0.3.5}/prisma_api/prisma_api_v2.py +37 -0
- {prisma_api-0.3.4 → prisma_api-0.3.5}/prisma_api.egg-info/PKG-INFO +1 -1
- {prisma_api-0.3.4 → prisma_api-0.3.5}/pyproject.toml +1 -1
- {prisma_api-0.3.4 → prisma_api-0.3.5}/tests/test_prisma_api_v2.py +52 -0
- {prisma_api-0.3.4 → prisma_api-0.3.5}/LICENSE +0 -0
- {prisma_api-0.3.4 → prisma_api-0.3.5}/README.md +0 -0
- {prisma_api-0.3.4 → prisma_api-0.3.5}/prisma_api/config.py +0 -0
- {prisma_api-0.3.4 → prisma_api-0.3.5}/prisma_api/prisma_api.py +0 -0
- {prisma_api-0.3.4 → prisma_api-0.3.5}/prisma_api.egg-info/SOURCES.txt +0 -0
- {prisma_api-0.3.4 → prisma_api-0.3.5}/prisma_api.egg-info/dependency_links.txt +0 -0
- {prisma_api-0.3.4 → prisma_api-0.3.5}/prisma_api.egg-info/requires.txt +0 -0
- {prisma_api-0.3.4 → prisma_api-0.3.5}/prisma_api.egg-info/top_level.txt +0 -0
- {prisma_api-0.3.4 → prisma_api-0.3.5}/setup.cfg +0 -0
- {prisma_api-0.3.4 → prisma_api-0.3.5}/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.3.
|
|
3
|
+
Version: 0.3.5
|
|
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
|
|
@@ -140,6 +140,43 @@ class PrismaAPIv2:
|
|
|
140
140
|
"""
|
|
141
141
|
return self._get(f"/flowsheets/{name}/bundle/")
|
|
142
142
|
|
|
143
|
+
def upsert_flowsheets(
|
|
144
|
+
self,
|
|
145
|
+
flowsheets: pd.DataFrame | list[dict],
|
|
146
|
+
on_exists: str = "append",
|
|
147
|
+
appendix: str = "_v4",
|
|
148
|
+
) -> dict:
|
|
149
|
+
"""
|
|
150
|
+
PUT /api/v2/flowsheets/upsert/
|
|
151
|
+
|
|
152
|
+
Modes:
|
|
153
|
+
* append (default): ``?on_exists=append&appendix=<suffix>``
|
|
154
|
+
* overwrite: ``?on_exists=overwrite``
|
|
155
|
+
|
|
156
|
+
Args:
|
|
157
|
+
flowsheets: DataFrame or list of dict payload records.
|
|
158
|
+
on_exists: Conflict mode; one of ``'append'`` or ``'overwrite'``.
|
|
159
|
+
appendix: Suffix used only in append mode (default ``'_v4'``).
|
|
160
|
+
|
|
161
|
+
Returns:
|
|
162
|
+
API response dict.
|
|
163
|
+
"""
|
|
164
|
+
if on_exists not in ("append", "overwrite"):
|
|
165
|
+
raise ValueError("on_exists must be 'append' or 'overwrite'")
|
|
166
|
+
|
|
167
|
+
records = (
|
|
168
|
+
flowsheets.to_dict(orient="records")
|
|
169
|
+
if isinstance(flowsheets, pd.DataFrame)
|
|
170
|
+
else flowsheets
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
if on_exists == "overwrite":
|
|
174
|
+
path = "/flowsheets/upsert/?on_exists=overwrite"
|
|
175
|
+
else:
|
|
176
|
+
path = f"/flowsheets/upsert/?on_exists=append&appendix={appendix}"
|
|
177
|
+
|
|
178
|
+
return self._put(path, records)
|
|
179
|
+
|
|
143
180
|
# ── Catalog ───────────────────────────────────────────────────────────────
|
|
144
181
|
|
|
145
182
|
def list_materials(self, name: str | None = None,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: prisma_api
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.5
|
|
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
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "prisma_api"
|
|
7
|
-
version = "0.3.
|
|
7
|
+
version = "0.3.5"
|
|
8
8
|
description = "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."
|
|
9
9
|
authors = [
|
|
10
10
|
{name = "RCCS-CaptureTeam", email = "team@prisma-platform.org"}
|
|
@@ -1423,6 +1423,13 @@ def test_api_key_header_sent(api):
|
|
|
1423
1423
|
|
|
1424
1424
|
# ── Flowsheets ────────────────────────────────────────────────────────────────
|
|
1425
1425
|
|
|
1426
|
+
_UPSERT_FLOWSHEET_FIXTURE = "reference_data/prisma_v2/dac_min_2026-07-01.json"
|
|
1427
|
+
|
|
1428
|
+
|
|
1429
|
+
def _load_upsert_flowsheet_payload() -> list[dict]:
|
|
1430
|
+
with open(_UPSERT_FLOWSHEET_FIXTURE, "r", encoding="utf-8") as f:
|
|
1431
|
+
return [json.load(f)]
|
|
1432
|
+
|
|
1426
1433
|
@resp_lib.activate
|
|
1427
1434
|
@pytest.mark.skipif(
|
|
1428
1435
|
os.getenv("CI", "").lower() == "true",
|
|
@@ -1478,3 +1485,48 @@ def test_get_flowsheet_bundle_custom_name_routes_path(api):
|
|
|
1478
1485
|
json={"template_id": "custom_case"}, status=200)
|
|
1479
1486
|
result = api.get_flowsheet_bundle(name="custom_case")
|
|
1480
1487
|
assert result["template_id"] == "custom_case"
|
|
1488
|
+
|
|
1489
|
+
|
|
1490
|
+
@resp_lib.activate
|
|
1491
|
+
def test_upsert_flowsheets_default_append_mode(api):
|
|
1492
|
+
resp_lib.add(
|
|
1493
|
+
resp_lib.PUT,
|
|
1494
|
+
f"{PROD_BASE}/flowsheets/upsert/?on_exists=append&appendix=_v4",
|
|
1495
|
+
json={"created": 1, "updated": 0},
|
|
1496
|
+
status=200,
|
|
1497
|
+
)
|
|
1498
|
+
payload = _load_upsert_flowsheet_payload()
|
|
1499
|
+
result = api.upsert_flowsheets(payload)
|
|
1500
|
+
assert result["created"] == 1
|
|
1501
|
+
|
|
1502
|
+
|
|
1503
|
+
@resp_lib.activate
|
|
1504
|
+
def test_upsert_flowsheets_overwrite_mode(api):
|
|
1505
|
+
resp_lib.add(
|
|
1506
|
+
resp_lib.PUT,
|
|
1507
|
+
f"{PROD_BASE}/flowsheets/upsert/?on_exists=overwrite",
|
|
1508
|
+
json={"created": 0, "updated": 1},
|
|
1509
|
+
status=200,
|
|
1510
|
+
)
|
|
1511
|
+
payload = _load_upsert_flowsheet_payload()
|
|
1512
|
+
result = api.upsert_flowsheets(payload, on_exists="overwrite")
|
|
1513
|
+
assert result["updated"] == 1
|
|
1514
|
+
|
|
1515
|
+
|
|
1516
|
+
@resp_lib.activate
|
|
1517
|
+
def test_upsert_flowsheets_uses_dev_mode_base_url(dev_api):
|
|
1518
|
+
resp_lib.add(
|
|
1519
|
+
resp_lib.PUT,
|
|
1520
|
+
"http://localhost:8000/api/v2/flowsheets/upsert/?on_exists=append&appendix=_dev",
|
|
1521
|
+
json={"created": 1, "updated": 0},
|
|
1522
|
+
status=200,
|
|
1523
|
+
)
|
|
1524
|
+
payload = _load_upsert_flowsheet_payload()
|
|
1525
|
+
result = dev_api.upsert_flowsheets(payload, appendix="_dev")
|
|
1526
|
+
assert result["created"] == 1
|
|
1527
|
+
|
|
1528
|
+
|
|
1529
|
+
def test_upsert_flowsheets_rejects_invalid_on_exists(api):
|
|
1530
|
+
payload = _load_upsert_flowsheet_payload()
|
|
1531
|
+
with pytest.raises(ValueError):
|
|
1532
|
+
api.upsert_flowsheets(payload, on_exists="replace")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|