prisma-api 0.3.6__tar.gz → 0.3.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: prisma_api
3
- Version: 0.3.6
3
+ Version: 0.3.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
@@ -20,8 +20,8 @@ Dynamic: license-file
20
20
 
21
21
  # PrISMa API
22
22
 
23
- ![Tests](https://img.shields.io/badge/tests-passing-brightgreen)
24
- ![Coverage](https://img.shields.io/badge/test%20coverage-passing-brightgreen)
23
+ [![CI](https://github.com/RCCS-CaptureTeam/prisma_api/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/RCCS-CaptureTeam/prisma_api/actions/workflows/ci.yml)
24
+ [![Coverage](https://codecov.io/gh/RCCS-CaptureTeam/prisma_api/graph/badge.svg?branch=main)](https://codecov.io/gh/RCCS-CaptureTeam/prisma_api)
25
25
 
26
26
  Python client for the PrISMa platform APIs.
27
27
 
@@ -1,7 +1,7 @@
1
1
  # PrISMa API
2
2
 
3
- ![Tests](https://img.shields.io/badge/tests-passing-brightgreen)
4
- ![Coverage](https://img.shields.io/badge/test%20coverage-passing-brightgreen)
3
+ [![CI](https://github.com/RCCS-CaptureTeam/prisma_api/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/RCCS-CaptureTeam/prisma_api/actions/workflows/ci.yml)
4
+ [![Coverage](https://codecov.io/gh/RCCS-CaptureTeam/prisma_api/graph/badge.svg?branch=main)](https://codecov.io/gh/RCCS-CaptureTeam/prisma_api)
5
5
 
6
6
  Python client for the PrISMa platform APIs.
7
7
 
@@ -1,4 +1,4 @@
1
- __version__ = "0.3.6"
1
+ __version__ = "0.3.7"
2
2
 
3
3
 
4
4
  from prisma_api.prisma_api import prisma_api as init # Main prisma_api class for initialisation
@@ -20,6 +20,7 @@ import pandas as pd
20
20
  import requests
21
21
  from typing import Any
22
22
  from urllib.parse import urlencode
23
+ import warnings
23
24
 
24
25
 
25
26
  _BASE_PROD = "https://prisma-platform.org/api/v2"
@@ -144,7 +145,7 @@ class PrismaAPIv2:
144
145
  def upsert_flowsheets(
145
146
  self,
146
147
  flowsheets: pd.DataFrame | list[dict],
147
- screening_analysis_name: str,
148
+ screening_analysis_name: str | None = None,
148
149
  on_exists: str = "append",
149
150
  appendix: str = "_v4",
150
151
  ) -> dict:
@@ -157,8 +158,10 @@ class PrismaAPIv2:
157
158
 
158
159
  Args:
159
160
  flowsheets: DataFrame or list of dict payload records.
160
- screening_analysis_name: Required analysis identifier forwarded to the
161
- API for upsert attribution/routing.
161
+ screening_analysis_name: Optional analysis identifier forwarded to the
162
+ API for upsert attribution/routing. For production uploads this
163
+ should be set and should match one of the nested screening
164
+ analysis names returned by ``list_case_studies()``.
162
165
  on_exists: Conflict mode; one of ``'append'`` or ``'overwrite'``.
163
166
  appendix: Suffix used only in append mode (default ``'_v4'``).
164
167
 
@@ -167,30 +170,33 @@ class PrismaAPIv2:
167
170
  """
168
171
  if on_exists not in ("append", "overwrite"):
169
172
  raise ValueError("on_exists must be 'append' or 'overwrite'")
170
- if not screening_analysis_name or not screening_analysis_name.strip():
171
- raise ValueError("screening_analysis_name must be a non-empty string")
172
173
 
173
174
  records = (
174
175
  flowsheets.to_dict(orient="records")
175
176
  if isinstance(flowsheets, pd.DataFrame)
176
177
  else flowsheets
177
178
  )
179
+ cleaned_screening_name = (screening_analysis_name or "").strip()
178
180
 
179
- if on_exists == "overwrite":
180
- query = urlencode(
181
- {
182
- "on_exists": "overwrite",
183
- "screening_analysis_name": screening_analysis_name,
184
- }
185
- )
181
+ query_params: dict[str, str] = (
182
+ {"on_exists": "overwrite"}
183
+ if on_exists == "overwrite"
184
+ else {"on_exists": "append", "appendix": appendix}
185
+ )
186
+
187
+ if cleaned_screening_name:
188
+ query_params["screening_analysis_name"] = cleaned_screening_name
186
189
  else:
187
- query = urlencode(
188
- {
189
- "on_exists": "append",
190
- "appendix": appendix,
191
- "screening_analysis_name": screening_analysis_name,
192
- }
190
+ warnings.warn(
191
+ "Uploading flowsheets without screening_analysis_name is intended "
192
+ "for experimentation only and is not recommended for production. "
193
+ "Provide screening_analysis_name matching one of the nested "
194
+ "screening analysis names returned by list_case_studies().",
195
+ UserWarning,
196
+ stacklevel=2,
193
197
  )
198
+
199
+ query = urlencode(query_params)
194
200
  path = f"/flowsheets/upsert/?{query}"
195
201
 
196
202
  return self._put(path, records)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: prisma_api
3
- Version: 0.3.6
3
+ Version: 0.3.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
@@ -20,8 +20,8 @@ Dynamic: license-file
20
20
 
21
21
  # PrISMa API
22
22
 
23
- ![Tests](https://img.shields.io/badge/tests-passing-brightgreen)
24
- ![Coverage](https://img.shields.io/badge/test%20coverage-passing-brightgreen)
23
+ [![CI](https://github.com/RCCS-CaptureTeam/prisma_api/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/RCCS-CaptureTeam/prisma_api/actions/workflows/ci.yml)
24
+ [![Coverage](https://codecov.io/gh/RCCS-CaptureTeam/prisma_api/graph/badge.svg?branch=main)](https://codecov.io/gh/RCCS-CaptureTeam/prisma_api)
25
25
 
26
26
  Python client for the PrISMa platform APIs.
27
27
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "prisma_api"
7
- version = "0.3.6"
7
+ version = "0.3.7"
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"}
@@ -1571,11 +1571,29 @@ def test_upsert_flowsheets_rejects_invalid_on_exists(api):
1571
1571
  )
1572
1572
 
1573
1573
 
1574
- @pytest.mark.skipif(
1575
- os.getenv("PRISMA_API_PRODUCTION_BYPASS", "").lower() == "true",
1576
- reason="Bypassed in production mode",
1577
- )
1578
- def test_upsert_flowsheets_rejects_empty_screening_analysis_name(api):
1574
+ @resp_lib.activate
1575
+ def test_upsert_flowsheets_allows_missing_screening_analysis_name_with_warning(api):
1576
+ resp_lib.add(
1577
+ resp_lib.PUT,
1578
+ f"{PROD_BASE}/flowsheets/upsert/?on_exists=append&appendix=_v4",
1579
+ json={"created": 1, "updated": 0},
1580
+ status=200,
1581
+ )
1579
1582
  payload = _load_upsert_flowsheet_payload()
1580
- with pytest.raises(ValueError):
1581
- api.upsert_flowsheets(payload, screening_analysis_name=" ")
1583
+ with pytest.warns(UserWarning, match="for experimentation only"):
1584
+ result = api.upsert_flowsheets(payload)
1585
+ assert result["created"] == 1
1586
+
1587
+
1588
+ @resp_lib.activate
1589
+ def test_upsert_flowsheets_blank_screening_analysis_name_warns_and_omits_query_param(api):
1590
+ resp_lib.add(
1591
+ resp_lib.PUT,
1592
+ f"{PROD_BASE}/flowsheets/upsert/?on_exists=overwrite",
1593
+ json={"created": 0, "updated": 1},
1594
+ status=200,
1595
+ )
1596
+ payload = _load_upsert_flowsheet_payload()
1597
+ with pytest.warns(UserWarning, match="list_case_studies"):
1598
+ result = api.upsert_flowsheets(payload, screening_analysis_name=" ", on_exists="overwrite")
1599
+ assert result["updated"] == 1
File without changes
File without changes