canvas 0.39.0__py3-none-any.whl → 0.40.1__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 canvas might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: canvas
3
- Version: 0.39.0
3
+ Version: 0.40.1
4
4
  Summary: SDK to customize event-driven actions in your Canvas instance
5
5
  Author-email: Canvas Team <engineering@canvasmedical.com>
6
6
  License-Expression: MIT
@@ -1,4 +1,4 @@
1
- settings.py,sha256=c4ocUJiL5omYwMfQqQIJBv4Kfk8PSGX6c30WARMnyUo,4871
1
+ settings.py,sha256=_2rO80LQaKinDMt6It_SQUgGUcgBXzlc6Yl5-QlbKCw,5302
2
2
  canvas_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  canvas_cli/main.py,sha256=L6JQkt1yxy30cA3-M9v7JD8WMW4i0M5GPr9kZetAito,2728
4
4
  canvas_cli/apps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -105,7 +105,7 @@ canvas_generated/services/plugin_runner_pb2.pyi,sha256=1w-Pa4k7HtlmQAr7B6sgV64zd
105
105
  canvas_generated/services/plugin_runner_pb2_grpc.py,sha256=EzJJVkP_AZ3dwBA7OxUito0NSalRmjjg8q9TZ_P18ww,4549
106
106
  canvas_sdk/__init__.py,sha256=3GEB9s-a9icf8c4JBEXbrsKYbagWNyn1TtJ50n1F3Z0,170
107
107
  canvas_sdk/base.py,sha256=vHSb9aKhvKFkQ0ROpIMqQWfPxQG1B7iBk2kGcFWoKEU,4125
108
- canvas_sdk/caching/__init__.py,sha256=9RJk4TUiLtTeW4AxQNqMf4Td9SfCeIxdjPH8kDkrTUk,26
108
+ canvas_sdk/caching/__init__.py,sha256=YYXr5tEQlnwMgTXJbOG963tKSPiUOM4mUkX8wuiqp7U,17
109
109
  canvas_sdk/caching/base.py,sha256=D4sT8vI0Q-o9dTq-GS099Rvyq0bNlrxCpLZ4LByc6TA,4521
110
110
  canvas_sdk/caching/client.py,sha256=ycOErRxlUaLwqN35gvan69xR42tNIKlNlSAlmzllIdk,773
111
111
  canvas_sdk/caching/exceptions.py,sha256=WIQIveMzmGm9WGhZqBhsGbbcydpS0AzMpkhzUmTa3WI,506
@@ -209,6 +209,7 @@ canvas_sdk/questionnaires/utils.py,sha256=hEB9cd8LmLolrQVzxEATt4r9n2nk7wR01vjquM
209
209
  canvas_sdk/templates/__init__.py,sha256=LtUmLDsGSTq249T6sA7PUzkl2OfCAyvtIOGPNHr6wTo,83
210
210
  canvas_sdk/templates/utils.py,sha256=_AIYcGQD3ePWzQpH7ZirkV_ATtIHlzf-T_03mHoeIWI,1460
211
211
  canvas_sdk/utils/__init__.py,sha256=PADveJMf-BtOapK5Cczy-nOuZzVh-HT2H6sfJW_SK9U,198
212
+ canvas_sdk/utils/db.py,sha256=wOZORBfyBVxQkay5vyEtQ4i0KVCfASFGREmecHMR8DE,409
212
213
  canvas_sdk/utils/http.py,sha256=n0Q9ndlwYi-fco7Hgu6JpjTmJnQFlkGkM5shT_ZRTvI,9043
213
214
  canvas_sdk/utils/metrics.py,sha256=ojCbXgjLSy1pEavHgRs8j4OVNdAUMa1nLqZdkA0uCQQ,5987
214
215
  canvas_sdk/utils/plugins.py,sha256=xxJUeVJBzfQWhlD1kO7HlFWxDAl01kkvbsf07Z08dOM,1551
@@ -276,14 +277,14 @@ plugin_runner/exceptions.py,sha256=YnRZiQVzbU3HrVlmEXLje_np99009YnhTRVHHyBCtqc,4
276
277
  plugin_runner/installation.py,sha256=LLjtnzPk-w4go3UbXnBItJTKz1ajR_5kGQbFXTaWTFU,7693
277
278
  plugin_runner/load_all_plugins.py,sha256=4T2gW2YljhIx4xfwf1c0F_8oIbE1ubsLj0ShkHRtlVY,5847
278
279
  plugin_runner/plugin_runner.py,sha256=Z7ySPJSY4AMGRR0PtdXA_I3z8rxlDpjssuMspHIc79U,21655
279
- plugin_runner/sandbox.py,sha256=nkYwIhuyCLkvpf7tyL9B-5sJMNREwSDmqHhIjz75JZw,28340
280
+ plugin_runner/sandbox.py,sha256=vxfPKkz3A31g_QAD6eqa-CFt7z6xTp4FHu6RBrxoNz8,28589
280
281
  protobufs/canvas_generated/messages/effects.proto,sha256=sFUsIAa6nhEhJbBlLTIf7gxzvFCC7zP-yD1aZevObvY,8583
281
282
  protobufs/canvas_generated/messages/events.proto,sha256=DSxbxKp7BTZpI4M14Sm7-XpHdUnN3bC3RapRqZbxgiQ,48751
282
283
  protobufs/canvas_generated/messages/plugins.proto,sha256=oNainUPWFYQjgCX7bJEPI9_VnHC5VZduzOqgR4Q7dNM,109
283
284
  protobufs/canvas_generated/services/plugin_runner.proto,sha256=doadBKn5k4xAtOgR-q_pEvW4yzxpUaHNOowMG6CL5GY,304
284
285
  pubsub/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
285
286
  pubsub/pubsub.py,sha256=PHIvJ5SD3M-jQSYeGGSj1FuG6CvP6BQffAoGax9Uudk,1423
286
- canvas-0.39.0.dist-info/METADATA,sha256=PWj6_zS-NVS9kAsf720ZBDLq8nYvgeffTcThqlUozEo,4447
287
- canvas-0.39.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
288
- canvas-0.39.0.dist-info/entry_points.txt,sha256=0Vs_9GmTVUNniH6eDBlRPgofmADMV4BES6Ao26M4AbM,47
289
- canvas-0.39.0.dist-info/RECORD,,
287
+ canvas-0.40.1.dist-info/METADATA,sha256=qjZMdUv-9EUOYW1OKk2CSV6pf-S7c7GQ1ay7HW-cjI4,4447
288
+ canvas-0.40.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
289
+ canvas-0.40.1.dist-info/entry_points.txt,sha256=0Vs_9GmTVUNniH6eDBlRPgofmADMV4BES6Ao26M4AbM,47
290
+ canvas-0.40.1.dist-info/RECORD,,
@@ -1 +1 @@
1
- __al__ = __exports__ = ()
1
+ __exports__ = ()
canvas_sdk/utils/db.py ADDED
@@ -0,0 +1,14 @@
1
+ from django.db import close_old_connections, reset_queries
2
+
3
+
4
+ def thread_cleanup() -> None:
5
+ """
6
+ Call this method to do cleanup work at thread exit. For users doing
7
+ advanced work with threads there is a need to do cleanup after each thread
8
+ runs so that e.g. the database pool does not become exhausted.
9
+ """
10
+ reset_queries()
11
+ close_old_connections()
12
+
13
+
14
+ __exports__ = ("thread_cleanup",)
plugin_runner/sandbox.py CHANGED
@@ -199,6 +199,7 @@ STANDARD_LIBRARY_MODULES = {
199
199
  },
200
200
  "typing": {
201
201
  "Any",
202
+ "cast",
202
203
  "Dict",
203
204
  "Final",
204
205
  "Iterable",
@@ -867,7 +868,13 @@ class Sandbox:
867
868
  # evaluate the module in the sandbox if needed
868
869
  self._evaluate_module(name)
869
870
 
870
- return __import__(name, globals, locals, fromlist, level)
871
+ imported_module = __import__(name, globals, locals, fromlist, level)
872
+
873
+ # If the module is part of the plugin, mark it as a plugin module
874
+ if self._same_module(name):
875
+ imported_module.__is_plugin__ = True # type: ignore[attr-defined]
876
+
877
+ return imported_module
871
878
 
872
879
  def execute(self) -> dict:
873
880
  """Execute the given code in a restricted sandbox."""
settings.py CHANGED
@@ -1,3 +1,4 @@
1
+ import logging
1
2
  import os
2
3
  import sys
3
4
  from pathlib import Path
@@ -16,9 +17,20 @@ IS_PRODUCTION = ENV == "production"
16
17
  IS_PRODUCTION_CUSTOMER = env_to_bool("IS_PRODUCTION_CUSTOMER", IS_PRODUCTION)
17
18
  IS_TESTING = env_to_bool("IS_TESTING", "pytest" in sys.argv[0] or sys.argv[0] == "-c")
18
19
  IS_SCRIPT = env_to_bool("IS_SCRIPT", "plugin_runner.py" not in sys.argv[0])
20
+ PLUGIN_POOL_DEBUG = env_to_bool("PLUGIN_POOL_DEBUG")
19
21
  CUSTOMER_IDENTIFIER = os.getenv("CUSTOMER_IDENTIFIER", "local")
20
22
  APP_NAME = os.getenv("APP_NAME")
21
23
 
24
+ if PLUGIN_POOL_DEBUG:
25
+ handler = logging.StreamHandler()
26
+ handler.setLevel(logging.DEBUG)
27
+ formatter = logging.Formatter("[%(process)d:%(thread)d] %(name)s - %(levelname)s - %(message)s")
28
+ handler.setFormatter(formatter)
29
+
30
+ pool_logger = logging.getLogger("psycopg.pool")
31
+ pool_logger.setLevel(logging.DEBUG)
32
+ pool_logger.addHandler(handler)
33
+
22
34
  INTEGRATION_TEST_URL = os.getenv("INTEGRATION_TEST_URL")
23
35
  INTEGRATION_TEST_CLIENT_ID = os.getenv("INTEGRATION_TEST_CLIENT_ID")
24
36
  INTEGRATION_TEST_CLIENT_SECRET = os.getenv("INTEGRATION_TEST_CLIENT_SECRET")