clerk-sdk 0.3.2__py3-none-any.whl → 0.3.3__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.
@@ -1,4 +1,3 @@
1
- import os
2
1
  import pickle
3
2
  import traceback
4
3
  from typing import Callable, Optional
@@ -17,6 +16,9 @@ def clerk_code():
17
16
  def wrapper(payload: Optional[ClerkCodePayload] = None) -> ClerkCodePayload:
18
17
  # 1. Load payload from file if not provided
19
18
  use_pickle = False
19
+ output = None
20
+ error_occurred = False
21
+ error_info = None
20
22
  if payload is None:
21
23
  use_pickle = True
22
24
  try:
@@ -28,34 +30,53 @@ def clerk_code():
28
30
  else raw_data
29
31
  )
30
32
  except Exception as e:
31
- raise RuntimeError(
32
- f"Failed to load and parse input pickle: {e}"
33
- ) from e
33
+ error_occurred = True
34
+ error_info = ApplicationException(
35
+ type_=str(type(e)),
36
+ message=f"Failed to load and parse input pickle: {e}",
37
+ traceback=traceback.format_exc(),
38
+ )
34
39
 
35
40
  # 2. Execute function
36
- try:
37
- output = func(payload)
38
- if not isinstance(output, ClerkCodePayload):
39
- raise TypeError("Function must return a ClerkCodePayload instance.")
40
- except Exception as e:
41
- # parse no standard errors into the standard Application Error
42
- output = ApplicationException(
43
- type_=str(type(e)), message=str(e), traceback=traceback.format_exc()
44
- )
41
+ if not error_occurred:
42
+ try:
43
+ output = func(payload)
44
+ if not isinstance(output, ClerkCodePayload):
45
+ raise TypeError(
46
+ "Function must return a ClerkCodePayload instance."
47
+ )
48
+ except Exception as e:
49
+ error_occurred = True
50
+ error_info = ApplicationException(
51
+ type_=str(type(e)),
52
+ message=str(e),
53
+ traceback=traceback.format_exc(),
54
+ )
45
55
 
46
56
  # 3. write to output.pkl
47
57
  try:
48
58
  if use_pickle:
49
59
  with open(output_pkl, "wb") as f:
50
- if isinstance(output, Exception):
60
+ if error_occurred:
61
+ pickle.dump(error_info, f)
62
+ elif isinstance(output, Exception):
51
63
  pickle.dump(output, f)
52
64
  else:
53
65
  pickle.dump(output.model_dump(mode="json"), f)
54
-
55
66
  except Exception as e:
56
- output = RuntimeError(f"Failed to write output pickle: {str(e)}")
57
- with open(output_pkl, "wb") as f:
58
- pickle.dump(output, f)
67
+ # If writing output.pkl fails, try to write a minimal error
68
+ try:
69
+ with open(output_pkl, "wb") as f:
70
+ pickle.dump(
71
+ ApplicationException(
72
+ type_=str(type(e)),
73
+ message=f"Failed to write output pickle: {str(e)}",
74
+ traceback=traceback.format_exc(),
75
+ ),
76
+ f,
77
+ )
78
+ except Exception:
79
+ pass # Last resort: do nothing if even this fails
59
80
 
60
81
  # 4. Raise if error or return result
61
82
  if isinstance(output, Exception):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clerk-sdk
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary: Library for interacting with Clerk
5
5
  Home-page: https://github.com/F-ONE-Group/clerk_pypi
6
6
  Author: F-ONE Group
@@ -3,7 +3,7 @@ clerk/base.py,sha256=Ayb2zCQr8fqKZM_Qh3nVxVJOQkkYt-eD5VtpPXd1TLs,2669
3
3
  clerk/client.py,sha256=6nWWWjGB7a6FNUWsZRM-IoBb_mshRi6g5KX8meMiJ2E,576
4
4
  clerk/decorator/__init__.py,sha256=4VCGOFNq7pA7iJS410V_R9eWfjxP7mwxwa4thwaUTf8,39
5
5
  clerk/decorator/models.py,sha256=JWFOJuUh3F40iOL0aoNgUC9GRHU3Fcq3GOjSXA7Gwng,394
6
- clerk/decorator/task_decorator.py,sha256=ZHBNaG5zlRZ6_OaVFgVhBaowCc0Q8YgdjUPSnmOL7r4,2454
6
+ clerk/decorator/task_decorator.py,sha256=6frvOIHTtDjP2SpBMx-KLZgd1EdXHahzPm9DLSxJfjQ,3390
7
7
  clerk/exceptions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  clerk/exceptions/exceptions.py,sha256=aIrmID62HoQo0pLErfX9NR2nopTyf53BpOu4gtqAy-A,1201
9
9
  clerk/exceptions/remote_device.py,sha256=R0Vfmk8ejibEFeV29A8Vqst2YA6yxdqEX9lP5wWubgM,134
@@ -46,8 +46,8 @@ clerk/models/ui_operator.py,sha256=mKTJUFZgv7PeEt5oys28HVZxHOJsofmRQOcRpqj0dbU,2
46
46
  clerk/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
47
47
  clerk/utils/logger.py,sha256=vHbp-lUK3W3c5fhyPsp05p9LGyDHj95v8XM_XQ_FlLc,3691
48
48
  clerk/utils/save_artifact.py,sha256=94aYkYNVGcSUaSWZmdjiY6Oc-3yCKb2XWCZ56IAXQqk,1158
49
- clerk_sdk-0.3.2.dist-info/licenses/LICENSE,sha256=GTVQl3vH6ht70wJXKC0yMT8CmXKHxv_YyO_utAgm7EA,1065
50
- clerk_sdk-0.3.2.dist-info/METADATA,sha256=BnwmGLHnRc6KnJ-YHOkCSLurPG6DjGvrRJ1wUTOg_JU,3508
51
- clerk_sdk-0.3.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
52
- clerk_sdk-0.3.2.dist-info/top_level.txt,sha256=99eQiU6d05_-f41tmSFanfI_SIJeAdh7u9m3LNSfcv4,6
53
- clerk_sdk-0.3.2.dist-info/RECORD,,
49
+ clerk_sdk-0.3.3.dist-info/licenses/LICENSE,sha256=GTVQl3vH6ht70wJXKC0yMT8CmXKHxv_YyO_utAgm7EA,1065
50
+ clerk_sdk-0.3.3.dist-info/METADATA,sha256=nGsbiRaB7DVlftGElyUsH24-U_KRZKlj7GX0X6dghTw,3508
51
+ clerk_sdk-0.3.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
52
+ clerk_sdk-0.3.3.dist-info/top_level.txt,sha256=99eQiU6d05_-f41tmSFanfI_SIJeAdh7u9m3LNSfcv4,6
53
+ clerk_sdk-0.3.3.dist-info/RECORD,,