clerk-sdk 0.1.0__py3-none-any.whl → 0.1.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.
- clerk/decorator/models.py +15 -4
- clerk/decorator/task_decorator.py +35 -15
- {clerk_sdk-0.1.0.dist-info → clerk_sdk-0.1.1.dist-info}/METADATA +1 -3
- {clerk_sdk-0.1.0.dist-info → clerk_sdk-0.1.1.dist-info}/RECORD +7 -7
- {clerk_sdk-0.1.0.dist-info → clerk_sdk-0.1.1.dist-info}/WHEEL +1 -1
- {clerk_sdk-0.1.0.dist-info → clerk_sdk-0.1.1.dist-info}/licenses/LICENSE +0 -0
- {clerk_sdk-0.1.0.dist-info → clerk_sdk-0.1.1.dist-info}/top_level.txt +0 -0
clerk/decorator/models.py
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
from typing import Dict
|
|
1
|
+
from typing import Dict, List, Optional
|
|
2
2
|
from pydantic import BaseModel
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
class File(BaseModel):
|
|
6
|
+
name: str
|
|
7
|
+
url: str
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Document(BaseModel):
|
|
11
|
+
id: str
|
|
12
|
+
message_subject: Optional[str] = None
|
|
13
|
+
message_content: Optional[str] = None
|
|
14
|
+
files: List[File] = []
|
|
15
|
+
|
|
16
|
+
|
|
5
17
|
class ClerkCodePayload(BaseModel):
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
data: Dict
|
|
18
|
+
document: Document
|
|
19
|
+
structured_data: Dict
|
|
@@ -1,23 +1,43 @@
|
|
|
1
|
-
import
|
|
2
|
-
from typing import
|
|
3
|
-
from prefect import flow
|
|
1
|
+
import pickle
|
|
2
|
+
from typing import Callable
|
|
4
3
|
from functools import wraps
|
|
5
|
-
from prefect.states import Completed
|
|
6
|
-
from pydantic import BaseModel
|
|
7
4
|
from .models import ClerkCodePayload
|
|
8
5
|
|
|
6
|
+
input_pkl: str = "/app/data/input/input.pkl"
|
|
7
|
+
output_pkl: str = "/app/data/output/output.pkl"
|
|
8
|
+
|
|
9
9
|
|
|
10
10
|
def clerk_code():
|
|
11
|
-
def
|
|
11
|
+
def decorator(func: Callable[[ClerkCodePayload], ClerkCodePayload]):
|
|
12
12
|
@wraps(func)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
def wrapper():
|
|
14
|
+
# Step 1: Load and parse input
|
|
15
|
+
try:
|
|
16
|
+
with open(input_pkl, "rb") as f:
|
|
17
|
+
raw_data = pickle.load(f)
|
|
18
|
+
parsed = (
|
|
19
|
+
ClerkCodePayload.model_validate(raw_data)
|
|
20
|
+
if not isinstance(raw_data, ClerkCodePayload)
|
|
21
|
+
else raw_data
|
|
22
|
+
)
|
|
23
|
+
except Exception as e:
|
|
24
|
+
raise RuntimeError(f"Failed to load and parse input pickle: {e}") from e
|
|
25
|
+
|
|
26
|
+
# Step 2: Call the function and validate output
|
|
27
|
+
try:
|
|
28
|
+
output = func(parsed)
|
|
29
|
+
if not isinstance(output, ClerkCodePayload):
|
|
30
|
+
raise TypeError("Function must return a ClerkCodePayload instance.")
|
|
31
|
+
except Exception as e:
|
|
32
|
+
output = e # Save exception to output file for later debugging
|
|
33
|
+
|
|
34
|
+
# Step 3: Write output or exception to pickle
|
|
35
|
+
try:
|
|
36
|
+
with open(output_pkl, "wb") as f:
|
|
37
|
+
pickle.dump(output, f)
|
|
38
|
+
except Exception as e:
|
|
39
|
+
raise RuntimeError(f"Failed to write output pickle: {e}") from e
|
|
20
40
|
|
|
21
|
-
return
|
|
41
|
+
return wrapper
|
|
22
42
|
|
|
23
|
-
return
|
|
43
|
+
return decorator
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: clerk-sdk
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1
|
|
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
|
|
@@ -11,7 +11,6 @@ Classifier: Operating System :: OS Independent
|
|
|
11
11
|
Requires-Python: >=3.10
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
|
-
Requires-Dist: prefect==3.4.1
|
|
15
14
|
Requires-Dist: pydantic>2.0.0
|
|
16
15
|
Requires-Dist: backoff>2.0.0
|
|
17
16
|
Dynamic: author
|
|
@@ -85,7 +84,6 @@ def process_document(payload):
|
|
|
85
84
|
|
|
86
85
|
- Python 3.10+
|
|
87
86
|
- Dependencies listed in `requirements.txt`:
|
|
88
|
-
- `prefect>=3.4.1`
|
|
89
87
|
- `pydantic>2.0.0`
|
|
90
88
|
- `backoff>2.0.0`
|
|
91
89
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
clerk/__init__.py,sha256=LWpbImG7352mUJYC1tRm_zsn5rnt4sFl5ldoq5f0dlo,26
|
|
2
2
|
clerk/client.py,sha256=UEbs5AhnBs6JWstLzT-TPHZ-yxyBwTFDLemv-yh25K4,3386
|
|
3
3
|
clerk/decorator/__init__.py,sha256=4VCGOFNq7pA7iJS410V_R9eWfjxP7mwxwa4thwaUTf8,39
|
|
4
|
-
clerk/decorator/models.py,sha256=
|
|
5
|
-
clerk/decorator/task_decorator.py,sha256=
|
|
4
|
+
clerk/decorator/models.py,sha256=FKs7oCq50hmvbzYWuscvqlL7boPYzMKv0Vg3tznmwao,361
|
|
5
|
+
clerk/decorator/task_decorator.py,sha256=nLKpPG4kRvNuviO5OLeBzHQppNG2RTHFclGOSARajdM,1536
|
|
6
6
|
clerk/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
7
|
clerk/models/document.py,sha256=Bbt3YSvGcOrJJjJBYjbDGXpZIaQAYdq_-uIr2urwy5s,525
|
|
8
8
|
clerk/models/document_statuses.py,sha256=ytTQhgACs2m22qz51_7Ti0IxzbVyl-fl7uF7CnDEyLA,279
|
|
9
9
|
clerk/models/file.py,sha256=7n6bV6ukRA-uh7MFxUx_TEMNpVAdNe5O0nKIeneCQhg,459
|
|
10
10
|
clerk/models/response_model.py,sha256=R62daUN1YVOwgnrh_epvFRsQcOwT7R4u97l73egvm-c,232
|
|
11
|
-
clerk_sdk-0.1.
|
|
12
|
-
clerk_sdk-0.1.
|
|
13
|
-
clerk_sdk-0.1.
|
|
14
|
-
clerk_sdk-0.1.
|
|
15
|
-
clerk_sdk-0.1.
|
|
11
|
+
clerk_sdk-0.1.1.dist-info/licenses/LICENSE,sha256=GTVQl3vH6ht70wJXKC0yMT8CmXKHxv_YyO_utAgm7EA,1065
|
|
12
|
+
clerk_sdk-0.1.1.dist-info/METADATA,sha256=LYguUv0vCO8dpZOkwO5TSuD6VpQeTzq4DcgbRMIasmI,2634
|
|
13
|
+
clerk_sdk-0.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
14
|
+
clerk_sdk-0.1.1.dist-info/top_level.txt,sha256=99eQiU6d05_-f41tmSFanfI_SIJeAdh7u9m3LNSfcv4,6
|
|
15
|
+
clerk_sdk-0.1.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|