sapiopycommons 2024.11.7a354__py3-none-any.whl → 2024.11.8a359__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.

Files changed (47) hide show
  1. sapiopycommons/callbacks/callback_util.py +83 -532
  2. sapiopycommons/chem/IndigoMolecules.py +0 -2
  3. sapiopycommons/chem/Molecules.py +18 -77
  4. sapiopycommons/datatype/attachment_util.py +10 -11
  5. sapiopycommons/eln/experiment_handler.py +70 -272
  6. sapiopycommons/files/complex_data_loader.py +4 -5
  7. sapiopycommons/files/file_bridge.py +24 -31
  8. sapiopycommons/files/file_data_handler.py +5 -2
  9. sapiopycommons/files/file_util.py +9 -59
  10. sapiopycommons/files/file_validator.py +6 -92
  11. sapiopycommons/files/file_writer.py +15 -44
  12. sapiopycommons/general/aliases.py +6 -207
  13. sapiopycommons/general/custom_report_util.py +37 -212
  14. sapiopycommons/general/exceptions.py +8 -21
  15. sapiopycommons/general/popup_util.py +0 -21
  16. sapiopycommons/general/time_util.py +2 -8
  17. sapiopycommons/processtracking/endpoints.py +22 -22
  18. sapiopycommons/recordmodel/record_handler.py +97 -481
  19. sapiopycommons/rules/eln_rule_handler.py +25 -34
  20. sapiopycommons/rules/on_save_rule_handler.py +31 -34
  21. sapiopycommons/webhook/webhook_handlers.py +42 -201
  22. {sapiopycommons-2024.11.7a354.dist-info → sapiopycommons-2024.11.8a359.dist-info}/METADATA +2 -4
  23. sapiopycommons-2024.11.8a359.dist-info/RECORD +38 -0
  24. sapiopycommons/callbacks/field_builder.py +0 -537
  25. sapiopycommons/customreport/__init__.py +0 -0
  26. sapiopycommons/customreport/column_builder.py +0 -60
  27. sapiopycommons/customreport/custom_report_builder.py +0 -130
  28. sapiopycommons/customreport/term_builder.py +0 -299
  29. sapiopycommons/datatype/data_fields.py +0 -61
  30. sapiopycommons/datatype/pseudo_data_types.py +0 -440
  31. sapiopycommons/eln/experiment_report_util.py +0 -653
  32. sapiopycommons/files/file_bridge_handler.py +0 -340
  33. sapiopycommons/flowcyto/flow_cyto.py +0 -77
  34. sapiopycommons/flowcyto/flowcyto_data.py +0 -75
  35. sapiopycommons/general/accession_service.py +0 -375
  36. sapiopycommons/general/audit_log.py +0 -189
  37. sapiopycommons/general/sapio_links.py +0 -50
  38. sapiopycommons/multimodal/multimodal.py +0 -146
  39. sapiopycommons/multimodal/multimodal_data.py +0 -489
  40. sapiopycommons/processtracking/custom_workflow_handler.py +0 -406
  41. sapiopycommons/sftpconnect/__init__.py +0 -0
  42. sapiopycommons/sftpconnect/sftp_builder.py +0 -69
  43. sapiopycommons/webhook/webhook_context.py +0 -39
  44. sapiopycommons/webhook/webservice_handlers.py +0 -67
  45. sapiopycommons-2024.11.7a354.dist-info/RECORD +0 -59
  46. {sapiopycommons-2024.11.7a354.dist-info → sapiopycommons-2024.11.8a359.dist-info}/WHEEL +0 -0
  47. {sapiopycommons-2024.11.7a354.dist-info → sapiopycommons-2024.11.8a359.dist-info}/licenses/LICENSE +0 -0
@@ -1,5 +1,3 @@
1
- import warnings
2
-
3
1
  from sapiopylib.rest.DataMgmtService import DataMgmtServer
4
2
  from sapiopylib.rest.pojo.datatype.DataType import DataTypeDefinition
5
3
  from sapiopylib.rest.pojo.datatype.FieldDefinition import VeloxStringFieldDefinition, AbstractVeloxFieldDefinition, \
@@ -53,7 +51,6 @@ class PopupUtil:
53
51
  :param request_context: Context that will be returned to the webhook server in the client callback result.
54
52
  :return: A SapioWebhookResult with the popup as its client callback request.
55
53
  """
56
- warnings.warn("PopupUtil is deprecated as of 24.5+. Use CallbackUtil instead.", DeprecationWarning)
57
54
  if display_name is None:
58
55
  display_name = data_type
59
56
  if plural_display_name is None:
@@ -100,7 +97,6 @@ class PopupUtil:
100
97
  :param request_context: Context that will be returned to the webhook server in the client callback result.
101
98
  :return: A SapioWebhookResult with the popup as its client callback request.
102
99
  """
103
- warnings.warn("PopupUtil is deprecated as of 24.5+. Use CallbackUtil instead.", DeprecationWarning)
104
100
  # Get the field definitions of the data type.
105
101
  data_type: str = record.data_type_name
106
102
  type_man = DataMgmtServer.get_data_type_manager(context.user)
@@ -159,7 +155,6 @@ class PopupUtil:
159
155
  :param request_context: Context that will be returned to the webhook server in the client callback result.
160
156
  :return: A SapioWebhookResult with the popup as its client callback request.
161
157
  """
162
- warnings.warn("PopupUtil is deprecated as of 24.5+. Use CallbackUtil instead.", DeprecationWarning)
163
158
  if max_length is None:
164
159
  max_length = len(default_value) if default_value else 100
165
160
  string_field = VeloxStringFieldDefinition(data_type, field_name, field_name, default_value=default_value,
@@ -196,7 +191,6 @@ class PopupUtil:
196
191
  :param request_context: Context that will be returned to the webhook server in the client callback result.
197
192
  :return: A SapioWebhookResult with the popup as its client callback request.
198
193
  """
199
- warnings.warn("PopupUtil is deprecated as of 24.5+. Use CallbackUtil instead.", DeprecationWarning)
200
194
  if default_value is None:
201
195
  default_value = max(0, min_value)
202
196
  integer_field = VeloxIntegerFieldDefinition(data_type, field_name, field_name, default_value=default_value,
@@ -235,7 +229,6 @@ class PopupUtil:
235
229
  :param request_context: Context that will be returned to the webhook server in the client callback result.
236
230
  :return: A SapioWebhookResult with the popup as its client callback request.
237
231
  """
238
- warnings.warn("PopupUtil is deprecated as of 24.5+. Use CallbackUtil instead.", DeprecationWarning)
239
232
  if default_value is None:
240
233
  default_value = min_value
241
234
  double_field = VeloxDoubleFieldDefinition(data_type, field_name, field_name, default_value=default_value,
@@ -267,7 +260,6 @@ class PopupUtil:
267
260
  :param request_context: Context that will be returned to the webhook server in the client callback result.
268
261
  :return: A SapioWebhookResult with the popup as its client callback request.
269
262
  """
270
- warnings.warn("PopupUtil is deprecated as of 24.5+. Use CallbackUtil instead.", DeprecationWarning)
271
263
  if display_name is None:
272
264
  display_name = data_type
273
265
  if plural_display_name is None:
@@ -303,9 +295,6 @@ class PopupUtil:
303
295
  :param request_context: Context that will be returned to the webhook server in the client callback result.
304
296
  :return: A SapioWebhookResult with the popup as its client callback request.
305
297
  """
306
- warnings.warn("PopupUtil is deprecated as of 24.5+. Use CallbackUtil instead.", DeprecationWarning)
307
- if not records:
308
- raise SapioException("No records provided.")
309
298
  data_types: set[str] = {x.data_type_name for x in records}
310
299
  if len(data_types) > 1:
311
300
  raise SapioException("Multiple data type names encountered in records list for record table popup.")
@@ -358,9 +347,6 @@ class PopupUtil:
358
347
  :param request_context: Context that will be returned to the webhook server in the client callback result.
359
348
  :return: A SapioWebhookResult with the popup as its client callback request.
360
349
  """
361
- warnings.warn("PopupUtil is deprecated as of 24.5+. Use CallbackUtil instead.", DeprecationWarning)
362
- if not records:
363
- raise SapioException("No records provided.")
364
350
  data_types: set[str] = {x.data_type_name for x in records}
365
351
  if len(data_types) > 1:
366
352
  raise SapioException("Multiple data type names encountered in records list for record table popup.")
@@ -405,7 +391,6 @@ class PopupUtil:
405
391
  :param request_context: Context that will be returned to the webhook server in the client callback result.
406
392
  :return: A SapioWebhookResult with the popup as its client callback request.
407
393
  """
408
- warnings.warn("PopupUtil is deprecated as of 24.5+. Use CallbackUtil instead.", DeprecationWarning)
409
394
  callback = ListDialogRequest(title, multi_select, options,
410
395
  callback_context_data=request_context)
411
396
  return SapioWebhookResult(True, client_callback_request=callback)
@@ -430,7 +415,6 @@ class PopupUtil:
430
415
  :param request_context: Context that will be returned to the webhook server in the client callback result.
431
416
  :return: A SapioWebhookResult with the popup as its client callback request.
432
417
  """
433
- warnings.warn("PopupUtil is deprecated as of 24.5+. Use CallbackUtil instead.", DeprecationWarning)
434
418
  callback = OptionDialogRequest(title, msg, options, default_option, user_can_cancel,
435
419
  callback_context_data=request_context)
436
420
  return SapioWebhookResult(True, client_callback_request=callback)
@@ -453,7 +437,6 @@ class PopupUtil:
453
437
  :param request_context: Context that will be returned to the webhook server in the client callback result.
454
438
  :return: A SapioWebhookResult with the popup as its client callback request.
455
439
  """
456
- warnings.warn("PopupUtil is deprecated as of 24.5+. Use CallbackUtil instead.", DeprecationWarning)
457
440
  return PopupUtil.option_popup(title, msg, ["OK"], 0, user_can_cancel, request_context=request_context)
458
441
 
459
442
  @staticmethod
@@ -475,7 +458,6 @@ class PopupUtil:
475
458
  :param request_context: Context that will be returned to the webhook server in the client callback result.
476
459
  :return: A SapioWebhookResult with the popup as its client callback request.
477
460
  """
478
- warnings.warn("PopupUtil is deprecated as of 24.5+. Use CallbackUtil instead.", DeprecationWarning)
479
461
  return PopupUtil.option_popup(title, msg, ["Yes", "No"], 0 if default_yes else 1, user_can_cancel,
480
462
  request_context=request_context)
481
463
 
@@ -488,7 +470,6 @@ class PopupUtil:
488
470
 
489
471
  Deprecated for PopupUtil.text_field_popup.
490
472
  """
491
- warnings.warn("PopupUtil is deprecated as of 24.5+. Use CallbackUtil instead.", DeprecationWarning)
492
473
  return PopupUtil.string_field_popup(title, "", field_name, msg, len(msg), False, data_type,
493
474
  request_context=request_context, auto_size=True)
494
475
 
@@ -500,7 +481,6 @@ class PopupUtil:
500
481
 
501
482
  Deprecated for PopupUtil.option_popup.
502
483
  """
503
- warnings.warn("PopupUtil is deprecated as of 24.5+. Use CallbackUtil instead.", DeprecationWarning)
504
484
  return PopupUtil.option_popup(title, msg, options, 0, user_can_cancel, request_context=request_context)
505
485
 
506
486
  @staticmethod
@@ -510,5 +490,4 @@ class PopupUtil:
510
490
 
511
491
  Deprecated for PopupUtil.ok_popup.
512
492
  """
513
- warnings.warn("PopupUtil is deprecated as of 24.5+. Use CallbackUtil instead.", DeprecationWarning)
514
493
  return PopupUtil.ok_popup(title, msg, False, request_context=request_context)
@@ -1,5 +1,3 @@
1
- from __future__ import annotations
2
-
3
1
  import time
4
2
  from datetime import datetime
5
3
 
@@ -94,10 +92,9 @@ class TimeUtil:
94
92
  return TimeUtil.current_time(timezone).strftime(time_format)
95
93
 
96
94
  @staticmethod
97
- def millis_to_format(millis: int, time_format: str, timezone: str | int = None) -> str | None:
95
+ def millis_to_format(millis: int, time_format: str, timezone: str | int = None) -> str:
98
96
  """
99
- Convert the input time in milliseconds to the provided format. If None is passed to the millis parameter,
100
- None will be returned
97
+ Convert the input time in milliseconds to the provided format.
101
98
 
102
99
  :param millis: The time in milliseconds to convert from.
103
100
  :param time_format: The format to display the input time in. Documentation for how the time formatting works
@@ -106,9 +103,6 @@ class TimeUtil:
106
103
  timezone variable set by the TimeUtil. A list of valid timezones can be found at
107
104
  https://en.wikipedia.org/wiki/List_of_tz_database_time_zones. May also accept a UTC offset in seconds.
108
105
  """
109
- if millis is None:
110
- return None
111
-
112
106
  tz = TimeUtil.__to_tz(timezone)
113
107
  return datetime.fromtimestamp(millis / 1000, tz).strftime(time_format)
114
108
 
@@ -1,12 +1,12 @@
1
1
  from sapiopylib.rest.User import SapioUser
2
+ from sapiopylib.rest.pojo.webhook.WebhookContext import SapioWebhookContext
2
3
 
3
- from sapiopycommons.general.aliases import RecordIdentifier, AliasUtil, ExperimentIdentifier, DataTypeIdentifier, \
4
- UserIdentifier
4
+ from sapiopycommons.general.aliases import RecordIdentifier, AliasUtil, ExperimentIdentifier
5
5
 
6
6
 
7
7
  class ProcessTracking:
8
8
  @staticmethod
9
- def assign_to_process(context: UserIdentifier, data_type: DataTypeIdentifier, records: list[RecordIdentifier],
9
+ def assign_to_process(context: SapioWebhookContext | SapioUser, data_type: str, records: list[RecordIdentifier],
10
10
  process_name: str, step_number: int | None = None, branch_id: int | None = None,
11
11
  request: RecordIdentifier | None = None) -> None:
12
12
  """
@@ -27,19 +27,19 @@ class ProcessTracking:
27
27
  """
28
28
  sub_path = '/ext/process-tracking/assign-to-process'
29
29
  payload = {
30
- "data-type-name": AliasUtil.to_data_type_name(data_type),
30
+ "data-type-name": data_type,
31
31
  "record-ids": AliasUtil.to_record_ids(records),
32
32
  "process-name": process_name,
33
33
  "step-number": step_number,
34
34
  "branch-id": branch_id,
35
35
  "request-record-id": AliasUtil.to_record_ids([request])[0] if request is not None else None
36
36
  }
37
- user: SapioUser = AliasUtil.to_sapio_user(context)
37
+ user: SapioUser = context if isinstance(context, SapioUser) else context.user
38
38
  response = user.post(sub_path, payload=payload)
39
39
  user.raise_for_status(response)
40
40
 
41
41
  @staticmethod
42
- def begin_protocol(context: UserIdentifier, data_type: DataTypeIdentifier, records: list[RecordIdentifier],
42
+ def begin_protocol(context: SapioWebhookContext | SapioUser, data_type: str, records: list[RecordIdentifier],
43
43
  experiment: ExperimentIdentifier) -> None:
44
44
  """
45
45
  Begin the assigned processes of the given tracked records as the given experiment. This sets the status of the
@@ -54,16 +54,16 @@ class ProcessTracking:
54
54
  """
55
55
  sub_path = '/ext/process-tracking/begin-protocol'
56
56
  payload = {
57
- "data-type-name": AliasUtil.to_data_type_name(data_type),
57
+ "data-type-name": data_type,
58
58
  "record-ids": AliasUtil.to_record_ids(records),
59
59
  "experiment-id": AliasUtil.to_notebook_id(experiment),
60
60
  }
61
- user: SapioUser = AliasUtil.to_sapio_user(context)
61
+ user: SapioUser = context if isinstance(context, SapioUser) else context.user
62
62
  response = user.post(sub_path, payload=payload)
63
63
  user.raise_for_status(response)
64
64
 
65
65
  @staticmethod
66
- def complete_protocol(context: UserIdentifier, data_type: DataTypeIdentifier, records: list[RecordIdentifier],
66
+ def complete_protocol(context: SapioWebhookContext | SapioUser, data_type: str, records: list[RecordIdentifier],
67
67
  experiment: ExperimentIdentifier) -> None:
68
68
  """
69
69
  Complete the current step that the given tracked records are at given the experiment.
@@ -80,16 +80,16 @@ class ProcessTracking:
80
80
  """
81
81
  sub_path = '/ext/process-tracking/complete-protocol'
82
82
  payload = {
83
- "data-type-name": AliasUtil.to_data_type_name(data_type),
83
+ "data-type-name": data_type,
84
84
  "record-ids": AliasUtil.to_record_ids(records),
85
85
  "experiment-id": AliasUtil.to_notebook_id(experiment),
86
86
  }
87
- user: SapioUser = AliasUtil.to_sapio_user(context)
87
+ user: SapioUser = context if isinstance(context, SapioUser) else context.user
88
88
  response = user.post(sub_path, payload=payload)
89
89
  user.raise_for_status(response)
90
90
 
91
91
  @staticmethod
92
- def fail(context: UserIdentifier, data_type: DataTypeIdentifier, records: list[RecordIdentifier],
92
+ def fail(context: SapioWebhookContext | SapioUser, data_type: str, records: list[RecordIdentifier],
93
93
  experiment: ExperimentIdentifier) -> None:
94
94
  """
95
95
  Fail the assigned processes of the given tracked records, changing their statuses to "Failed -". The tracked
@@ -103,16 +103,16 @@ class ProcessTracking:
103
103
  """
104
104
  sub_path = '/ext/process-tracking/fail'
105
105
  payload = {
106
- "data-type-name": AliasUtil.to_data_type_name(data_type),
106
+ "data-type-name": data_type,
107
107
  "record-ids": AliasUtil.to_record_ids(records),
108
108
  "experiment-id": AliasUtil.to_notebook_id(experiment),
109
109
  }
110
- user: SapioUser = AliasUtil.to_sapio_user(context)
110
+ user: SapioUser = context if isinstance(context, SapioUser) else context.user
111
111
  response = user.post(sub_path, payload=payload)
112
112
  user.raise_for_status(response)
113
113
 
114
114
  @staticmethod
115
- def promote_to_next_by_experiment(context: UserIdentifier, data_type: DataTypeIdentifier,
115
+ def promote_to_next_by_experiment(context: SapioWebhookContext | SapioUser, data_type: str,
116
116
  records: list[RecordIdentifier], experiment: ExperimentIdentifier) -> None:
117
117
  """
118
118
  Promote the status of the given tracked records to the next status in their process using an experiment.
@@ -129,16 +129,16 @@ class ProcessTracking:
129
129
  """
130
130
  sub_path = '/ext/process-tracking/promote-status-to-next'
131
131
  payload = {
132
- "data-type-name": AliasUtil.to_data_type_name(data_type),
132
+ "data-type-name": data_type,
133
133
  "record-ids": AliasUtil.to_record_ids(records),
134
134
  "experiment-id": AliasUtil.to_notebook_id(experiment),
135
135
  }
136
- user: SapioUser = AliasUtil.to_sapio_user(context)
136
+ user: SapioUser = context if isinstance(context, SapioUser) else context.user
137
137
  response = user.post(sub_path, payload=payload)
138
138
  user.raise_for_status(response)
139
139
 
140
140
  @staticmethod
141
- def promote_to_next_by_step(context: UserIdentifier, data_type: DataTypeIdentifier,
141
+ def promote_to_next_by_step(context: SapioWebhookContext | SapioUser, data_type: str,
142
142
  records: list[RecordIdentifier], process_name: str, step_number: int,
143
143
  branch_id: int | None = None) -> None:
144
144
  """
@@ -159,7 +159,7 @@ class ProcessTracking:
159
159
  """
160
160
  sub_path = '/ext/process-tracking/promote-status-to-next'
161
161
  payload = {
162
- "data-type-name": AliasUtil.to_data_type_name(data_type),
162
+ "data-type-name": data_type,
163
163
  "record-ids": AliasUtil.to_record_ids(records),
164
164
  "current-process-status": {
165
165
  "process-name": process_name,
@@ -167,12 +167,12 @@ class ProcessTracking:
167
167
  "branch-id": branch_id
168
168
  }
169
169
  }
170
- user: SapioUser = AliasUtil.to_sapio_user(context)
170
+ user: SapioUser = context if isinstance(context, SapioUser) else context.user
171
171
  response = user.post(sub_path, payload=payload)
172
172
  user.raise_for_status(response)
173
173
 
174
174
  @staticmethod
175
- def reprocess(context: UserIdentifier, records: list[RecordIdentifier]) -> None:
175
+ def reprocess(context: SapioWebhookContext | SapioUser, records: list[RecordIdentifier]) -> None:
176
176
  """
177
177
  Reprocess tracked records to a previous step in their process. Reprocessing is controlled by ReturnPoint records
178
178
  which are children of the AssignedProcess on the tracked records. Creates a new AssignedProcess record for the
@@ -187,6 +187,6 @@ class ProcessTracking:
187
187
  payload = {
188
188
  "record-ids": AliasUtil.to_record_ids(records)
189
189
  }
190
- user: SapioUser = AliasUtil.to_sapio_user(context)
190
+ user: SapioUser = context if isinstance(context, SapioUser) else context.user
191
191
  response = user.post(sub_path, payload=payload)
192
192
  user.raise_for_status(response)