sapiopycommons 2024.8.15a304__py3-none-any.whl → 2024.8.19a305__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 (28) hide show
  1. sapiopycommons/callbacks/callback_util.py +122 -25
  2. sapiopycommons/customreport/__init__.py +0 -0
  3. sapiopycommons/customreport/column_builder.py +60 -0
  4. sapiopycommons/customreport/custom_report_builder.py +125 -0
  5. sapiopycommons/customreport/term_builder.py +296 -0
  6. sapiopycommons/datatype/attachment_util.py +15 -6
  7. sapiopycommons/eln/experiment_handler.py +193 -39
  8. sapiopycommons/files/complex_data_loader.py +1 -1
  9. sapiopycommons/files/file_bridge.py +1 -1
  10. sapiopycommons/files/file_bridge_handler.py +21 -0
  11. sapiopycommons/files/file_util.py +38 -5
  12. sapiopycommons/files/file_validator.py +21 -6
  13. sapiopycommons/files/file_writer.py +44 -15
  14. sapiopycommons/general/aliases.py +93 -2
  15. sapiopycommons/general/audit_log.py +200 -0
  16. sapiopycommons/general/popup_util.py +17 -0
  17. sapiopycommons/general/sapio_links.py +48 -0
  18. sapiopycommons/general/time_util.py +40 -0
  19. sapiopycommons/recordmodel/record_handler.py +114 -17
  20. sapiopycommons/rules/eln_rule_handler.py +29 -22
  21. sapiopycommons/rules/on_save_rule_handler.py +29 -28
  22. sapiopycommons/webhook/webhook_handlers.py +90 -26
  23. sapiopycommons/webhook/webservice_handlers.py +67 -0
  24. {sapiopycommons-2024.8.15a304.dist-info → sapiopycommons-2024.8.19a305.dist-info}/METADATA +1 -1
  25. sapiopycommons-2024.8.19a305.dist-info/RECORD +50 -0
  26. sapiopycommons-2024.8.15a304.dist-info/RECORD +0 -43
  27. {sapiopycommons-2024.8.15a304.dist-info → sapiopycommons-2024.8.19a305.dist-info}/WHEEL +0 -0
  28. {sapiopycommons-2024.8.15a304.dist-info → sapiopycommons-2024.8.19a305.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,67 @@
1
+ import sys
2
+ import traceback
3
+ from abc import abstractmethod
4
+ from typing import Any
5
+
6
+ from flask import request
7
+ from sapiopylib.rest.User import SapioUser
8
+ from sapiopylib.rest.WebhookService import AbstractWebhookHandler
9
+ from sapiopylib.rest.pojo.webhook.WebhookResult import SapioWebhookResult
10
+
11
+
12
+ class AbstractWebserviceHandler(AbstractWebhookHandler):
13
+ """
14
+ A base class for constructing "webservice" endpoints on your webhook server. These are endpoints that can be
15
+ communicated with by external sources without needing to format the payload JSON in the webhook context format that
16
+ webhook handlers expect.
17
+
18
+ The entire payload JSON is sent to the run method of this class. It is up to the run method to determine how
19
+ this JSON should be parsed. In order to communicate with a Sapio system, a SapioUser object must be able to be
20
+ defined using the payload. Functions have been provided for constructing users with various authentication methods.
21
+
22
+ Since this extends AbstractWebhookHandler, you can still register endpoints from this class in the same way you
23
+ would normal webhook endpoints.
24
+ """
25
+ def post(self) -> dict[str, Any]:
26
+ """
27
+ Internal method to be executed to translate incoming requests.
28
+ """
29
+ # noinspection PyBroadException
30
+ try:
31
+ return self.run(request.json).to_json()
32
+ except Exception:
33
+ print('Error occurred while running webservice custom logic. See traceback.', file=sys.stderr)
34
+ traceback.print_exc()
35
+ return SapioWebhookResult(False, display_text="Error occurred during webservice execution.").to_json()
36
+
37
+ @abstractmethod
38
+ def run(self, payload: dict[str, Any]) -> SapioWebhookResult:
39
+ pass
40
+
41
+ def basic_auth(self, url: str, username: str, password: str) -> SapioUser:
42
+ """
43
+ :param url: The URL of the Sapio system that requests from this user will be sent to.
44
+ Must end in /webservice/api
45
+ :param username: The username to authenticate requests with.
46
+ :param password: The password to authenticate requests with.
47
+ :return: A SapioUser that will authenticate requests using basic auth.
48
+ """
49
+ return SapioUser(url, self.verify_sapio_cert, self.client_timeout_seconds, username=username, password=password)
50
+
51
+ def api_token_auth(self, url: str, api_token: str) -> SapioUser:
52
+ """
53
+ :param url: The URL of the Sapio system that requests from this user will be sent to.
54
+ Must end in /webservice/api
55
+ :param api_token: The API token to authenticate requests with.
56
+ :return: A SapioUser that will authenticate requests using an API token.
57
+ """
58
+ return SapioUser(url, self.verify_sapio_cert, self.client_timeout_seconds, api_token=api_token)
59
+
60
+ def bearer_token_auth(self, url: str, bearer_token: str) -> SapioUser:
61
+ """
62
+ :param url: The URL of the Sapio system that requests from this user will be sent to.
63
+ Must end in /webservice/api
64
+ :param bearer_token: The bearer token to authenticate requests with.
65
+ :return: A SapioUser that will authenticate requests using a bearer token.
66
+ """
67
+ return SapioUser(url, self.verify_sapio_cert, self.client_timeout_seconds, bearer_token=bearer_token)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: sapiopycommons
3
- Version: 2024.8.15a304
3
+ Version: 2024.8.19a305
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>
@@ -0,0 +1,50 @@
1
+ sapiopycommons/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ sapiopycommons/callbacks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ sapiopycommons/callbacks/callback_util.py,sha256=E9-PIO8NO2BBltd6Dy4eaha9u39V636NjM7IXR0TP_Y,63539
4
+ sapiopycommons/chem/IndigoMolecules.py,sha256=QqFDi9CKERj6sn_ZwVcS2xZq4imlkaTeCrpq1iNcEJA,1992
5
+ sapiopycommons/chem/Molecules.py,sha256=t80IsQBPJ9mwE8ZxnWomAGrZDhdsOuPvLaTPb_N6jGU,8639
6
+ sapiopycommons/chem/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ sapiopycommons/customreport/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ sapiopycommons/customreport/column_builder.py,sha256=sS_wZYOR72rs3syTNjwCVP4h8M8N0b0burkTxFQItVU,3019
9
+ sapiopycommons/customreport/custom_report_builder.py,sha256=o2O89OrWPm0OYS8Ux6EKZTg6hcUzfz3ZxAgnzJg1wEw,6601
10
+ sapiopycommons/customreport/term_builder.py,sha256=mOnm2c6EUOQVgoURmXHzqSGKuQjP2gswJmWecoeC4yw,16606
11
+ sapiopycommons/datatype/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ sapiopycommons/datatype/attachment_util.py,sha256=23JQ4avSmBBJdCv95LVj31x8rUCclzB_DYFBijH0NII,3708
13
+ sapiopycommons/eln/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
+ sapiopycommons/eln/experiment_handler.py,sha256=9wNRjwWHekKSAA_1io5WW1iDSezDXidWKAVn0bQZkbc,66161
15
+ sapiopycommons/eln/experiment_report_util.py,sha256=FTLw-6SLAMeoWTOO-qhGROE9g54pZdyoQJIhiIzlwGw,7848
16
+ sapiopycommons/eln/plate_designer.py,sha256=FYJfhhNq8hdfuXgDYOYHy6g0m2zNwQXZWF_MTPzElDg,7184
17
+ sapiopycommons/files/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
+ sapiopycommons/files/complex_data_loader.py,sha256=8jgYF5iGDD6Abw8JRWLYxUWVwj4s4pH5HylyxEGFZSU,1471
19
+ sapiopycommons/files/file_bridge.py,sha256=njx_5Z3tvQUNW4mPazQerL8lopLAFStIByHWHJ7m5ug,6220
20
+ sapiopycommons/files/file_bridge_handler.py,sha256=KCk8JTojMeHWgARqVlhOBXf-OInGuc6NW2vXG5Xf-7w,14352
21
+ sapiopycommons/files/file_data_handler.py,sha256=3-guAdhJdeJWAFq1a27ijspkO7uMMZ6CapMCD_6o4jA,36746
22
+ sapiopycommons/files/file_util.py,sha256=ZrgoGwHHfPdL5KHkGwlrEHJqGpttmZzRkGQCXdLjra8,28284
23
+ sapiopycommons/files/file_validator.py,sha256=HaZF4rqGXspkkyLPol5KAWvV7djuodzrIxg2EnNYoLw,28858
24
+ sapiopycommons/files/file_writer.py,sha256=96Xl8TTT46Krxe_J8rmmlEMtel4nzZB961f5Yqtl1-I,17616
25
+ sapiopycommons/general/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
+ sapiopycommons/general/accession_service.py,sha256=HYgyOsH_UaoRnoury-c2yTW8SeG4OtjLemdpCzoV4R8,13484
27
+ sapiopycommons/general/aliases.py,sha256=bSj4-oU6UDY1Yvlhr19RWVlSJf9NhfZE42y-xzYC-lg,7575
28
+ sapiopycommons/general/audit_log.py,sha256=YwBkm1kT6faXtipcUpoOtME3FZaUM46OtCE6KIzAROQ,9038
29
+ sapiopycommons/general/custom_report_util.py,sha256=cLgIR5Fn3M9uyAtgfTYRv3JRk2SKNevnsb_R5zidSYs,15557
30
+ sapiopycommons/general/exceptions.py,sha256=DOlLKnpCatxQF-lVCToa8ryJgusWLvip6N_1ALN00QE,1679
31
+ sapiopycommons/general/popup_util.py,sha256=vqLSiCry4YClSKIdnk56CIKioBOtawGVmPi2iS1LOIc,31763
32
+ sapiopycommons/general/sapio_links.py,sha256=UlqB09wmgDgbQiB8d3mEj7rxW_GMIXz3j3RlvADNt_A,2475
33
+ sapiopycommons/general/storage_util.py,sha256=ovmK_jN7v09BoX07XxwShpBUC5WYQOM7dbKV_VeLXJU,8892
34
+ sapiopycommons/general/time_util.py,sha256=sXThADCRAQDWYDD9C5CdhcKYIt3qOaVNyZfGBR7HW9A,8701
35
+ sapiopycommons/multimodal/multimodal.py,sha256=A1QsC8QTPmgZyPr7KtMbPRedn2Ie4WIErodUvQ9otgU,6724
36
+ sapiopycommons/multimodal/multimodal_data.py,sha256=zqgYHO-ULaPKV0POFWZVY9N-Sfm1RQWwdsfwFxe5DjI,15038
37
+ sapiopycommons/processtracking/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
+ sapiopycommons/processtracking/endpoints.py,sha256=g5h_uCVByqacYm9zWAz8TyAdRsGfaO2o0b5RSJdOaSA,10926
39
+ sapiopycommons/recordmodel/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
+ sapiopycommons/recordmodel/record_handler.py,sha256=Xr0fRkUW5nAY4NVKwkQR81WF23POX_FtVp4pP7QMgZ0,60188
41
+ sapiopycommons/rules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
42
+ sapiopycommons/rules/eln_rule_handler.py,sha256=QkK3TD9fxdw0usWik0eIRlcIDHaN3LgfR8laOElCA8A,10280
43
+ sapiopycommons/rules/on_save_rule_handler.py,sha256=STJ8QFeZGk5yUCPgiJ_Q0Trpn6rfXTFum0s2ECLfxHU,10047
44
+ sapiopycommons/webhook/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
+ sapiopycommons/webhook/webhook_handlers.py,sha256=jwc4xu-wwl8haS5k1dENZ1UIYK9GQk74TAo3CGxMW9U,16583
46
+ sapiopycommons/webhook/webservice_handlers.py,sha256=1J56zFI0pWl5MHoNTznvcZumITXgAHJMluj8-2BqYEw,3315
47
+ sapiopycommons-2024.8.19a305.dist-info/METADATA,sha256=RW_yNejA3ktxl81ktZx88D5R4g3Iq50c2gy6Svd5YBQ,3176
48
+ sapiopycommons-2024.8.19a305.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
49
+ sapiopycommons-2024.8.19a305.dist-info/licenses/LICENSE,sha256=HyVuytGSiAUQ6ErWBHTqt1iSGHhLmlC8fO7jTCuR8dU,16725
50
+ sapiopycommons-2024.8.19a305.dist-info/RECORD,,
@@ -1,43 +0,0 @@
1
- sapiopycommons/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- sapiopycommons/callbacks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- sapiopycommons/callbacks/callback_util.py,sha256=caeIWCHvK33jDs3TRskpJv0kDe7W8NPK4MyJPjgztwo,58012
4
- sapiopycommons/chem/IndigoMolecules.py,sha256=QqFDi9CKERj6sn_ZwVcS2xZq4imlkaTeCrpq1iNcEJA,1992
5
- sapiopycommons/chem/Molecules.py,sha256=t80IsQBPJ9mwE8ZxnWomAGrZDhdsOuPvLaTPb_N6jGU,8639
6
- sapiopycommons/chem/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- sapiopycommons/datatype/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- sapiopycommons/datatype/attachment_util.py,sha256=YlnMprj5IGBbAZDLG2khS1P7JIYTw_NYfpJAfRZfP3M,3219
9
- sapiopycommons/eln/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- sapiopycommons/eln/experiment_handler.py,sha256=v1pG4qtZb8OSNWfKtFo6NjnEkReqnu5R9i_hqWh_xxg,57198
11
- sapiopycommons/eln/experiment_report_util.py,sha256=FTLw-6SLAMeoWTOO-qhGROE9g54pZdyoQJIhiIzlwGw,7848
12
- sapiopycommons/eln/plate_designer.py,sha256=FYJfhhNq8hdfuXgDYOYHy6g0m2zNwQXZWF_MTPzElDg,7184
13
- sapiopycommons/files/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
- sapiopycommons/files/complex_data_loader.py,sha256=XSJOl676mIklJo78v07-70u1b015a5DI4sqZPI3C-Tw,1475
15
- sapiopycommons/files/file_bridge.py,sha256=GI3-gWFzcL0q0c8jKOxTevbzJqtUpiElmkXfTnMsaOo,6224
16
- sapiopycommons/files/file_bridge_handler.py,sha256=MU2wZR4VY606yx6Bnv8-LzG3mGCeuXeRBn914WNRFCo,13601
17
- sapiopycommons/files/file_data_handler.py,sha256=3-guAdhJdeJWAFq1a27ijspkO7uMMZ6CapMCD_6o4jA,36746
18
- sapiopycommons/files/file_util.py,sha256=44mzhn3M_QltoncBB-ooX7_yO6u5k-XU_bzUXHGxUiw,26299
19
- sapiopycommons/files/file_validator.py,sha256=BhXB2XnoNEzdBXuwul1s2RNoj-3ZoiMmephUCU_0o3Y,28113
20
- sapiopycommons/files/file_writer.py,sha256=5u_iZXTQvuUU7ceHZr8Q001_tvgJhOqBwAnB_pxcAbQ,16027
21
- sapiopycommons/general/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
- sapiopycommons/general/accession_service.py,sha256=HYgyOsH_UaoRnoury-c2yTW8SeG4OtjLemdpCzoV4R8,13484
23
- sapiopycommons/general/aliases.py,sha256=i6af5o2oVFGNcyk7GkvTWXQs0H9xTbFKc_GIah8NKVU,3594
24
- sapiopycommons/general/custom_report_util.py,sha256=cLgIR5Fn3M9uyAtgfTYRv3JRk2SKNevnsb_R5zidSYs,15557
25
- sapiopycommons/general/exceptions.py,sha256=DOlLKnpCatxQF-lVCToa8ryJgusWLvip6N_1ALN00QE,1679
26
- sapiopycommons/general/popup_util.py,sha256=-mN5IgYPrLrOEHJ4CHPi2rec4_WAN6X0yMxHwD5h3Bs,30126
27
- sapiopycommons/general/storage_util.py,sha256=ovmK_jN7v09BoX07XxwShpBUC5WYQOM7dbKV_VeLXJU,8892
28
- sapiopycommons/general/time_util.py,sha256=jiJUh7jc1ZRCOem880S3HaLPZ4RboBtSl4_U9sqAQuM,7290
29
- sapiopycommons/multimodal/multimodal.py,sha256=A1QsC8QTPmgZyPr7KtMbPRedn2Ie4WIErodUvQ9otgU,6724
30
- sapiopycommons/multimodal/multimodal_data.py,sha256=zqgYHO-ULaPKV0POFWZVY9N-Sfm1RQWwdsfwFxe5DjI,15038
31
- sapiopycommons/processtracking/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
- sapiopycommons/processtracking/endpoints.py,sha256=g5h_uCVByqacYm9zWAz8TyAdRsGfaO2o0b5RSJdOaSA,10926
33
- sapiopycommons/recordmodel/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
- sapiopycommons/recordmodel/record_handler.py,sha256=AyK1H3x-g1eu1Mt9XD1h57yRrZp_TJjZlEaQ2kPP4Dc,54432
35
- sapiopycommons/rules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
- sapiopycommons/rules/eln_rule_handler.py,sha256=qfkBZtck0KK1i9s9Xe2UZqkzQOgPCzDxRkhxE8Si1xk,10671
37
- sapiopycommons/rules/on_save_rule_handler.py,sha256=JY9F30IcHwFVdgPAMQtTYuRastV1jeezhVktyrzNASU,10763
38
- sapiopycommons/webhook/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
- sapiopycommons/webhook/webhook_handlers.py,sha256=ibpBY3Sk3Eij919bIdW0awzlogYoQSWYDDOg--NwsQE,13431
40
- sapiopycommons-2024.8.15a304.dist-info/METADATA,sha256=MAySm4oWvEe5RSyNWOoiu0F3qnD-zTzWVUvqulqlKpQ,3176
41
- sapiopycommons-2024.8.15a304.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
42
- sapiopycommons-2024.8.15a304.dist-info/licenses/LICENSE,sha256=HyVuytGSiAUQ6ErWBHTqt1iSGHhLmlC8fO7jTCuR8dU,16725
43
- sapiopycommons-2024.8.15a304.dist-info/RECORD,,