sapiopycommons 2025.2.6a419__py3-none-any.whl → 2025.2.6a421__py3-none-any.whl

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.

Potentially problematic release.


This version of sapiopycommons might be problematic. Click here for more details.

@@ -1,4 +1,5 @@
1
1
  import base64
2
+ import math
2
3
  from typing import Final, Mapping, Any
3
4
 
4
5
  from pandas import DataFrame
@@ -9,7 +10,7 @@ from sapiopylib.rest.pojo.DataRecord import DataRecord
9
10
  from sapiopylib.rest.pojo.chartdata.DashboardDefinition import GaugeChartDefinition
10
11
  from sapiopylib.rest.pojo.chartdata.DashboardEnums import ChartGroupingType, ChartOperationType, ChartType
11
12
  from sapiopylib.rest.pojo.chartdata.DashboardSeries import GaugeChartSeries
12
- from sapiopylib.rest.pojo.datatype.FieldDefinition import AbstractVeloxFieldDefinition
13
+ from sapiopylib.rest.pojo.datatype.FieldDefinition import AbstractVeloxFieldDefinition, FieldType
13
14
  from sapiopylib.rest.pojo.eln.ElnExperiment import ElnExperiment
14
15
  from sapiopylib.rest.pojo.eln.ExperimentEntry import ExperimentEntry
15
16
  from sapiopylib.rest.pojo.eln.ExperimentEntryCriteria import ElnEntryCriteria, ElnFormEntryUpdateCriteria, \
@@ -124,16 +125,21 @@ def create_experiment_details_from_json(user: SapioUser,
124
125
  # Determine which fields in the JSON can be used to create field definitions.
125
126
  fb = FieldBuilder()
126
127
  fields: list[AbstractVeloxFieldDefinition] = []
128
+ fields_by_name: dict[str, AbstractVeloxFieldDefinition] = {}
127
129
  valid_keys: list[str] = []
128
130
  display_to_field_name: dict[str, str] = {}
129
131
  for key, value in json_list[0].items():
130
132
  field_name: str = key.replace(" ", "_")
131
133
  display_to_field_name[key] = field_name
132
134
  if isinstance(value, str):
133
- fields.append(fb.string_field(field_name, display_name=key))
135
+ field = fb.string_field(field_name, display_name=key)
136
+ fields.append(field)
137
+ fields_by_name[field_name] = field
134
138
  valid_keys.append(key)
135
139
  elif isinstance(value, (int, float)):
136
- fields.append(fb.double_field(field_name, display_name=key, precision=3))
140
+ field = fb.double_field(field_name, display_name=key, precision=3)
141
+ fields.append(field)
142
+ fields_by_name[field_name] = field
137
143
  valid_keys.append(key)
138
144
 
139
145
  # Extract the valid field values from the JSON.
@@ -141,7 +147,12 @@ def create_experiment_details_from_json(user: SapioUser,
141
147
  for json_dict in json_list:
142
148
  field_map: dict[str, Any] = {}
143
149
  for key in valid_keys:
144
- field_map[display_to_field_name[key]] = json_dict.get(key)
150
+ # Watch out for NaN values or other special values.
151
+ val: Any = json_dict.get(key)
152
+ if (fields_by_name[key].data_field_type == FieldType.DOUBLE
153
+ and (not isinstance(val, (int, float))) or (isinstance(val, float) and math.isnan(val))):
154
+ val = None
155
+ field_map[display_to_field_name[key]] = val
145
156
  field_maps.append(field_map)
146
157
 
147
158
  detail_entry = ElnEntryCriteria(ElnEntryType.Table, entry_name,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: sapiopycommons
3
- Version: 2025.2.6a419
3
+ Version: 2025.2.6a421
4
4
  Summary: Official Sapio Python API Utilities Package
5
5
  Project-URL: Homepage, https://github.com/sapiosciences
6
6
  Author-email: Jonathan Steck <jsteck@sapiosciences.com>, Yechen Qiao <yqiao@sapiosciences.com>
@@ -15,7 +15,7 @@ sapiopycommons/datatype/attachment_util.py,sha256=_l2swuP8noIGAl4bwzBUEhr6YlN_OV
15
15
  sapiopycommons/datatype/data_fields.py,sha256=C6HpqtEuF0KsxhlBUprfyv1XguaXql3EYWVbh8y-IFU,4064
16
16
  sapiopycommons/datatype/pseudo_data_types.py,sha256=6TG7aJxgmUZ8FQkWBcgmbK5oy7AFFNtKOPpi1w1OOYA,27657
17
17
  sapiopycommons/elain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
- sapiopycommons/elain/tool_of_tools.py,sha256=OKH9OdATK7fjXux_X3eI-pzF7x-v_WnkxtOLmCaYuvE,24703
18
+ sapiopycommons/elain/tool_of_tools.py,sha256=laacUopEoExV5ayt7-UA1UeXczqDDJlt6AlRAug6dzQ,25237
19
19
  sapiopycommons/eln/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  sapiopycommons/eln/experiment_handler.py,sha256=8hmR7sawDo9K6iBwB44QSoxlH1M91inor7dfuXQ4LKs,69323
21
21
  sapiopycommons/eln/experiment_report_util.py,sha256=EA2Iq8gW17bSEI6lPoHYQQ-fDvG4O28RWOoTPXpOlUw,36640
@@ -57,7 +57,7 @@ sapiopycommons/webhook/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
57
57
  sapiopycommons/webhook/webhook_context.py,sha256=D793uLsb1691SalaPnBUk3rOSxn_hYLhdvkaIxjNXss,1909
58
58
  sapiopycommons/webhook/webhook_handlers.py,sha256=M5PMt-j7PpnzUQMUQDTvqwJUyJNxuFtC9wdnk5VRNpI,39703
59
59
  sapiopycommons/webhook/webservice_handlers.py,sha256=Y5dHx_UFWFuSqaoPL6Re-fsKYRuxvCWZ8bj6KSZ3jfM,14285
60
- sapiopycommons-2025.2.6a419.dist-info/METADATA,sha256=CHB96SeSgnLS8BhUqqSVQqpxglFo0xumGkZ8lJ5Qh78,3142
61
- sapiopycommons-2025.2.6a419.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
62
- sapiopycommons-2025.2.6a419.dist-info/licenses/LICENSE,sha256=HyVuytGSiAUQ6ErWBHTqt1iSGHhLmlC8fO7jTCuR8dU,16725
63
- sapiopycommons-2025.2.6a419.dist-info/RECORD,,
60
+ sapiopycommons-2025.2.6a421.dist-info/METADATA,sha256=90F0XGGSIBnyrH9EKr1tN-ej-0XNoGxKBBXOebv3898,3142
61
+ sapiopycommons-2025.2.6a421.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
62
+ sapiopycommons-2025.2.6a421.dist-info/licenses/LICENSE,sha256=HyVuytGSiAUQ6ErWBHTqt1iSGHhLmlC8fO7jTCuR8dU,16725
63
+ sapiopycommons-2025.2.6a421.dist-info/RECORD,,