sapiopycommons 2024.8.20a306__tar.gz → 2024.8.26a309__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.

Potentially problematic release.


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

Files changed (59) hide show
  1. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/PKG-INFO +1 -1
  2. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/pyproject.toml +1 -1
  3. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/callbacks/callback_util.py +3 -3
  4. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/eln/experiment_handler.py +1 -5
  5. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/files/file_bridge_handler.py +1 -1
  6. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/recordmodel/record_handler.py +50 -21
  7. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/.gitignore +0 -0
  8. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/LICENSE +0 -0
  9. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/README.md +0 -0
  10. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/__init__.py +0 -0
  11. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/callbacks/__init__.py +0 -0
  12. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/chem/IndigoMolecules.py +0 -0
  13. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/chem/Molecules.py +0 -0
  14. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/chem/__init__.py +0 -0
  15. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/customreport/__init__.py +0 -0
  16. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/customreport/column_builder.py +0 -0
  17. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/customreport/custom_report_builder.py +0 -0
  18. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/customreport/term_builder.py +0 -0
  19. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/datatype/__init__.py +0 -0
  20. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/datatype/attachment_util.py +0 -0
  21. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/eln/__init__.py +0 -0
  22. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/eln/experiment_report_util.py +0 -0
  23. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/eln/plate_designer.py +0 -0
  24. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/files/__init__.py +0 -0
  25. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/files/complex_data_loader.py +0 -0
  26. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/files/file_bridge.py +0 -0
  27. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/files/file_data_handler.py +0 -0
  28. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/files/file_util.py +0 -0
  29. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/files/file_validator.py +0 -0
  30. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/files/file_writer.py +0 -0
  31. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/general/__init__.py +0 -0
  32. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/general/accession_service.py +0 -0
  33. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/general/aliases.py +0 -0
  34. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/general/audit_log.py +0 -0
  35. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/general/custom_report_util.py +0 -0
  36. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/general/exceptions.py +0 -0
  37. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/general/popup_util.py +0 -0
  38. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/general/sapio_links.py +0 -0
  39. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/general/storage_util.py +0 -0
  40. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/general/time_util.py +0 -0
  41. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/multimodal/multimodal.py +0 -0
  42. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/multimodal/multimodal_data.py +0 -0
  43. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/processtracking/__init__.py +0 -0
  44. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/processtracking/endpoints.py +0 -0
  45. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/recordmodel/__init__.py +0 -0
  46. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/rules/__init__.py +0 -0
  47. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/rules/eln_rule_handler.py +0 -0
  48. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/rules/on_save_rule_handler.py +0 -0
  49. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/webhook/__init__.py +0 -0
  50. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/webhook/webhook_handlers.py +0 -0
  51. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/src/sapiopycommons/webhook/webservice_handlers.py +0 -0
  52. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/tests/_do_not_add_init_py_here +0 -0
  53. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/tests/accession_test.py +0 -0
  54. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/tests/bio_reg_test.py +0 -0
  55. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/tests/chem_test.py +0 -0
  56. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/tests/data_type_models.py +0 -0
  57. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/tests/kappa.chains.fasta +0 -0
  58. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/tests/mafft_test.py +0 -0
  59. {sapiopycommons-2024.8.20a306 → sapiopycommons-2024.8.26a309}/tests/test.gb +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: sapiopycommons
3
- Version: 2024.8.20a306
3
+ Version: 2024.8.26a309
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>
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "sapiopycommons"
7
- version='2024.08.20a306'
7
+ version='2024.08.26a309'
8
8
  authors = [
9
9
  { name="Jonathan Steck", email="jsteck@sapiosciences.com" },
10
10
  { name="Yechen Qiao", email="yqiao@sapiosciences.com" },
@@ -900,7 +900,7 @@ class CallbackUtil:
900
900
  return response
901
901
 
902
902
  def request_file(self, title: str, exts: list[str] | None = None,
903
- show_image_editor: bool = False, show_camera_button: bool = False) -> (str, bytes):
903
+ show_image_editor: bool = False, show_camera_button: bool = False) -> tuple[str, bytes]:
904
904
  """
905
905
  Request a single file from the user.
906
906
 
@@ -933,7 +933,7 @@ class CallbackUtil:
933
933
  return file_path, sink.data
934
934
 
935
935
  def request_files(self, title: str, exts: list[str] | None = None,
936
- show_image_editor: bool = False, show_camera_button: bool = False):
936
+ show_image_editor: bool = False, show_camera_button: bool = False) -> dict[str, bytes]:
937
937
  """
938
938
  Request multiple files from the user.
939
939
 
@@ -964,7 +964,7 @@ class CallbackUtil:
964
964
  return ret_dict
965
965
 
966
966
  @staticmethod
967
- def __verify_file(file_path: str, file_bytes: bytes, allowed_extensions: list[str]):
967
+ def __verify_file(file_path: str, file_bytes: bytes, allowed_extensions: list[str]) -> None:
968
968
  """
969
969
  Verify that the provided file was read (i.e. the file path and file bytes aren't None or empty) and that it
970
970
  has the correct file extension. Raises a user error exception if something about the file is incorrect.
@@ -330,11 +330,7 @@ class ExperimentHandler:
330
330
  :return: The data record for this experiment. None if it has no record.
331
331
  """
332
332
  if not hasattr(self, "_ExperimentHandler__exp_record"):
333
- drm = DataMgmtServer.get_data_record_manager(self.user)
334
- dt = self.__eln_exp.experiment_data_type_name
335
- results = drm.query_data_records_by_id(dt, [self.__eln_exp.experiment_record_id]).result_list
336
- # PR-46504: Set the exp_record to None if there are no results.
337
- self.__exp_record = results[0] if results else None
333
+ self.__exp_record = self.__protocol.get_record()
338
334
  if self.__exp_record is None and exception_on_none:
339
335
  raise SapioException(f"Experiment record not found for experiment with ID {self.__exp_id}.")
340
336
  return self.__exp_record
@@ -328,7 +328,7 @@ class Directory(FileBridgeObject):
328
328
  return {x: y for x, y in self.contents.items() if not y.is_file()}
329
329
 
330
330
 
331
- def split_path(file_path: str) -> (str, str):
331
+ def split_path(file_path: str) -> tuple[str, str]:
332
332
  """
333
333
  :param file_path: A file path where directories are separated the "/" characters.
334
334
  :return: A tuple of two strings that splits the path on its last slash. The first string is the name of the
@@ -92,7 +92,7 @@ class RecordHandler:
92
92
  return self.inst_man.add_existing_records_of_type(list(records), wrapper_type)
93
93
 
94
94
  def query_models(self, wrapper_type: type[WrappedType], field: FieldIdentifier, value_list: Iterable[FieldValue],
95
- page_limit: int | None = None) -> list[WrappedType]:
95
+ page_limit: int | None = None, page_size: int | None = None) -> list[WrappedType]:
96
96
  """
97
97
  Shorthand for using the data record manager to query for a list of data records by field value
98
98
  and then converting the results into a list of record models.
@@ -100,14 +100,20 @@ class RecordHandler:
100
100
  :param wrapper_type: The record model wrapper to use.
101
101
  :param field: The field to query on.
102
102
  :param value_list: The values of the field to query on.
103
- :param page_limit: The maximum number of pages to query. If None, exhausts all possible pages.
103
+ :param page_limit: The maximum number of pages to query. If None, exhausts all possible pages. This parameter
104
+ only functions if you set a page size or the platform enforces a page size.
105
+ :param page_size: The size of the pages to query. If None, the page size may be limited by the platform.
104
106
  :return: The record models for the queried records.
105
107
  """
106
- return self.query_models_with_criteria(wrapper_type, field, value_list, None, page_limit)[0]
108
+ criteria: DataRecordPojoPageCriteria | None = None
109
+ if page_size is not None:
110
+ criteria = DataRecordPojoPageCriteria(page_size=page_size)
111
+ return self.query_models_with_criteria(wrapper_type, field, value_list, criteria, page_limit)[0]
107
112
 
108
113
  def query_and_map_models(self, wrapper_type: type[WrappedType], field: FieldIdentifier,
109
114
  value_list: Iterable[FieldValue], page_limit: int | None = None,
110
- *, mapping_field: FieldIdentifier | None = None) -> dict[FieldValue, list[WrappedType]]:
115
+ page_size: int | None = None, *, mapping_field: FieldIdentifier | None = None) \
116
+ -> dict[FieldValue, list[WrappedType]]:
111
117
  """
112
118
  Shorthand for using query_models to search for records given values on a specific field and then using
113
119
  map_by_field to turn the returned list into a dictionary mapping field values to records.
@@ -115,17 +121,20 @@ class RecordHandler:
115
121
  :param wrapper_type: The record model wrapper to use.
116
122
  :param field: The field to query and map on.
117
123
  :param value_list: The values of the field to query on.
118
- :param page_limit: The maximum number of pages to query. If None, exhausts all possible pages.
124
+ :param page_limit: The maximum number of pages to query. If None, exhausts all possible pages. This parameter
125
+ only functions if you set a page size or the platform enforces a page size.
126
+ :param page_size: The size of the pages to query. If None, the page size may be limited by the platform.
119
127
  :param mapping_field: If provided, use this field to map against instead of the field that was queried on.
120
128
  :return: The record models for the queried records mapped by field values to the records with that value.
121
129
  """
122
130
  if mapping_field is None:
123
131
  mapping_field = field
124
- return self.map_by_field(self.query_models(wrapper_type, field, value_list, page_limit), mapping_field)
132
+ return self.map_by_field(self.query_models(wrapper_type, field, value_list, page_limit, page_size),
133
+ mapping_field)
125
134
 
126
135
  def query_and_unique_map_models(self, wrapper_type: type[WrappedType], field: FieldIdentifier,
127
136
  value_list: Iterable[FieldValue], page_limit: int | None = None,
128
- *, mapping_field: FieldIdentifier | None = None) \
137
+ page_size: int | None = None, *, mapping_field: FieldIdentifier | None = None) \
129
138
  -> dict[FieldValue, WrappedType]:
130
139
  """
131
140
  Shorthand for using query_models to search for records given values on a specific field and then using
@@ -135,13 +144,16 @@ class RecordHandler:
135
144
  :param wrapper_type: The record model wrapper to use.
136
145
  :param field: The field to query and map on.
137
146
  :param value_list: The values of the field to query on.
138
- :param page_limit: The maximum number of pages to query. If None, exhausts all possible pages.
147
+ :param page_limit: The maximum number of pages to query. If None, exhausts all possible pages. This parameter
148
+ only functions if you set a page size or the platform enforces a page size.
149
+ :param page_size: The size of the pages to query. If None, the page size may be limited by the platform.
139
150
  :param mapping_field: If provided, use this field to map against instead of the field that was queried on.
140
151
  :return: The record models for the queried records mapped by field values to the record with that value.
141
152
  """
142
153
  if mapping_field is None:
143
154
  mapping_field = field
144
- return self.map_by_unique_field(self.query_models(wrapper_type, field, value_list, page_limit), mapping_field)
155
+ return self.map_by_unique_field(self.query_models(wrapper_type, field, value_list, page_limit, page_size),
156
+ mapping_field)
145
157
 
146
158
  def query_models_with_criteria(self, wrapper_type: type[WrappedType], field: FieldIdentifier,
147
159
  value_list: Iterable[FieldValue],
@@ -157,7 +169,8 @@ class RecordHandler:
157
169
  :param value_list: The values of the field to query on.
158
170
  :param paging_criteria: The paging criteria to start the query with.
159
171
  :param page_limit: The maximum number of pages to query from the starting criteria. If None, exhausts all
160
- possible pages.
172
+ possible pages. This parameter only functions if you set a page size in the paging criteria or the platform
173
+ enforces a page size.
161
174
  :return: The record models for the queried records and the final paging criteria.
162
175
  """
163
176
  dt: str = wrapper_type.get_wrapper_data_type_name()
@@ -167,17 +180,22 @@ class RecordHandler:
167
180
  return self.wrap_models(pager.get_all_at_once(), wrapper_type), pager.next_page_criteria
168
181
 
169
182
  def query_models_by_id(self, wrapper_type: type[WrappedType], ids: Iterable[int],
170
- page_limit: int | None = None) -> list[WrappedType]:
183
+ page_limit: int | None = None, page_size: int | None = None) -> list[WrappedType]:
171
184
  """
172
185
  Shorthand for using the data record manager to query for a list of data records by record ID
173
186
  and then converting the results into a list of record models.
174
187
 
175
188
  :param wrapper_type: The record model wrapper to use.
176
189
  :param ids: The list of record IDs to query.
177
- :param page_limit: The maximum number of pages to query. If None, exhausts all possible pages.
190
+ :param page_limit: The maximum number of pages to query. If None, exhausts all possible pages. This parameter
191
+ only functions if you set a page size or the platform enforces a page size.
192
+ :param page_size: The size of the pages to query. If None, the page size may be limited by the platform.
178
193
  :return: The record models for the queried records.
179
194
  """
180
- return self.query_models_by_id_with_criteria(wrapper_type, ids, None, page_limit)[0]
195
+ criteria: DataRecordPojoPageCriteria | None = None
196
+ if page_size is not None:
197
+ criteria = DataRecordPojoPageCriteria(page_size=page_size)
198
+ return self.query_models_by_id_with_criteria(wrapper_type, ids, criteria, page_limit)[0]
181
199
 
182
200
  def query_models_by_id_with_criteria(self, wrapper_type: type[WrappedType], ids: Iterable[int],
183
201
  paging_criteria: DataRecordPojoPageCriteria | None = None,
@@ -191,7 +209,8 @@ class RecordHandler:
191
209
  :param ids: The list of record IDs to query.
192
210
  :param paging_criteria: The paging criteria to start the query with.
193
211
  :param page_limit: The maximum number of pages to query from the starting criteria. If None, exhausts all
194
- possible pages.
212
+ possible pages. This parameter only functions if you set a page size in the paging criteria or the platform
213
+ enforces a page size.
195
214
  :return: The record models for the queried records and the final paging criteria.
196
215
  """
197
216
  dt: str = wrapper_type.get_wrapper_data_type_name()
@@ -200,28 +219,37 @@ class RecordHandler:
200
219
  return self.wrap_models(pager.get_all_at_once(), wrapper_type), pager.next_page_criteria
201
220
 
202
221
  def query_models_by_id_and_map(self, wrapper_type: type[WrappedType], ids: Iterable[int],
203
- page_limit: int | None = None) -> dict[int, WrappedType]:
222
+ page_limit: int | None = None, page_size: int | None = None) \
223
+ -> dict[int, WrappedType]:
204
224
  """
205
225
  Shorthand for using the data record manager to query for a list of data records by record ID
206
226
  and then converting the results into a dictionary of record ID to the record model for that ID.
207
227
 
208
228
  :param wrapper_type: The record model wrapper to use.
209
229
  :param ids: The list of record IDs to query.
210
- :param page_limit: The maximum number of pages to query. If None, exhausts all possible pages.
230
+ :param page_limit: The maximum number of pages to query. If None, exhausts all possible pages. This parameter
231
+ only functions if you set a page size or the platform enforces a page size.
232
+ :param page_size: The size of the pages to query. If None, the page size may be limited by the platform.
211
233
  :return: The record models for the queried records mapped in a dictionary by their record ID.
212
234
  """
213
- return {x.record_id: x for x in self.query_models_by_id(wrapper_type, ids, page_limit)}
235
+ return {x.record_id: x for x in self.query_models_by_id(wrapper_type, ids, page_limit, page_size)}
214
236
 
215
- def query_all_models(self, wrapper_type: type[WrappedType], page_limit: int | None = None) -> list[WrappedType]:
237
+ def query_all_models(self, wrapper_type: type[WrappedType], page_limit: int | None = None,
238
+ page_size: int | None = None) -> list[WrappedType]:
216
239
  """
217
240
  Shorthand for using the data record manager to query for all data records of a given type
218
241
  and then converting the results into a list of record models.
219
242
 
220
243
  :param wrapper_type: The record model wrapper to use.
221
- :param page_limit: The maximum number of pages to query. If None, exhausts all possible pages.
244
+ :param page_limit: The maximum number of pages to query. If None, exhausts all possible pages. This parameter
245
+ only functions if you set a page size or the platform enforces a page size.
246
+ :param page_size: The size of the pages to query. If None, the page size may be limited by the platform.
222
247
  :return: The record models for the queried records.
223
248
  """
224
- return self.query_all_models_with_criteria(wrapper_type, None, page_limit)[0]
249
+ criteria: DataRecordPojoPageCriteria | None = None
250
+ if page_size is not None:
251
+ criteria = DataRecordPojoPageCriteria(page_size=page_size)
252
+ return self.query_all_models_with_criteria(wrapper_type, criteria, page_limit)[0]
225
253
 
226
254
  def query_all_models_with_criteria(self, wrapper_type: type[WrappedType],
227
255
  paging_criteria: DataRecordPojoPageCriteria | None = None,
@@ -234,7 +262,8 @@ class RecordHandler:
234
262
  :param wrapper_type: The record model wrapper to use.
235
263
  :param paging_criteria: The paging criteria to start the query with.
236
264
  :param page_limit: The maximum number of pages to query from the starting criteria. If None, exhausts all
237
- possible pages.
265
+ possible pages. This parameter only functions if you set a page size in the paging criteria or the platform
266
+ enforces a page size.
238
267
  :return: The record models for the queried records and the final paging criteria.
239
268
  """
240
269
  dt: str = wrapper_type.get_wrapper_data_type_name()