benchling-sdk 1.10.0a7__py3-none-any.whl → 1.10.0a9__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.
- benchling_sdk/apps/canvas/framework.py +3 -3
- benchling_sdk/apps/status/framework.py +23 -2
- {benchling_sdk-1.10.0a7.dist-info → benchling_sdk-1.10.0a9.dist-info}/METADATA +1 -1
- {benchling_sdk-1.10.0a7.dist-info → benchling_sdk-1.10.0a9.dist-info}/RECORD +6 -6
- {benchling_sdk-1.10.0a7.dist-info → benchling_sdk-1.10.0a9.dist-info}/LICENSE +0 -0
- {benchling_sdk-1.10.0a7.dist-info → benchling_sdk-1.10.0a9.dist-info}/WHEEL +0 -0
@@ -411,7 +411,7 @@ class CanvasBuilder:
|
|
411
411
|
enabled=value,
|
412
412
|
session_id=self._source_canvas.session_id,
|
413
413
|
blocks=self._source_canvas.blocks,
|
414
|
-
data=self.
|
414
|
+
data=self.data_to_json(),
|
415
415
|
)
|
416
416
|
|
417
417
|
def with_enabled(self, enabled: bool = True) -> CanvasBuilder:
|
@@ -436,7 +436,7 @@ class CanvasBuilder:
|
|
436
436
|
enabled=self._source_canvas.enabled,
|
437
437
|
session_id=self._source_canvas.session_id,
|
438
438
|
blocks=new_blocks,
|
439
|
-
data=self.
|
439
|
+
data=self.data_to_json(),
|
440
440
|
)
|
441
441
|
|
442
442
|
def with_data(self, new_data: Optional[JsonType]) -> CanvasBuilder:
|
@@ -468,7 +468,7 @@ class CanvasBuilder:
|
|
468
468
|
enabled=self._source_canvas.enabled,
|
469
469
|
session_id=session_id,
|
470
470
|
blocks=self._source_canvas.blocks,
|
471
|
-
data=self.
|
471
|
+
data=self.data_to_json(),
|
472
472
|
)
|
473
473
|
|
474
474
|
def inputs_to_dict(self) -> Dict[str, Union[str, List[str]]]:
|
@@ -53,7 +53,7 @@ class SessionContextErrorProcessor(ABC):
|
|
53
53
|
process_error() does not assume a context's session is active. If using the session with process_error(),
|
54
54
|
this should be checked.
|
55
55
|
|
56
|
-
For
|
56
|
+
For use with SessionClosingContextExitHandler or its subclasses.
|
57
57
|
"""
|
58
58
|
|
59
59
|
@classmethod
|
@@ -269,6 +269,7 @@ class SessionClosingContextExitHandler(SessionContextExitHandler):
|
|
269
269
|
|
270
270
|
On error: close the Session with Benchling with SessionStatusUpdate.FAILED.
|
271
271
|
If error_messages were specified, those will also be written to the Session when setting the status.
|
272
|
+
If the session has a Canvas attached and enable_attached_canvas_on_error is True, re-enable the AppCanvas.
|
272
273
|
|
273
274
|
As a best practice, error messages are not written to the session to avoid leaking
|
274
275
|
potentially sensitive information.
|
@@ -277,6 +278,7 @@ class SessionClosingContextExitHandler(SessionContextExitHandler):
|
|
277
278
|
_success_messages: Optional[Iterable[AppSessionMessageCreate]]
|
278
279
|
_error_messages: Optional[Iterable[AppSessionMessageCreate]]
|
279
280
|
_error_processors: List[Type[SessionContextErrorProcessor]]
|
281
|
+
_enable_attached_canvas_on_error: bool
|
280
282
|
|
281
283
|
def __init__(
|
282
284
|
self,
|
@@ -288,6 +290,7 @@ class SessionClosingContextExitHandler(SessionContextExitHandler):
|
|
288
290
|
AppUserFacingErrorProcessor,
|
289
291
|
BenchlingBadRequestErrorProcessor,
|
290
292
|
],
|
293
|
+
enable_attached_canvas_on_error: bool = True,
|
291
294
|
):
|
292
295
|
"""
|
293
296
|
Init Session Closing Context Exit Handler.
|
@@ -298,6 +301,7 @@ class SessionClosingContextExitHandler(SessionContextExitHandler):
|
|
298
301
|
self._success_messages = success_messages
|
299
302
|
self._error_messages = error_messages
|
300
303
|
self._error_processors = error_processors
|
304
|
+
self._enable_attached_canvas_on_error = enable_attached_canvas_on_error
|
301
305
|
|
302
306
|
def on_success(self, context: SessionContextManager) -> bool:
|
303
307
|
"""
|
@@ -354,7 +358,9 @@ class SessionClosingContextExitHandler(SessionContextExitHandler):
|
|
354
358
|
# Pluggable specific error handling
|
355
359
|
if optional_error_processor:
|
356
360
|
sdk_logger.debug("Exiting session context with error, matched handler for %s", str(exc_type))
|
357
|
-
|
361
|
+
result = optional_error_processor.process_error(context, exc_type, exc_value, exc_traceback)
|
362
|
+
self._check_and_enable_canvas(context)
|
363
|
+
return result
|
358
364
|
# Fallback to general error handling
|
359
365
|
sdk_logger.debug(
|
360
366
|
"Exiting session context with error, automatically closing session ID %s as %s",
|
@@ -368,10 +374,17 @@ class SessionClosingContextExitHandler(SessionContextExitHandler):
|
|
368
374
|
context.close_session(AppSessionUpdateStatus.FAILED, messages=message_creates)
|
369
375
|
else:
|
370
376
|
context.close_session(AppSessionUpdateStatus.FAILED)
|
377
|
+
self._check_and_enable_canvas(context)
|
371
378
|
else:
|
372
379
|
sdk_logger.debug("Exiting session context, no active session present")
|
373
380
|
return False
|
374
381
|
|
382
|
+
def _check_and_enable_canvas(self, context: SessionContextManager) -> None:
|
383
|
+
canvas_id = context.attached_canvas_id()
|
384
|
+
if self._enable_attached_canvas_on_error and canvas_id:
|
385
|
+
context.app.benchling.apps.update_canvas(canvas_id, AppCanvasUpdate(enabled=True))
|
386
|
+
sdk_logger.debug("Re-enabled canvas with ID %s", context.attached_canvas_id())
|
387
|
+
|
375
388
|
def _error_processor_type(
|
376
389
|
self,
|
377
390
|
exc_type: Type[BaseException],
|
@@ -598,6 +611,14 @@ class SessionContextManager(AbstractContextManager):
|
|
598
611
|
"""
|
599
612
|
return self._session is not None
|
600
613
|
|
614
|
+
def attached_canvas_id(self) -> Optional[str]:
|
615
|
+
"""
|
616
|
+
Attached Canvas Id.
|
617
|
+
|
618
|
+
Returns a canvas_id associated with the active session, if one has been attached via `attach_canvas`.
|
619
|
+
"""
|
620
|
+
return self._attached_canvas_id
|
621
|
+
|
601
622
|
def attach_canvas(self, canvas_id: str) -> None:
|
602
623
|
"""
|
603
624
|
Attach Canvas.
|
@@ -3,7 +3,7 @@ benchling_sdk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
benchling_sdk/apps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
4
|
benchling_sdk/apps/canvas/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
5
|
benchling_sdk/apps/canvas/errors.py,sha256=5YTZOhSV-O0WqURjB1a676BIO429drCKfz5aQjsezms,358
|
6
|
-
benchling_sdk/apps/canvas/framework.py,sha256=
|
6
|
+
benchling_sdk/apps/canvas/framework.py,sha256=CeOmiEg_ufWOwDLgSiMXlhCNXuHhRQzBnuoxhF-oAZ8,24366
|
7
7
|
benchling_sdk/apps/canvas/types.py,sha256=tmuU0kpzd1pXqxs3X6x5kjWpCZJrJMb6hnfN1CbtFG4,3613
|
8
8
|
benchling_sdk/apps/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
9
9
|
benchling_sdk/apps/config/cryptography_helpers.py,sha256=VCzgQURLAitYjcjdwFzMPSKZ7MOD6ghxFdbPGA_6RbY,1778
|
@@ -19,7 +19,7 @@ benchling_sdk/apps/helpers/manifest_helpers.py,sha256=yidiKA5mwWdAFR1ZSUu40QoG0U
|
|
19
19
|
benchling_sdk/apps/helpers/webhook_helpers.py,sha256=T-ZJLWb37nzSKMQFAQQ8FJU7al_QFBgNRhTfWDfCfYU,7077
|
20
20
|
benchling_sdk/apps/status/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
21
21
|
benchling_sdk/apps/status/errors.py,sha256=E9PugMd0YwZQWweTztIZyqycECBuVvH6PcLfij0Cb3k,2279
|
22
|
-
benchling_sdk/apps/status/framework.py,sha256=
|
22
|
+
benchling_sdk/apps/status/framework.py,sha256=go0pyU5qgMCvsrTDXWk3V9FZwbaRHgfhEWtjIZ-JLEE,27418
|
23
23
|
benchling_sdk/apps/status/helpers.py,sha256=o8jdgdxUYdGh2j0Gb3AYoeXI9Bu-ubyIkgWBuCGLKgE,705
|
24
24
|
benchling_sdk/apps/status/types.py,sha256=vE7-_7ns3mvPRJoVv-GQxc3389dIIH4mcG0VDNWpVhQ,746
|
25
25
|
benchling_sdk/apps/types.py,sha256=TBTfAB3IOoZjZqzTOK25kN3b6RTU9Z7tOMdBbq6u8lA,110
|
@@ -115,7 +115,7 @@ benchling_sdk/services/v2/v2_alpha_service.py,sha256=vNfYK0Dheml9ozR_0tzTlA3blPD
|
|
115
115
|
benchling_sdk/services/v2/v2_beta_service.py,sha256=7v9ngWH_XTinkVC7bIxxbaA1UeFQqkzR4ANGtQQN-fA,11521
|
116
116
|
benchling_sdk/services/v2/v2_stable_service.py,sha256=YIc-_0p6x1NQqj7awnWgCTHxbxYO7ZOolePZyW90whc,35246
|
117
117
|
benchling_sdk/services/v2_service.py,sha256=3eoIjYEmGLPdWCpBN0pl7q7_HNWCsUvfvTn3Hcz0wSM,2860
|
118
|
-
benchling_sdk-1.10.
|
119
|
-
benchling_sdk-1.10.
|
120
|
-
benchling_sdk-1.10.
|
121
|
-
benchling_sdk-1.10.
|
118
|
+
benchling_sdk-1.10.0a9.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
119
|
+
benchling_sdk-1.10.0a9.dist-info/METADATA,sha256=sXGs66Z5BBG6tO9A0HCSgc9saaXB7omsobqmehDm76s,2126
|
120
|
+
benchling_sdk-1.10.0a9.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
|
121
|
+
benchling_sdk-1.10.0a9.dist-info/RECORD,,
|
File without changes
|
File without changes
|