sapiopycommons 2024.12.5a376__py3-none-any.whl → 2024.12.9a378__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/custom_report_builder.py +7 -0
- sapiopycommons/customreport/term_builder.py +44 -28
- sapiopycommons/eln/experiment_report_util.py +85 -89
- sapiopycommons/general/audit_log.py +3 -6
- sapiopycommons/processtracking/custom_workflow_handler.py +35 -35
- {sapiopycommons-2024.12.5a376.dist-info → sapiopycommons-2024.12.9a378.dist-info}/METADATA +1 -1
- {sapiopycommons-2024.12.5a376.dist-info → sapiopycommons-2024.12.9a378.dist-info}/RECORD +9 -9
- {sapiopycommons-2024.12.5a376.dist-info → sapiopycommons-2024.12.9a378.dist-info}/WHEEL +0 -0
- {sapiopycommons-2024.12.5a376.dist-info → sapiopycommons-2024.12.9a378.dist-info}/licenses/LICENSE +0 -0
|
@@ -3,6 +3,7 @@ from sapiopylib.rest.pojo.CustomReport import ReportColumn, CustomReportCriteria
|
|
|
3
3
|
from sapiopylib.rest.pojo.datatype.FieldDefinition import FieldType
|
|
4
4
|
|
|
5
5
|
from sapiopycommons.customreport.column_builder import ColumnBuilder
|
|
6
|
+
from sapiopycommons.customreport.term_builder import TermBuilder
|
|
6
7
|
from sapiopycommons.general.aliases import DataTypeIdentifier, FieldIdentifier, AliasUtil, SapioRecord
|
|
7
8
|
from sapiopycommons.general.exceptions import SapioException
|
|
8
9
|
|
|
@@ -31,6 +32,12 @@ class CustomReportBuilder:
|
|
|
31
32
|
self.column_list = []
|
|
32
33
|
self.join_list = []
|
|
33
34
|
|
|
35
|
+
def get_term_builder(self) -> TermBuilder:
|
|
36
|
+
"""
|
|
37
|
+
:return: A TermBuilder with a data type matching this report builder's root data type.
|
|
38
|
+
"""
|
|
39
|
+
return TermBuilder(self.root_data_type)
|
|
40
|
+
|
|
34
41
|
def has_root_term(self) -> bool:
|
|
35
42
|
"""
|
|
36
43
|
:return: Whether this report builder has had its root term set.
|
|
@@ -25,103 +25,119 @@ class TermBuilder:
|
|
|
25
25
|
"""
|
|
26
26
|
A class that allows for the easier constructions of custom report terms.
|
|
27
27
|
"""
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
data_type: str
|
|
29
|
+
|
|
30
|
+
def __init__(self, data_type: DataTypeIdentifier):
|
|
31
|
+
"""
|
|
32
|
+
:param data_type: An object that can be used to identify a data type name. Used as the default data type name
|
|
33
|
+
of the terms created from this TermBuilder.
|
|
34
|
+
"""
|
|
35
|
+
self.data_type = AliasUtil.to_data_type_name(data_type)
|
|
36
|
+
|
|
37
|
+
def all_records_term(self, *, data_type: DataTypeIdentifier | None = None) -> RawReportTerm:
|
|
30
38
|
"""
|
|
31
39
|
Create a raw report term that captures all records of the given data type.
|
|
32
40
|
|
|
33
|
-
:param data_type:
|
|
41
|
+
:param data_type: If provided, the data type of this term. If not provided, then the data type that this term
|
|
42
|
+
builder was instantiated with is used.
|
|
34
43
|
:return: A raw report term for "data_type.RecordId >= 0".
|
|
35
44
|
"""
|
|
36
|
-
|
|
45
|
+
data_type: str = AliasUtil.to_data_type_name(data_type) if data_type else self.data_type
|
|
46
|
+
return RawReportTerm(data_type, "RecordId", GTE, TermBuilder.to_term_val(0))
|
|
37
47
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
*, trim: bool = False) -> RawReportTerm:
|
|
48
|
+
def is_term(self, field: FieldIdentifier, value: TermValue,
|
|
49
|
+
*, data_type: DataTypeIdentifier | None = None, trim: bool = False) -> RawReportTerm:
|
|
41
50
|
"""
|
|
42
51
|
Create a raw report term for comparing a field value with an equals operation.
|
|
43
52
|
|
|
44
|
-
:param data_type: The data type of this term.
|
|
45
53
|
:param field: The data field of this term.
|
|
46
54
|
:param value: The value to compare for this term.
|
|
55
|
+
:param data_type: If provided, the data type of this term. If not provided, then the data type that this term
|
|
56
|
+
builder was instantiated with is used.
|
|
47
57
|
:param trim: Whether the string of the given value should be trimmed of trailing and leading whitespace.
|
|
48
58
|
:return: A raw report term for "data_type.field = value".
|
|
49
59
|
"""
|
|
60
|
+
data_type: str = AliasUtil.to_data_type_name(data_type) if data_type else self.data_type
|
|
50
61
|
return RawReportTerm(AliasUtil.to_data_type_name(data_type), AliasUtil.to_data_field_name(field), EQ,
|
|
51
62
|
TermBuilder.to_term_val(value), trim)
|
|
52
63
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
*, trim: bool = False) -> RawReportTerm:
|
|
64
|
+
def not_term(self, field: FieldIdentifier, value: TermValue,
|
|
65
|
+
*, data_type: DataTypeIdentifier | None = None, trim: bool = False) -> RawReportTerm:
|
|
56
66
|
"""
|
|
57
67
|
Create a raw report term for comparing a field value with a not equals operation.
|
|
58
68
|
|
|
59
|
-
:param data_type: The data type of this term.
|
|
60
69
|
:param field: The data field of this term.
|
|
61
70
|
:param value: The value to compare for this term.
|
|
71
|
+
:param data_type: If provided, the data type of this term. If not provided, then the data type that this term
|
|
72
|
+
builder was instantiated with is used.
|
|
62
73
|
:param trim: Whether the string of the given value should be trimmed of trailing and leading whitespace.
|
|
63
74
|
:return: A raw report term for "data_type.field != value".
|
|
64
75
|
"""
|
|
76
|
+
data_type: str = AliasUtil.to_data_type_name(data_type) if data_type else self.data_type
|
|
65
77
|
return RawReportTerm(AliasUtil.to_data_type_name(data_type), AliasUtil.to_data_field_name(field), NEQ,
|
|
66
78
|
TermBuilder.to_term_val(value), trim)
|
|
67
79
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
*, trim: bool = False) -> RawReportTerm:
|
|
80
|
+
def lt_term(self, field: FieldIdentifier, value: TermValue,
|
|
81
|
+
*, data_type: DataTypeIdentifier | None = None, trim: bool = False) -> RawReportTerm:
|
|
71
82
|
"""
|
|
72
83
|
Create a raw report term for comparing a field value with a less than operation.
|
|
73
84
|
|
|
74
|
-
:param data_type: The data type of this term.
|
|
75
85
|
:param field: The data field of this term.
|
|
76
86
|
:param value: The value to compare for this term.
|
|
87
|
+
:param data_type: If provided, the data type of this term. If not provided, then the data type that this term
|
|
88
|
+
builder was instantiated with is used.
|
|
77
89
|
:param trim: Whether the string of the given value should be trimmed of trailing and leading whitespace.
|
|
78
90
|
:return: A raw report term for "data_type.field < value".
|
|
79
91
|
"""
|
|
92
|
+
data_type: str = AliasUtil.to_data_type_name(data_type) if data_type else self.data_type
|
|
80
93
|
return RawReportTerm(AliasUtil.to_data_type_name(data_type), AliasUtil.to_data_field_name(field), LT,
|
|
81
94
|
TermBuilder.to_term_val(value), trim)
|
|
82
95
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
*, trim: bool = False) -> RawReportTerm:
|
|
96
|
+
def lte_term(self, field: FieldIdentifier, value: TermValue,
|
|
97
|
+
*, data_type: DataTypeIdentifier | None = None, trim: bool = False) -> RawReportTerm:
|
|
86
98
|
"""
|
|
87
99
|
Create a raw report term for comparing a field value with a less than or equal to operation.
|
|
88
100
|
|
|
89
|
-
:param data_type: The data type of this term.
|
|
90
101
|
:param field: The data field of this term.
|
|
91
102
|
:param value: The value to compare for this term.
|
|
103
|
+
:param data_type: If provided, the data type of this term. If not provided, then the data type that this term
|
|
104
|
+
builder was instantiated with is used.
|
|
92
105
|
:param trim: Whether the string of the given value should be trimmed of trailing and leading whitespace.
|
|
93
106
|
:return: A raw report term for "data_type.field <= value".
|
|
94
107
|
"""
|
|
108
|
+
data_type: str = AliasUtil.to_data_type_name(data_type) if data_type else self.data_type
|
|
95
109
|
return RawReportTerm(AliasUtil.to_data_type_name(data_type), AliasUtil.to_data_field_name(field), LTE,
|
|
96
110
|
TermBuilder.to_term_val(value), trim)
|
|
97
111
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
*, trim: bool = False) -> RawReportTerm:
|
|
112
|
+
def gt_term(self, field: FieldIdentifier, value: TermValue,
|
|
113
|
+
*, data_type: DataTypeIdentifier | None = None, trim: bool = False) -> RawReportTerm:
|
|
101
114
|
"""
|
|
102
115
|
Create a raw report term for comparing a field value with a greater than operation.
|
|
103
116
|
|
|
104
|
-
:param data_type: The data type of this term.
|
|
105
117
|
:param field: The data field of this term.
|
|
106
118
|
:param value: The value to compare for this term.
|
|
119
|
+
:param data_type: If provided, the data type of this term. If not provided, then the data type that this term
|
|
120
|
+
builder was instantiated with is used.
|
|
107
121
|
:param trim: Whether the string of the given value should be trimmed of trailing and leading whitespace.
|
|
108
122
|
:return: A raw report term for "data_type.field > value".
|
|
109
123
|
"""
|
|
124
|
+
data_type: str = AliasUtil.to_data_type_name(data_type) if data_type else self.data_type
|
|
110
125
|
return RawReportTerm(AliasUtil.to_data_type_name(data_type), AliasUtil.to_data_field_name(field), GT,
|
|
111
126
|
TermBuilder.to_term_val(value), trim)
|
|
112
127
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
*, trim: bool = False) -> RawReportTerm:
|
|
128
|
+
def gte_term(self, field: FieldIdentifier, value: TermValue,
|
|
129
|
+
*, data_type: DataTypeIdentifier | None = None, trim: bool = False) -> RawReportTerm:
|
|
116
130
|
"""
|
|
117
131
|
Create a raw report term for comparing a field value with a greater than or equal to operation.
|
|
118
132
|
|
|
119
|
-
:param data_type: The data type of this term.
|
|
120
133
|
:param field: The data field of this term.
|
|
121
134
|
:param value: The value to compare for this term.
|
|
135
|
+
:param data_type: If provided, the data type of this term. If not provided, then the data type that this term
|
|
136
|
+
builder was instantiated with is used.
|
|
122
137
|
:param trim: Whether the string of the given value should be trimmed of trailing and leading whitespace.
|
|
123
138
|
:return: A raw report term for "data_type.field >= value".
|
|
124
139
|
"""
|
|
140
|
+
data_type: str = AliasUtil.to_data_type_name(data_type) if data_type else self.data_type
|
|
125
141
|
return RawReportTerm(AliasUtil.to_data_type_name(data_type), AliasUtil.to_data_field_name(field), GTE,
|
|
126
142
|
TermBuilder.to_term_val(value), trim)
|
|
127
143
|
|
|
@@ -194,11 +194,10 @@ class ExperimentReportUtil:
|
|
|
194
194
|
dt_to_record.setdefault(AliasUtil.to_data_type_name(record, False), []).append(record)
|
|
195
195
|
|
|
196
196
|
report_builder = CustomReportBuilder(EnbEntryPseudoDef.DATA_TYPE_NAME)
|
|
197
|
+
tb = report_builder.get_term_builder()
|
|
197
198
|
report_builder.add_column(EnbEntryPseudoDef.DATA_TYPE_NAME__FIELD_NAME)
|
|
198
199
|
report_builder.add_column(EnbEntryPseudoDef.EXPERIMENT_ID__FIELD_NAME)
|
|
199
|
-
report_builder.set_root_term(
|
|
200
|
-
EnbEntryPseudoDef.DATA_TYPE_NAME__FIELD_NAME,
|
|
201
|
-
data_types))
|
|
200
|
+
report_builder.set_root_term(tb.is_term(EnbEntryPseudoDef.DATA_TYPE_NAME__FIELD_NAME, data_types))
|
|
202
201
|
criteria = report_builder.build_report_criteria()
|
|
203
202
|
|
|
204
203
|
ret_val: dict[SapioRecord, int] = {}
|
|
@@ -259,9 +258,8 @@ class ExperimentReportUtil:
|
|
|
259
258
|
exp_ids: list[int] = AliasUtil.to_notebook_ids(experiments)
|
|
260
259
|
|
|
261
260
|
report_builder = CustomReportBuilder(NotebookExperimentOptionPseudoDef.DATA_TYPE_NAME)
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
exp_ids)
|
|
261
|
+
tb = report_builder.get_term_builder()
|
|
262
|
+
root = tb.is_term(NotebookExperimentOptionPseudoDef.EXPERIMENT_ID__FIELD_NAME, exp_ids)
|
|
265
263
|
report_builder.set_root_term(root)
|
|
266
264
|
report_builder.add_column(NotebookExperimentOptionPseudoDef.EXPERIMENT_ID__FIELD_NAME)
|
|
267
265
|
report_builder.add_column(NotebookExperimentOptionPseudoDef.OPTION_KEY__FIELD_NAME)
|
|
@@ -291,9 +289,8 @@ class ExperimentReportUtil:
|
|
|
291
289
|
"""
|
|
292
290
|
entries: list[int] = AliasUtil.to_entry_ids(entries)
|
|
293
291
|
report_builder = CustomReportBuilder(EnbEntryOptionsPseudoDef.DATA_TYPE_NAME)
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
entries)
|
|
292
|
+
tb = report_builder.get_term_builder()
|
|
293
|
+
root = tb.is_term(EnbEntryOptionsPseudoDef.ENTRY_ID__FIELD_NAME, entries)
|
|
297
294
|
report_builder.set_root_term(root)
|
|
298
295
|
report_builder.add_column(EnbEntryOptionsPseudoDef.ENTRY_ID__FIELD_NAME)
|
|
299
296
|
report_builder.add_column(EnbEntryOptionsPseudoDef.ENTRY_OPTION_KEY__FIELD_NAME)
|
|
@@ -323,13 +320,12 @@ class ExperimentReportUtil:
|
|
|
323
320
|
exp_ids: list[int] = AliasUtil.to_notebook_ids(experiments)
|
|
324
321
|
|
|
325
322
|
report_builder = CustomReportBuilder(NotebookExperimentPseudoDef.DATA_TYPE_NAME)
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
NotebookExperimentPseudoDef.EXPERIMENT_RECORD_ID__FIELD_NAME))
|
|
323
|
+
tb = report_builder.get_term_builder()
|
|
324
|
+
root = tb.is_term(NotebookExperimentPseudoDef.EXPERIMENT_ID__FIELD_NAME, exp_ids)
|
|
325
|
+
report_builder.add_join(tb.compare_is_term("ELNExperiment",
|
|
326
|
+
"RecordId",
|
|
327
|
+
NotebookExperimentPseudoDef.DATA_TYPE_NAME,
|
|
328
|
+
NotebookExperimentPseudoDef.EXPERIMENT_RECORD_ID__FIELD_NAME))
|
|
333
329
|
report_builder.set_root_term(root)
|
|
334
330
|
report_builder.add_column(NotebookExperimentPseudoDef.EXPERIMENT_ID__FIELD_NAME)
|
|
335
331
|
report_builder.add_column("TemplateExperimentName", FieldType.STRING, data_type="ELNExperiment")
|
|
@@ -474,100 +470,101 @@ class ExperimentReportUtil:
|
|
|
474
470
|
"""
|
|
475
471
|
dt: str = NotebookExperimentPseudoDef.DATA_TYPE_NAME
|
|
476
472
|
report_builder = CustomReportBuilder(dt)
|
|
473
|
+
tb = report_builder.get_term_builder()
|
|
477
474
|
report_builder.add_column(NotebookExperimentPseudoDef.EXPERIMENT_ID__FIELD_NAME)
|
|
478
475
|
|
|
479
476
|
root: AbstractReportTerm | None = None
|
|
480
477
|
if criteria.notebook_ids is not None:
|
|
481
|
-
root =
|
|
478
|
+
root = tb.is_term(NotebookExperimentPseudoDef.EXPERIMENT_ID__FIELD_NAME, criteria.notebook_ids)
|
|
482
479
|
if criteria.not_notebook_ids is not None:
|
|
483
|
-
term =
|
|
480
|
+
term = tb.not_term(NotebookExperimentPseudoDef.EXPERIMENT_ID__FIELD_NAME, criteria.not_notebook_ids)
|
|
484
481
|
if root is not None:
|
|
485
|
-
root =
|
|
482
|
+
root = tb.and_terms(root, term)
|
|
486
483
|
if root is None:
|
|
487
484
|
root = ExperimentReportUtil.all_notebook_experiments_term()
|
|
488
485
|
|
|
489
486
|
if criteria.names is not None:
|
|
490
|
-
term =
|
|
491
|
-
root =
|
|
487
|
+
term = tb.is_term(NotebookExperimentPseudoDef.EXPERIMENT_NAME__FIELD_NAME, criteria.names)
|
|
488
|
+
root = tb.and_terms(root, term)
|
|
492
489
|
if criteria.not_names is not None:
|
|
493
|
-
term =
|
|
494
|
-
root =
|
|
490
|
+
term = tb.not_term(NotebookExperimentPseudoDef.EXPERIMENT_NAME__FIELD_NAME, criteria.not_names)
|
|
491
|
+
root = tb.and_terms(root, term)
|
|
495
492
|
|
|
496
493
|
if criteria.created_by is not None:
|
|
497
|
-
term =
|
|
498
|
-
root =
|
|
494
|
+
term = tb.is_term(NotebookExperimentPseudoDef.CREATED_BY__FIELD_NAME, criteria.created_by)
|
|
495
|
+
root = tb.and_terms(root, term)
|
|
499
496
|
if criteria.not_created_by is not None:
|
|
500
|
-
term =
|
|
501
|
-
root =
|
|
497
|
+
term = tb.not_term(NotebookExperimentPseudoDef.CREATED_BY__FIELD_NAME, criteria.not_created_by)
|
|
498
|
+
root = tb.and_terms(root, term)
|
|
502
499
|
|
|
503
500
|
if criteria.last_modified_by is not None:
|
|
504
|
-
term =
|
|
505
|
-
root =
|
|
501
|
+
term = tb.is_term(NotebookExperimentPseudoDef.LAST_MODIFIED_BY__FIELD_NAME, criteria.last_modified_by)
|
|
502
|
+
root = tb.and_terms(root, term)
|
|
506
503
|
if criteria.not_last_modified_by is not None:
|
|
507
|
-
term =
|
|
508
|
-
root =
|
|
504
|
+
term = tb.not_term(NotebookExperimentPseudoDef.LAST_MODIFIED_BY__FIELD_NAME, criteria.not_last_modified_by)
|
|
505
|
+
root = tb.and_terms(root, term)
|
|
509
506
|
|
|
510
507
|
if criteria.owners is not None:
|
|
511
|
-
term =
|
|
512
|
-
root =
|
|
508
|
+
term = tb.is_term(NotebookExperimentPseudoDef.EXPERIMENT_OWNER__FIELD_NAME, criteria.owners)
|
|
509
|
+
root = tb.and_terms(root, term)
|
|
513
510
|
if criteria.not_owners is not None:
|
|
514
|
-
term =
|
|
515
|
-
root =
|
|
511
|
+
term = tb.not_term(NotebookExperimentPseudoDef.EXPERIMENT_OWNER__FIELD_NAME, criteria.not_owners)
|
|
512
|
+
root = tb.and_terms(root, term)
|
|
516
513
|
|
|
517
514
|
if criteria.statuses is not None:
|
|
518
|
-
term =
|
|
519
|
-
root =
|
|
515
|
+
term = tb.is_term(NotebookExperimentPseudoDef.STATUS__FIELD_NAME, criteria.statuses)
|
|
516
|
+
root = tb.and_terms(root, term)
|
|
520
517
|
if criteria.not_statuses is not None:
|
|
521
|
-
term =
|
|
522
|
-
root =
|
|
518
|
+
term = tb.not_term(NotebookExperimentPseudoDef.STATUS__FIELD_NAME, criteria.not_statuses)
|
|
519
|
+
root = tb.and_terms(root, term)
|
|
523
520
|
|
|
524
521
|
# For the template name term, we need to join on the experiment record.
|
|
525
522
|
if criteria.templates is not None or criteria.not_templates is not None:
|
|
526
|
-
join =
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
523
|
+
join = tb.compare_is_term("ELNExperiment",
|
|
524
|
+
"RecordId",
|
|
525
|
+
NotebookExperimentPseudoDef.DATA_TYPE_NAME,
|
|
526
|
+
NotebookExperimentPseudoDef.EXPERIMENT_RECORD_ID__FIELD_NAME)
|
|
530
527
|
report_builder.add_join(join)
|
|
531
528
|
if criteria.templates is not None:
|
|
532
|
-
term =
|
|
533
|
-
root =
|
|
529
|
+
term = tb.is_term("TemplateExperimentName", criteria.templates, data_type="ELNExperiment")
|
|
530
|
+
root = tb.and_terms(root, term)
|
|
534
531
|
if criteria.not_templates is not None:
|
|
535
|
-
term =
|
|
536
|
-
root =
|
|
532
|
+
term = tb.not_term("TemplateExperimentName", criteria.not_templates, data_type="ELNExperiment")
|
|
533
|
+
root = tb.and_terms(root, term)
|
|
537
534
|
|
|
538
535
|
if criteria.is_from_template is not None:
|
|
539
|
-
term =
|
|
540
|
-
root =
|
|
536
|
+
term = tb.is_term(NotebookExperimentPseudoDef.IS_TEMPLATE__FIELD_NAME, criteria.is_from_template)
|
|
537
|
+
root = tb.and_terms(root, term)
|
|
541
538
|
if criteria.is_from_protocol_template is not None:
|
|
542
|
-
term =
|
|
543
|
-
root =
|
|
539
|
+
term = tb.is_term(NotebookExperimentPseudoDef.IS_PROTOCOL_TEMPLATE__FIELD_NAME, criteria.is_from_protocol_template)
|
|
540
|
+
root = tb.and_terms(root, term)
|
|
544
541
|
if criteria.is_modifiable is not None:
|
|
545
|
-
term =
|
|
546
|
-
root =
|
|
542
|
+
term = tb.is_term(NotebookExperimentPseudoDef.IS_MODIFIABLE__FIELD_NAME, criteria.is_modifiable)
|
|
543
|
+
root = tb.and_terms(root, term)
|
|
547
544
|
if criteria.is_active is not None:
|
|
548
|
-
term =
|
|
549
|
-
root =
|
|
545
|
+
term = tb.is_term(NotebookExperimentPseudoDef.IS_ACTIVE__FIELD_NAME, criteria.is_active)
|
|
546
|
+
root = tb.and_terms(root, term)
|
|
550
547
|
|
|
551
548
|
if criteria.created_after is not None:
|
|
552
|
-
term =
|
|
553
|
-
root =
|
|
549
|
+
term = tb.gte_term(NotebookExperimentPseudoDef.DATE_CREATED__FIELD_NAME, criteria.created_after)
|
|
550
|
+
root = tb.and_terms(root, term)
|
|
554
551
|
if criteria.created_before is not None:
|
|
555
|
-
term =
|
|
556
|
-
root =
|
|
552
|
+
term = tb.lte_term(NotebookExperimentPseudoDef.DATE_CREATED__FIELD_NAME, criteria.created_before)
|
|
553
|
+
root = tb.and_terms(root, term)
|
|
557
554
|
|
|
558
555
|
if criteria.last_modified_after is not None:
|
|
559
|
-
term =
|
|
560
|
-
root =
|
|
556
|
+
term = tb.gte_term(NotebookExperimentPseudoDef.LAST_MODIFIED_DATE__FIELD_NAME, criteria.last_modified_after)
|
|
557
|
+
root = tb.and_terms(root, term)
|
|
561
558
|
if criteria.last_modified_before is not None:
|
|
562
|
-
term =
|
|
563
|
-
root =
|
|
559
|
+
term = tb.lte_term(NotebookExperimentPseudoDef.LAST_MODIFIED_DATE__FIELD_NAME, criteria.last_modified_before)
|
|
560
|
+
root = tb.and_terms(root, term)
|
|
564
561
|
|
|
565
562
|
if criteria.due_after is not None:
|
|
566
|
-
term =
|
|
567
|
-
root =
|
|
563
|
+
term = tb.gte_term(NotebookExperimentPseudoDef.APPROVAL_DUE_DATE__FIELD_NAME, criteria.due_after)
|
|
564
|
+
root = tb.and_terms(root, term)
|
|
568
565
|
if criteria.due_before is not None:
|
|
569
|
-
term =
|
|
570
|
-
root =
|
|
566
|
+
term = tb.lte_term(NotebookExperimentPseudoDef.APPROVAL_DUE_DATE__FIELD_NAME, criteria.due_before)
|
|
567
|
+
root = tb.and_terms(root, term)
|
|
571
568
|
|
|
572
569
|
report_builder.set_root_term(root)
|
|
573
570
|
return report_builder.build_report_criteria()
|
|
@@ -597,9 +594,8 @@ class ExperimentReportUtil:
|
|
|
597
594
|
"""
|
|
598
595
|
:return: A report term searching for all notebook experiments.
|
|
599
596
|
"""
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
0)
|
|
597
|
+
tb = TermBuilder(NotebookExperimentPseudoDef.DATA_TYPE_NAME)
|
|
598
|
+
return tb.gte_term(NotebookExperimentPseudoDef.EXPERIMENT_ID__FIELD_NAME, 0)
|
|
603
599
|
|
|
604
600
|
@staticmethod
|
|
605
601
|
def __get_record_experiment_relation_rows(user: SapioUser, data_type_name: str, record_ids: list[int] | None = None,
|
|
@@ -610,39 +606,39 @@ class ExperimentReportUtil:
|
|
|
610
606
|
"""
|
|
611
607
|
assert (record_ids or exp_ids)
|
|
612
608
|
|
|
609
|
+
report_builder = CustomReportBuilder(data_type_name)
|
|
610
|
+
tb = report_builder.get_term_builder()
|
|
613
611
|
if record_ids:
|
|
614
|
-
records_term =
|
|
612
|
+
records_term = tb.is_term("RecordId", record_ids)
|
|
615
613
|
else:
|
|
616
614
|
# Get all records of the given type
|
|
617
|
-
records_term =
|
|
615
|
+
records_term = tb.all_records_term()
|
|
618
616
|
|
|
619
617
|
if exp_ids:
|
|
620
|
-
exp_term =
|
|
621
|
-
|
|
622
|
-
exp_ids)
|
|
618
|
+
exp_term = tb.is_term(NotebookExperimentPseudoDef.EXPERIMENT_ID__FIELD_NAME, exp_ids,
|
|
619
|
+
data_type=NotebookExperimentPseudoDef.DATA_TYPE_NAME)
|
|
623
620
|
else:
|
|
624
621
|
# Get all experiments
|
|
625
622
|
exp_term = ExperimentReportUtil.all_notebook_experiments_term()
|
|
626
623
|
|
|
627
|
-
root_term =
|
|
624
|
+
root_term = tb.and_terms(records_term, exp_term)
|
|
628
625
|
|
|
629
626
|
# Join records on the experiment entry records that correspond to them.
|
|
630
|
-
records_entry_join =
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
627
|
+
records_entry_join = tb.compare_is_term(data_type_name,
|
|
628
|
+
"RecordId",
|
|
629
|
+
ExperimentEntryRecordPseudoDef.DATA_TYPE_NAME,
|
|
630
|
+
ExperimentEntryRecordPseudoDef.RECORD_ID__FIELD_NAME)
|
|
634
631
|
# Join entry records on the experiment entries they are in.
|
|
635
|
-
experiment_entry_enb_entry_join =
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
632
|
+
experiment_entry_enb_entry_join = tb.compare_is_term(EnbEntryPseudoDef.DATA_TYPE_NAME,
|
|
633
|
+
EnbEntryPseudoDef.ENTRY_ID__FIELD_NAME,
|
|
634
|
+
ExperimentEntryRecordPseudoDef.DATA_TYPE_NAME,
|
|
635
|
+
ExperimentEntryRecordPseudoDef.ENTRY_ID__FIELD_NAME)
|
|
639
636
|
# Join entries on the experiments they are in.
|
|
640
|
-
enb_entry_experiment_join =
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
637
|
+
enb_entry_experiment_join = tb.compare_is_term(NotebookExperimentPseudoDef.DATA_TYPE_NAME,
|
|
638
|
+
NotebookExperimentPseudoDef.EXPERIMENT_ID__FIELD_NAME,
|
|
639
|
+
EnbEntryPseudoDef.DATA_TYPE_NAME,
|
|
640
|
+
EnbEntryPseudoDef.EXPERIMENT_ID__FIELD_NAME)
|
|
644
641
|
|
|
645
|
-
report_builder = CustomReportBuilder(data_type_name)
|
|
646
642
|
report_builder.set_root_term(root_term)
|
|
647
643
|
report_builder.add_column("RecordId", FieldType.LONG)
|
|
648
644
|
report_builder.add_column(NotebookExperimentPseudoDef.EXPERIMENT_ID__FIELD_NAME,
|
|
@@ -137,16 +137,13 @@ class AuditLogUtil:
|
|
|
137
137
|
# Build the raw report term querying for any entry with a matching record ID value to the record ID's
|
|
138
138
|
# passed in.
|
|
139
139
|
record_ids = AliasUtil.to_record_ids(records)
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
record_ids)
|
|
140
|
+
tb = TermBuilder(AuditLogPseudoDef.DATA_TYPE_NAME)
|
|
141
|
+
root_term = tb.is_term(AuditLogPseudoDef.RECORD_ID__FIELD_NAME, record_ids)
|
|
143
142
|
|
|
144
143
|
# If the user passed in any specific fields, then we should limit the query to those fields.
|
|
145
144
|
if fields:
|
|
146
145
|
fields: list[str] = AliasUtil.to_data_field_names(fields)
|
|
147
|
-
field_term =
|
|
148
|
-
AuditLogPseudoDef.DATA_FIELD_NAME__FIELD_NAME,
|
|
149
|
-
fields)
|
|
146
|
+
field_term = tb.is_term(AuditLogPseudoDef.DATA_FIELD_NAME__FIELD_NAME, fields)
|
|
150
147
|
root_term = TermBuilder.and_terms(root_term, field_term)
|
|
151
148
|
|
|
152
149
|
return CustomReportCriteria(AuditLogUtil.report_columns(), root_term)
|
|
@@ -6,7 +6,6 @@ from sapiopylib.rest.pojo.webhook.WebhookContext import SapioWebhookContext
|
|
|
6
6
|
from sapiopylib.rest.utils.recordmodel.RecordModelWrapper import WrappedType
|
|
7
7
|
|
|
8
8
|
from sapiopycommons.customreport.custom_report_builder import CustomReportBuilder
|
|
9
|
-
from sapiopycommons.customreport.term_builder import TermBuilder
|
|
10
9
|
from sapiopycommons.datatype.data_fields import ProcessQueueItemFields, SystemFields, ProcessWorkflowTrackingFields
|
|
11
10
|
from sapiopycommons.general.aliases import UserIdentifier, AliasUtil, SapioRecord
|
|
12
11
|
from sapiopycommons.general.custom_report_util import CustomReportUtil
|
|
@@ -338,69 +337,70 @@ class QueueItemHandler:
|
|
|
338
337
|
"""
|
|
339
338
|
dt: str = ProcessQueueItemFields.DATA_TYPE_NAME
|
|
340
339
|
report_builder = CustomReportBuilder(dt)
|
|
340
|
+
tb = report_builder.get_term_builder()
|
|
341
341
|
report_builder.add_column(SystemFields.RECORD_ID__FIELD)
|
|
342
342
|
report_builder.add_column(ProcessQueueItemFields.DATA_RECORD_ID__FIELD)
|
|
343
343
|
|
|
344
|
-
root =
|
|
344
|
+
root = tb.all_records_term()
|
|
345
345
|
|
|
346
346
|
if criteria.process_names is not None:
|
|
347
|
-
term =
|
|
348
|
-
root =
|
|
347
|
+
term = tb.is_term(ProcessQueueItemFields.PROCESS_HEADER_NAME__FIELD, criteria.process_names)
|
|
348
|
+
root = tb.and_terms(root, term)
|
|
349
349
|
if criteria.not_process_names is not None:
|
|
350
|
-
term =
|
|
351
|
-
root =
|
|
350
|
+
term = tb.not_term(ProcessQueueItemFields.PROCESS_HEADER_NAME__FIELD, criteria.not_process_names)
|
|
351
|
+
root = tb.and_terms(root, term)
|
|
352
352
|
|
|
353
353
|
if criteria.step_names is not None:
|
|
354
|
-
term =
|
|
355
|
-
root =
|
|
354
|
+
term = tb.is_term(ProcessQueueItemFields.WORKFLOW_HEADER_NAME__FIELD, criteria.step_names)
|
|
355
|
+
root = tb.and_terms(root, term)
|
|
356
356
|
if criteria.not_step_names is not None:
|
|
357
|
-
term =
|
|
358
|
-
root =
|
|
357
|
+
term = tb.not_term(ProcessQueueItemFields.WORKFLOW_HEADER_NAME__FIELD, criteria.not_step_names)
|
|
358
|
+
root = tb.and_terms(root, term)
|
|
359
359
|
|
|
360
360
|
if criteria.data_type_names is not None:
|
|
361
|
-
term =
|
|
362
|
-
root =
|
|
361
|
+
term = tb.is_term(ProcessQueueItemFields.DATA_TYPE_NAME__FIELD, criteria.data_type_names)
|
|
362
|
+
root = tb.and_terms(root, term)
|
|
363
363
|
if criteria.not_data_type_names is not None:
|
|
364
|
-
term =
|
|
365
|
-
root =
|
|
364
|
+
term = tb.not_term(ProcessQueueItemFields.DATA_TYPE_NAME__FIELD, criteria.not_data_type_names)
|
|
365
|
+
root = tb.and_terms(root, term)
|
|
366
366
|
|
|
367
367
|
if criteria.data_record_ids is not None:
|
|
368
|
-
term =
|
|
369
|
-
root =
|
|
368
|
+
term = tb.is_term(ProcessQueueItemFields.DATA_RECORD_ID__FIELD, criteria.data_record_ids)
|
|
369
|
+
root = tb.and_terms(root, term)
|
|
370
370
|
if criteria.not_data_record_ids is not None:
|
|
371
|
-
term =
|
|
372
|
-
root =
|
|
371
|
+
term = tb.not_term(ProcessQueueItemFields.DATA_RECORD_ID__FIELD, criteria.not_data_record_ids)
|
|
372
|
+
root = tb.and_terms(root, term)
|
|
373
373
|
|
|
374
374
|
if criteria.assigned_to is not None:
|
|
375
|
-
term =
|
|
376
|
-
root =
|
|
375
|
+
term = tb.is_term(ProcessQueueItemFields.ASSIGNED_TO__FIELD, criteria.assigned_to)
|
|
376
|
+
root = tb.and_terms(root, term)
|
|
377
377
|
if criteria.not_assigned_to is not None:
|
|
378
|
-
term =
|
|
379
|
-
root =
|
|
378
|
+
term = tb.not_term(ProcessQueueItemFields.ASSIGNED_TO__FIELD, criteria.not_assigned_to)
|
|
379
|
+
root = tb.and_terms(root, term)
|
|
380
380
|
|
|
381
381
|
if criteria.launched_after is not None:
|
|
382
|
-
term =
|
|
383
|
-
root =
|
|
382
|
+
term = tb.gte_term(ProcessQueueItemFields.LAUNCHED_DATE__FIELD, criteria.launched_after)
|
|
383
|
+
root = tb.and_terms(root, term)
|
|
384
384
|
if criteria.launched_before is not None:
|
|
385
|
-
term =
|
|
386
|
-
root =
|
|
385
|
+
term = tb.lte_term(ProcessQueueItemFields.LAUNCHED_DATE__FIELD, criteria.launched_before)
|
|
386
|
+
root = tb.and_terms(root, term)
|
|
387
387
|
|
|
388
388
|
if criteria.scheduled_after is not None:
|
|
389
|
-
term =
|
|
390
|
-
root =
|
|
389
|
+
term = tb.gte_term(ProcessQueueItemFields.LAUNCHED_DATE__FIELD, criteria.scheduled_after)
|
|
390
|
+
root = tb.and_terms(root, term)
|
|
391
391
|
if criteria.scheduled_before is not None:
|
|
392
|
-
term =
|
|
393
|
-
root =
|
|
392
|
+
term = tb.lte_term(ProcessQueueItemFields.LAUNCHED_DATE__FIELD, criteria.scheduled_before)
|
|
393
|
+
root = tb.and_terms(root, term)
|
|
394
394
|
|
|
395
395
|
if criteria.shown_in_queue is not None:
|
|
396
|
-
term =
|
|
397
|
-
root =
|
|
396
|
+
term = tb.is_term(ProcessQueueItemFields.SHOW_IN_QUEUE__FIELD, criteria.shown_in_queue)
|
|
397
|
+
root = tb.and_terms(root, term)
|
|
398
398
|
if criteria.has_experiment is not None:
|
|
399
399
|
if criteria.has_experiment:
|
|
400
|
-
term =
|
|
400
|
+
term = tb.not_term(ProcessQueueItemFields.EXPERIMENT__FIELD, None)
|
|
401
401
|
else:
|
|
402
|
-
term =
|
|
403
|
-
root =
|
|
402
|
+
term = tb.is_term(ProcessQueueItemFields.EXPERIMENT__FIELD, None)
|
|
403
|
+
root = tb.and_terms(root, term)
|
|
404
404
|
|
|
405
405
|
report_builder.set_root_term(root)
|
|
406
406
|
return report_builder.build_report_criteria()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: sapiopycommons
|
|
3
|
-
Version: 2024.12.
|
|
3
|
+
Version: 2024.12.9a378
|
|
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>
|
|
@@ -7,15 +7,15 @@ sapiopycommons/chem/Molecules.py,sha256=9B4sbwbvYs50XHRn0TZiu-D1Oa3pKrI9qE5vNW8z
|
|
|
7
7
|
sapiopycommons/chem/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
sapiopycommons/customreport/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
9
|
sapiopycommons/customreport/column_builder.py,sha256=0RO53e9rKPZ07C--KcepN6_tpRw_FxF3O9vdG0ilKG8,3014
|
|
10
|
-
sapiopycommons/customreport/custom_report_builder.py,sha256=
|
|
11
|
-
sapiopycommons/customreport/term_builder.py,sha256=
|
|
10
|
+
sapiopycommons/customreport/custom_report_builder.py,sha256=BlTxZ4t1sfZA2Ciur1EfYvkZxHxJ7ADwYNAe2zwiN0c,7176
|
|
11
|
+
sapiopycommons/customreport/term_builder.py,sha256=PNp71NF1vFxidk5v6uQNi9oQR9KJIk8WfhyntvvZN-U,18573
|
|
12
12
|
sapiopycommons/datatype/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
13
|
sapiopycommons/datatype/attachment_util.py,sha256=_l2swuP8noIGAl4bwzBUEhr6YlN_OVZl3-gi1XqFHYA,3364
|
|
14
14
|
sapiopycommons/datatype/data_fields.py,sha256=g8Ib6LH8ikNu9AzeVJs8Z2qS8A-cplACeFU7vYguNEY,4063
|
|
15
15
|
sapiopycommons/datatype/pseudo_data_types.py,sha256=Fe75Rnq5evyeJM1nC0sLkLGKAC74g2-GEeTdMeId80o,27649
|
|
16
16
|
sapiopycommons/eln/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
17
|
sapiopycommons/eln/experiment_handler.py,sha256=ZSx0uZy-2OtH_ArHy2OVwoNI3BYQLXSHGBmjviZl1Fw,69283
|
|
18
|
-
sapiopycommons/eln/experiment_report_util.py,sha256=
|
|
18
|
+
sapiopycommons/eln/experiment_report_util.py,sha256=bs9zSUgRo40q2VYtjDCVPsT-D1umdNfl5s4oZrY4uuc,36597
|
|
19
19
|
sapiopycommons/eln/plate_designer.py,sha256=FYJfhhNq8hdfuXgDYOYHy6g0m2zNwQXZWF_MTPzElDg,7184
|
|
20
20
|
sapiopycommons/files/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
21
21
|
sapiopycommons/files/complex_data_loader.py,sha256=T39veNhvYl6j_uZjIIJ8Mk5Aa7otR5RB-g8XlAdkksA,1421
|
|
@@ -30,7 +30,7 @@ sapiopycommons/flowcyto/flowcyto_data.py,sha256=mYKFuLbtpJ-EsQxLGtu4tNHVlygTxKix
|
|
|
30
30
|
sapiopycommons/general/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
31
31
|
sapiopycommons/general/accession_service.py,sha256=HYgyOsH_UaoRnoury-c2yTW8SeG4OtjLemdpCzoV4R8,13484
|
|
32
32
|
sapiopycommons/general/aliases.py,sha256=tdDBNWSGx6s39eHJ3n2kscc4xxW3ZYaUfDftct6FmJE,12910
|
|
33
|
-
sapiopycommons/general/audit_log.py,sha256=
|
|
33
|
+
sapiopycommons/general/audit_log.py,sha256=L-RiaSusvC2MxrEParBPYWrahymLQosEVEJKiiYb1VQ,8759
|
|
34
34
|
sapiopycommons/general/custom_report_util.py,sha256=6ZIg_Jl02TYUygfc5xqBoI1srPsSxLyxaJ9jwTolGcM,16671
|
|
35
35
|
sapiopycommons/general/exceptions.py,sha256=GY7fe0qOgoy4kQVn_Pn3tdzHsJZyNIpa6VCChg6tzuM,1813
|
|
36
36
|
sapiopycommons/general/popup_util.py,sha256=L-4qpTemSZdlD6_6oEsDYIzLOCiZgDK6wC6DqUwzOYA,31925
|
|
@@ -40,7 +40,7 @@ sapiopycommons/general/time_util.py,sha256=jU1urPoZRv6evNucR0-288EyT4PrsDpCr-H1-
|
|
|
40
40
|
sapiopycommons/multimodal/multimodal.py,sha256=A1QsC8QTPmgZyPr7KtMbPRedn2Ie4WIErodUvQ9otgU,6724
|
|
41
41
|
sapiopycommons/multimodal/multimodal_data.py,sha256=0BeVPr9HaC0hNTF1v1phTIKGruvNnwerHsD994qJKBg,15099
|
|
42
42
|
sapiopycommons/processtracking/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
43
|
-
sapiopycommons/processtracking/custom_workflow_handler.py,sha256=
|
|
43
|
+
sapiopycommons/processtracking/custom_workflow_handler.py,sha256=B8KxQlwlLGkxnEid2jb9igGyGqrtcsBMhcOb9MfnO9E,23465
|
|
44
44
|
sapiopycommons/processtracking/endpoints.py,sha256=w5bziI2xC7450M95rCF8JpRwkoni1kEDibyAux9B12Q,10848
|
|
45
45
|
sapiopycommons/recordmodel/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
46
46
|
sapiopycommons/recordmodel/record_handler.py,sha256=5kCO5zsSg0kp3uYpgw1vf0WLHw30pMNC_6Bn3G7iQkI,64796
|
|
@@ -53,7 +53,7 @@ sapiopycommons/webhook/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
|
|
|
53
53
|
sapiopycommons/webhook/webhook_context.py,sha256=D793uLsb1691SalaPnBUk3rOSxn_hYLhdvkaIxjNXss,1909
|
|
54
54
|
sapiopycommons/webhook/webhook_handlers.py,sha256=MdsVK4bHffkMNmNWl0_qvu-5Lz8-qGu4Ryi7lZO1BZs,18586
|
|
55
55
|
sapiopycommons/webhook/webservice_handlers.py,sha256=AFM2Va9Fpb2BvlFycIUUOdghtGiEv1Ab5jf44yjHSgU,17218
|
|
56
|
-
sapiopycommons-2024.12.
|
|
57
|
-
sapiopycommons-2024.12.
|
|
58
|
-
sapiopycommons-2024.12.
|
|
59
|
-
sapiopycommons-2024.12.
|
|
56
|
+
sapiopycommons-2024.12.9a378.dist-info/METADATA,sha256=QaoCRUSYWLym5unbq9pWM1crBbv-aGeLmgCtWpLxcko,3143
|
|
57
|
+
sapiopycommons-2024.12.9a378.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
|
58
|
+
sapiopycommons-2024.12.9a378.dist-info/licenses/LICENSE,sha256=HyVuytGSiAUQ6ErWBHTqt1iSGHhLmlC8fO7jTCuR8dU,16725
|
|
59
|
+
sapiopycommons-2024.12.9a378.dist-info/RECORD,,
|
|
File without changes
|
{sapiopycommons-2024.12.5a376.dist-info → sapiopycommons-2024.12.9a378.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|