sapiopycommons 2025.3.6a451__py3-none-any.whl → 2025.3.6a454__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.
- sapiopycommons/customreport/auto_pagers.py +17 -25
- sapiopycommons/general/sapio_links.py +4 -12
- sapiopycommons/recordmodel/record_handler.py +101 -137
- {sapiopycommons-2025.3.6a451.dist-info → sapiopycommons-2025.3.6a454.dist-info}/METADATA +1 -1
- {sapiopycommons-2025.3.6a451.dist-info → sapiopycommons-2025.3.6a454.dist-info}/RECORD +7 -10
- sapiopycommons/ai/__init__.py +0 -0
- sapiopycommons/ai/tool_of_tools.py +0 -905
- sapiopycommons/general/html_formatter.py +0 -456
- {sapiopycommons-2025.3.6a451.dist-info → sapiopycommons-2025.3.6a454.dist-info}/WHEEL +0 -0
- {sapiopycommons-2025.3.6a451.dist-info → sapiopycommons-2025.3.6a454.dist-info}/licenses/LICENSE +0 -0
|
@@ -8,7 +8,6 @@ from sapiopylib.rest.pojo.CustomReport import CustomReportCriteria, CustomReport
|
|
|
8
8
|
from sapiopylib.rest.pojo.datatype.FieldDefinition import FieldType
|
|
9
9
|
from sapiopylib.rest.utils.autopaging import SapioPyAutoPager, PagerResultCriteriaType, _default_report_page_size, \
|
|
10
10
|
_default_record_page_size
|
|
11
|
-
from sapiopylib.rest.utils.recordmodel.PyRecordModel import PyRecordModel
|
|
12
11
|
from sapiopylib.rest.utils.recordmodel.RecordModelWrapper import WrappedType
|
|
13
12
|
|
|
14
13
|
from sapiopycommons.general.aliases import FieldValue, UserIdentifier, AliasUtil, RecordModel
|
|
@@ -111,20 +110,20 @@ class QuickReportDictAutoPager(_DictReportPagerBase):
|
|
|
111
110
|
super().__init__(user, first_page_criteria)
|
|
112
111
|
|
|
113
112
|
|
|
114
|
-
class _RecordReportPagerBase(SapioPyAutoPager[CustomReportCriteria,
|
|
113
|
+
class _RecordReportPagerBase(SapioPyAutoPager[CustomReportCriteria, WrappedType], ABC):
|
|
115
114
|
"""
|
|
116
115
|
A base class for automatically paging through a report and returning the results as a list of records.
|
|
117
116
|
"""
|
|
118
117
|
_columns: list[ReportColumn]
|
|
119
|
-
|
|
118
|
+
_wrapper: type[WrappedType]
|
|
120
119
|
_data_type: str
|
|
121
120
|
_rec_handler: RecordHandler
|
|
122
121
|
_report_man: CustomReportManager
|
|
123
122
|
|
|
124
|
-
def __init__(self, user: UserIdentifier, first_page_criteria: CustomReportCriteria, wrapper_type: type[WrappedType]
|
|
123
|
+
def __init__(self, user: UserIdentifier, first_page_criteria: CustomReportCriteria, wrapper_type: type[WrappedType]):
|
|
125
124
|
self._columns = first_page_criteria.column_list
|
|
126
|
-
self.
|
|
127
|
-
self._data_type =
|
|
125
|
+
self._wrapper = wrapper_type
|
|
126
|
+
self._data_type = wrapper_type.get_wrapper_data_type_name()
|
|
128
127
|
self._rec_handler = RecordHandler(user)
|
|
129
128
|
super().__init__(AliasUtil.to_sapio_user(user), first_page_criteria)
|
|
130
129
|
self._report_man = DataMgmtServer.get_custom_report_manager(self.user)
|
|
@@ -140,9 +139,9 @@ class _RecordReportPagerBase(SapioPyAutoPager[CustomReportCriteria, RecordModel]
|
|
|
140
139
|
def default_first_page_criteria(self) -> PagerResultCriteriaType:
|
|
141
140
|
raise ValueError("Cannot generate a default first page criteria for custom reports.")
|
|
142
141
|
|
|
143
|
-
def get_next_page_result(self) -> tuple[CustomReportCriteria | None, Queue[WrappedType]
|
|
142
|
+
def get_next_page_result(self) -> tuple[CustomReportCriteria | None, Queue[WrappedType]]:
|
|
144
143
|
report: CustomReport = self._report_man.run_custom_report(self.next_page_criteria)
|
|
145
|
-
queue = Queue()
|
|
144
|
+
queue: Queue[WrappedType] = Queue()
|
|
146
145
|
id_index: int = -1
|
|
147
146
|
for i, column in enumerate(self._columns):
|
|
148
147
|
if column.data_type_name == self._data_type and column.data_field_name == "RecordId":
|
|
@@ -152,7 +151,7 @@ class _RecordReportPagerBase(SapioPyAutoPager[CustomReportCriteria, RecordModel]
|
|
|
152
151
|
raise SapioException(f"This report does not contain a Record ID column for the given record model type "
|
|
153
152
|
f"{self._data_type}.")
|
|
154
153
|
ids: list[int] = [row[id_index] for row in report.result_table]
|
|
155
|
-
for row in self._rec_handler.query_models_by_id(self.
|
|
154
|
+
for row in self._rec_handler.query_models_by_id(self._wrapper, ids, page_size=report.page_size):
|
|
156
155
|
queue.put(row)
|
|
157
156
|
if report.has_next_page:
|
|
158
157
|
next_page_criteria = copy(self.next_page_criteria)
|
|
@@ -166,15 +165,12 @@ class CustomReportRecordAutoPager(_RecordReportPagerBase):
|
|
|
166
165
|
"""
|
|
167
166
|
A class that automatically pages through a custom report and returns the results as a list of records.
|
|
168
167
|
"""
|
|
169
|
-
def __init__(self, user: UserIdentifier, report_criteria: CustomReportCriteria,
|
|
170
|
-
|
|
171
|
-
page_size: int = _default_record_page_size):
|
|
168
|
+
def __init__(self, user: UserIdentifier, report_criteria: CustomReportCriteria, wrapper_type: type[WrappedType],
|
|
169
|
+
page_number: int = 0, page_size: int = _default_record_page_size):
|
|
172
170
|
"""
|
|
173
171
|
:param user: The current webhook context or a user object to send requests from.
|
|
174
172
|
:param report_criteria: The custom report criteria to run.
|
|
175
|
-
:param wrapper_type: The record model wrapper type
|
|
176
|
-
If a data type name was used instead of a model wrapper, then the returned records will be PyRecordModels
|
|
177
|
-
instead of WrappedRecordModels.
|
|
173
|
+
:param wrapper_type: The record model wrapper type to use for the records.
|
|
178
174
|
:param page_number: The page number to start on. The first page is page 0.
|
|
179
175
|
:param page_size: The number of results to return per page.
|
|
180
176
|
"""
|
|
@@ -192,14 +188,12 @@ class SystemReportRecordAutoPager(_RecordReportPagerBase):
|
|
|
192
188
|
System reports are also known as predefined searches in the system and must be defined in the data designer for
|
|
193
189
|
a specific data type. That is, saved searches created by users cannot be run using this function.
|
|
194
190
|
"""
|
|
195
|
-
def __init__(self, user: UserIdentifier, report_name: str, wrapper_type: type[WrappedType]
|
|
191
|
+
def __init__(self, user: UserIdentifier, report_name: str, wrapper_type: type[WrappedType],
|
|
196
192
|
page_number: int = 0, page_size: int = _default_record_page_size):
|
|
197
193
|
"""
|
|
198
194
|
:param user: The current webhook context or a user object to send requests from.
|
|
199
195
|
:param report_name: The name of the system report to run.
|
|
200
|
-
:param wrapper_type: The record model wrapper type
|
|
201
|
-
If a data type name was used instead of a model wrapper, then the returned records will be PyRecordModels
|
|
202
|
-
instead of WrappedRecordModels.
|
|
196
|
+
:param wrapper_type: The record model wrapper type to use for the records.
|
|
203
197
|
:param page_number: The page number to start on. The first page is page 0.
|
|
204
198
|
:param page_size: The number of results to return per page.
|
|
205
199
|
"""
|
|
@@ -214,14 +208,12 @@ class QuickReportRecordAutoPager(_RecordReportPagerBase):
|
|
|
214
208
|
"""
|
|
215
209
|
A class that automatically pages through a quick report and returns the results as a list of records.
|
|
216
210
|
"""
|
|
217
|
-
def __init__(self, user: UserIdentifier, report_term: RawReportTerm, wrapper_type: type[WrappedType]
|
|
211
|
+
def __init__(self, user: UserIdentifier, report_term: RawReportTerm, wrapper_type: type[WrappedType],
|
|
218
212
|
page_number: int = 0, page_size: int = _default_record_page_size):
|
|
219
213
|
"""
|
|
220
214
|
:param user: The current webhook context or a user object to send requests from.
|
|
221
215
|
:param report_term: The raw report term to use for the quick report.
|
|
222
|
-
:param wrapper_type: The record model wrapper type
|
|
223
|
-
If a data type name was used instead of a model wrapper, then the returned records will be PyRecordModels
|
|
224
|
-
instead of WrappedRecordModels.
|
|
216
|
+
:param wrapper_type: The record model wrapper type to use for the records.
|
|
225
217
|
:param page_number: The page number to start on. The first page is page 0.
|
|
226
218
|
:param page_size: The number of results to return per page.
|
|
227
219
|
"""
|
|
@@ -233,12 +225,12 @@ class QuickReportRecordAutoPager(_RecordReportPagerBase):
|
|
|
233
225
|
super().__init__(user, first_page_criteria, wrapper_type)
|
|
234
226
|
|
|
235
227
|
|
|
236
|
-
def _add_record_id_column(report: CustomReportCriteria, wrapper_type: type[WrappedType]
|
|
228
|
+
def _add_record_id_column(report: CustomReportCriteria, wrapper_type: type[WrappedType]) -> None:
|
|
237
229
|
"""
|
|
238
230
|
Given a custom report criteria, ensure that the report contains a Record ID column for the given record model's
|
|
239
231
|
data type. Add one if it is missing.
|
|
240
232
|
"""
|
|
241
|
-
dt: str =
|
|
233
|
+
dt: str = wrapper_type.get_wrapper_data_type_name()
|
|
242
234
|
# Ensure that the root data type is the one we're looking for.
|
|
243
235
|
report.root_data_type = dt
|
|
244
236
|
# Enforce that the given custom report has a record ID column.
|
|
@@ -10,8 +10,7 @@ class SapioNavigationLinker:
|
|
|
10
10
|
Given a URL to a system's webservice API (example: https://company.exemplareln.com/webservice/api), construct
|
|
11
11
|
URLs for navigation links to various locations in the system.
|
|
12
12
|
"""
|
|
13
|
-
|
|
14
|
-
webservice_url: str
|
|
13
|
+
base_url: str
|
|
15
14
|
|
|
16
15
|
def __init__(self, url: str | SapioUser | SapioWebhookContext):
|
|
17
16
|
"""
|
|
@@ -22,14 +21,7 @@ class SapioNavigationLinker:
|
|
|
22
21
|
url = url.user.url
|
|
23
22
|
elif isinstance(url, SapioUser):
|
|
24
23
|
url = url.url
|
|
25
|
-
self.
|
|
26
|
-
self.client_url = url.rstrip("/").replace('webservice/api', 'veloxClient')
|
|
27
|
-
|
|
28
|
-
def homepage(self) -> str:
|
|
29
|
-
"""
|
|
30
|
-
:return: A URL for navigating to the system's homepage.
|
|
31
|
-
"""
|
|
32
|
-
return self.client_url + "/#view=homepage"
|
|
24
|
+
self.base_url = url.rstrip("/").replace('webservice/api', 'veloxClient')
|
|
33
25
|
|
|
34
26
|
def data_record(self, record_identifier: RecordIdentifier, data_type_name: DataTypeIdentifier | None = None) -> str:
|
|
35
27
|
"""
|
|
@@ -47,7 +39,7 @@ class SapioNavigationLinker:
|
|
|
47
39
|
if not data_type_name:
|
|
48
40
|
raise SapioException("Unable to create a data record link without a data type name. "
|
|
49
41
|
"Only a record ID was provided.")
|
|
50
|
-
return self.
|
|
42
|
+
return self.base_url + f"/#dataType={data_type_name};recordId={record_id};view=dataRecord"
|
|
51
43
|
|
|
52
44
|
def experiment(self, experiment: ExperimentIdentifier) -> str:
|
|
53
45
|
"""
|
|
@@ -55,4 +47,4 @@ class SapioNavigationLinker:
|
|
|
55
47
|
object, experiment protocol, or a notebook ID.
|
|
56
48
|
:return: A URL for navigating to the input experiment.
|
|
57
49
|
"""
|
|
58
|
-
return self.
|
|
50
|
+
return self.base_url + f"/#notebookExperimentId={AliasUtil.to_notebook_id(experiment)};view=eln"
|