clerk-sdk 0.1.0__tar.gz → 0.1.2__tar.gz

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.
Files changed (26) hide show
  1. {clerk_sdk-0.1.0/clerk_sdk.egg-info → clerk_sdk-0.1.2}/PKG-INFO +28 -9
  2. {clerk_sdk-0.1.0 → clerk_sdk-0.1.2}/README.md +27 -7
  3. clerk_sdk-0.1.2/clerk/decorator/models.py +19 -0
  4. clerk_sdk-0.1.2/clerk/decorator/task_decorator.py +51 -0
  5. {clerk_sdk-0.1.0 → clerk_sdk-0.1.2/clerk_sdk.egg-info}/PKG-INFO +28 -9
  6. {clerk_sdk-0.1.0 → clerk_sdk-0.1.2}/clerk_sdk.egg-info/requires.txt +0 -1
  7. clerk_sdk-0.1.2/requirements.txt +2 -0
  8. {clerk_sdk-0.1.0 → clerk_sdk-0.1.2}/setup.py +1 -1
  9. clerk_sdk-0.1.0/clerk/decorator/models.py +0 -8
  10. clerk_sdk-0.1.0/clerk/decorator/task_decorator.py +0 -23
  11. clerk_sdk-0.1.0/requirements.txt +0 -3
  12. {clerk_sdk-0.1.0 → clerk_sdk-0.1.2}/LICENSE +0 -0
  13. {clerk_sdk-0.1.0 → clerk_sdk-0.1.2}/MANIFEST.in +0 -0
  14. {clerk_sdk-0.1.0 → clerk_sdk-0.1.2}/clerk/__init__.py +0 -0
  15. {clerk_sdk-0.1.0 → clerk_sdk-0.1.2}/clerk/client.py +0 -0
  16. {clerk_sdk-0.1.0 → clerk_sdk-0.1.2}/clerk/decorator/__init__.py +0 -0
  17. {clerk_sdk-0.1.0 → clerk_sdk-0.1.2}/clerk/models/__init__.py +0 -0
  18. {clerk_sdk-0.1.0 → clerk_sdk-0.1.2}/clerk/models/document.py +0 -0
  19. {clerk_sdk-0.1.0 → clerk_sdk-0.1.2}/clerk/models/document_statuses.py +0 -0
  20. {clerk_sdk-0.1.0 → clerk_sdk-0.1.2}/clerk/models/file.py +0 -0
  21. {clerk_sdk-0.1.0 → clerk_sdk-0.1.2}/clerk/models/response_model.py +0 -0
  22. {clerk_sdk-0.1.0 → clerk_sdk-0.1.2}/clerk_sdk.egg-info/SOURCES.txt +0 -0
  23. {clerk_sdk-0.1.0 → clerk_sdk-0.1.2}/clerk_sdk.egg-info/dependency_links.txt +0 -0
  24. {clerk_sdk-0.1.0 → clerk_sdk-0.1.2}/clerk_sdk.egg-info/top_level.txt +0 -0
  25. {clerk_sdk-0.1.0 → clerk_sdk-0.1.2}/pyproject.toml +0 -0
  26. {clerk_sdk-0.1.0 → clerk_sdk-0.1.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clerk-sdk
3
- Version: 0.1.0
3
+ Version: 0.1.2
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
@@ -27,14 +26,14 @@ Dynamic: summary
27
26
 
28
27
  # CLERK
29
28
 
30
- `clerk-sdk` is a Python library designed to simplify interactions with the Clerk API. It provides a robust and user-friendly interface for managing documents, handling API requests, and integrating structured data models into your workflows. With built-in support for Prefect task flows and retry mechanisms, `clerk-sdk` is ideal for developers looking to streamline their integration with Clerk.
29
+ `clerk-sdk` is a Python library designed to simplify interactions with the Clerk API. It provides a robust and user-friendly interface for managing documents, handling API requests, and integrating structured data models into your workflows. `clerk-sdk` is ideal for developers looking to streamline their integration with Clerk.
31
30
 
32
31
  ## Features
33
32
 
34
33
  - **Document Management**: Retrieve and manage documents and their associated files.
35
34
  - **API Request Handling**: Simplified GET and POST requests with automatic retries and error handling.
36
35
  - **Data Models**: Predefined Pydantic models for structured data validation and serialization.
37
- - **Task Flow Integration**: Prefect-based decorators for creating and managing task flows.
36
+ - **Task Flow Integration**: Decorator for creating and managing task flows.
38
37
  - **Extensibility**: Easily extend and customize the library to fit your specific use case.
39
38
 
40
39
  ## Installation
@@ -70,22 +69,42 @@ for file in files:
70
69
  print(file.name)
71
70
  ```
72
71
 
73
- ### Use the Prefect Task Decorator
72
+ ### Use the Task Decorator
73
+
74
+ #### PROD
74
75
 
75
76
  ```python
76
77
  from clerk.decorator import clerk_code
78
+ from clerk.decorator.models import ClerkCodePayload
77
79
 
78
80
  @clerk_code()
79
- def process_document(payload):
80
- # Your processing logic here
81
- return {"status": "processed"}
81
+ def main(payload: ClerkCodePayload) -> ClerkCodePayload:
82
+ payload.structured_data["status"] = "ok"
83
+ return payload
84
+
85
+ main()
82
86
  ```
83
87
 
88
+ #### TEST
89
+
90
+ ```python
91
+ from clerk.decorator.models import ClerkCodePayload, Document
92
+
93
+ def test_main():
94
+ test_payload = ClerkCodePayload(
95
+ document=Document(id="doc-123", message_subject="Hello"),
96
+ structured_data={}
97
+ )
98
+
99
+ result = main(test_payload) # ✅ Just pass it!
100
+ assert result.structured_data["status"] == "ok"
101
+ ```
102
+
103
+
84
104
  ## Requirements
85
105
 
86
106
  - Python 3.10+
87
107
  - Dependencies listed in `requirements.txt`:
88
- - `prefect>=3.4.1`
89
108
  - `pydantic>2.0.0`
90
109
  - `backoff>2.0.0`
91
110
 
@@ -1,13 +1,13 @@
1
1
  # CLERK
2
2
 
3
- `clerk-sdk` is a Python library designed to simplify interactions with the Clerk API. It provides a robust and user-friendly interface for managing documents, handling API requests, and integrating structured data models into your workflows. With built-in support for Prefect task flows and retry mechanisms, `clerk-sdk` is ideal for developers looking to streamline their integration with Clerk.
3
+ `clerk-sdk` is a Python library designed to simplify interactions with the Clerk API. It provides a robust and user-friendly interface for managing documents, handling API requests, and integrating structured data models into your workflows. `clerk-sdk` is ideal for developers looking to streamline their integration with Clerk.
4
4
 
5
5
  ## Features
6
6
 
7
7
  - **Document Management**: Retrieve and manage documents and their associated files.
8
8
  - **API Request Handling**: Simplified GET and POST requests with automatic retries and error handling.
9
9
  - **Data Models**: Predefined Pydantic models for structured data validation and serialization.
10
- - **Task Flow Integration**: Prefect-based decorators for creating and managing task flows.
10
+ - **Task Flow Integration**: Decorator for creating and managing task flows.
11
11
  - **Extensibility**: Easily extend and customize the library to fit your specific use case.
12
12
 
13
13
  ## Installation
@@ -43,22 +43,42 @@ for file in files:
43
43
  print(file.name)
44
44
  ```
45
45
 
46
- ### Use the Prefect Task Decorator
46
+ ### Use the Task Decorator
47
+
48
+ #### PROD
47
49
 
48
50
  ```python
49
51
  from clerk.decorator import clerk_code
52
+ from clerk.decorator.models import ClerkCodePayload
50
53
 
51
54
  @clerk_code()
52
- def process_document(payload):
53
- # Your processing logic here
54
- return {"status": "processed"}
55
+ def main(payload: ClerkCodePayload) -> ClerkCodePayload:
56
+ payload.structured_data["status"] = "ok"
57
+ return payload
58
+
59
+ main()
55
60
  ```
56
61
 
62
+ #### TEST
63
+
64
+ ```python
65
+ from clerk.decorator.models import ClerkCodePayload, Document
66
+
67
+ def test_main():
68
+ test_payload = ClerkCodePayload(
69
+ document=Document(id="doc-123", message_subject="Hello"),
70
+ structured_data={}
71
+ )
72
+
73
+ result = main(test_payload) # ✅ Just pass it!
74
+ assert result.structured_data["status"] == "ok"
75
+ ```
76
+
77
+
57
78
  ## Requirements
58
79
 
59
80
  - Python 3.10+
60
81
  - Dependencies listed in `requirements.txt`:
61
- - `prefect>=3.4.1`
62
82
  - `pydantic>2.0.0`
63
83
  - `backoff>2.0.0`
64
84
 
@@ -0,0 +1,19 @@
1
+ from typing import Dict, List, Optional
2
+ from pydantic import BaseModel
3
+
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
+
17
+ class ClerkCodePayload(BaseModel):
18
+ document: Document
19
+ structured_data: Dict
@@ -0,0 +1,51 @@
1
+ import pickle
2
+ from typing import Callable, Optional
3
+ from functools import wraps
4
+ from .models import ClerkCodePayload
5
+
6
+ input_pkl: str = "/app/data/input/input.pkl"
7
+ output_pkl: str = "/app/data/output/output.pkl"
8
+
9
+
10
+ def clerk_code():
11
+ def decorator(func: Callable[[ClerkCodePayload], ClerkCodePayload]):
12
+ @wraps(func)
13
+ def wrapper(payload: Optional[ClerkCodePayload] = None) -> ClerkCodePayload:
14
+ # 1. Load payload from file if not provided
15
+ if payload is None:
16
+ try:
17
+ with open(input_pkl, "rb") as f:
18
+ raw_data = pickle.load(f)
19
+ payload = (
20
+ ClerkCodePayload.model_validate(raw_data)
21
+ if not isinstance(raw_data, ClerkCodePayload)
22
+ else raw_data
23
+ )
24
+ except Exception as e:
25
+ raise RuntimeError(
26
+ f"Failed to load and parse input pickle: {e}"
27
+ ) from e
28
+
29
+ # 2. Execute function
30
+ try:
31
+ output = func(payload)
32
+ if not isinstance(output, ClerkCodePayload):
33
+ raise TypeError("Function must return a ClerkCodePayload instance.")
34
+ except Exception as e:
35
+ output = e
36
+
37
+ # 3. Always write to output.pkl
38
+ try:
39
+ with open(output_pkl, "wb") as f:
40
+ pickle.dump(output, f)
41
+ except Exception as e:
42
+ raise RuntimeError(f"Failed to write output pickle: {e}") from e
43
+
44
+ # 4. Raise if error or return result
45
+ if isinstance(output, Exception):
46
+ raise output
47
+ return output
48
+
49
+ return wrapper
50
+
51
+ return decorator
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clerk-sdk
3
- Version: 0.1.0
3
+ Version: 0.1.2
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
@@ -27,14 +26,14 @@ Dynamic: summary
27
26
 
28
27
  # CLERK
29
28
 
30
- `clerk-sdk` is a Python library designed to simplify interactions with the Clerk API. It provides a robust and user-friendly interface for managing documents, handling API requests, and integrating structured data models into your workflows. With built-in support for Prefect task flows and retry mechanisms, `clerk-sdk` is ideal for developers looking to streamline their integration with Clerk.
29
+ `clerk-sdk` is a Python library designed to simplify interactions with the Clerk API. It provides a robust and user-friendly interface for managing documents, handling API requests, and integrating structured data models into your workflows. `clerk-sdk` is ideal for developers looking to streamline their integration with Clerk.
31
30
 
32
31
  ## Features
33
32
 
34
33
  - **Document Management**: Retrieve and manage documents and their associated files.
35
34
  - **API Request Handling**: Simplified GET and POST requests with automatic retries and error handling.
36
35
  - **Data Models**: Predefined Pydantic models for structured data validation and serialization.
37
- - **Task Flow Integration**: Prefect-based decorators for creating and managing task flows.
36
+ - **Task Flow Integration**: Decorator for creating and managing task flows.
38
37
  - **Extensibility**: Easily extend and customize the library to fit your specific use case.
39
38
 
40
39
  ## Installation
@@ -70,22 +69,42 @@ for file in files:
70
69
  print(file.name)
71
70
  ```
72
71
 
73
- ### Use the Prefect Task Decorator
72
+ ### Use the Task Decorator
73
+
74
+ #### PROD
74
75
 
75
76
  ```python
76
77
  from clerk.decorator import clerk_code
78
+ from clerk.decorator.models import ClerkCodePayload
77
79
 
78
80
  @clerk_code()
79
- def process_document(payload):
80
- # Your processing logic here
81
- return {"status": "processed"}
81
+ def main(payload: ClerkCodePayload) -> ClerkCodePayload:
82
+ payload.structured_data["status"] = "ok"
83
+ return payload
84
+
85
+ main()
82
86
  ```
83
87
 
88
+ #### TEST
89
+
90
+ ```python
91
+ from clerk.decorator.models import ClerkCodePayload, Document
92
+
93
+ def test_main():
94
+ test_payload = ClerkCodePayload(
95
+ document=Document(id="doc-123", message_subject="Hello"),
96
+ structured_data={}
97
+ )
98
+
99
+ result = main(test_payload) # ✅ Just pass it!
100
+ assert result.structured_data["status"] == "ok"
101
+ ```
102
+
103
+
84
104
  ## Requirements
85
105
 
86
106
  - Python 3.10+
87
107
  - Dependencies listed in `requirements.txt`:
88
- - `prefect>=3.4.1`
89
108
  - `pydantic>2.0.0`
90
109
  - `backoff>2.0.0`
91
110
 
@@ -1,3 +1,2 @@
1
- prefect==3.4.1
2
1
  pydantic>2.0.0
3
2
  backoff>2.0.0
@@ -0,0 +1,2 @@
1
+ pydantic>2.0.0
2
+ backoff>2.0.0
@@ -6,7 +6,7 @@ with open("./requirements.txt", "r") as f:
6
6
 
7
7
  setup(
8
8
  name="clerk-sdk",
9
- version="0.1.0",
9
+ version="0.1.2",
10
10
  description="Library for interacting with Clerk",
11
11
  long_description=open("README.md").read(),
12
12
  long_description_content_type="text/markdown",
@@ -1,8 +0,0 @@
1
- from typing import Dict
2
- from pydantic import BaseModel
3
-
4
-
5
- class ClerkCodePayload(BaseModel):
6
- document_id: str
7
- instance_id: str
8
- data: Dict
@@ -1,23 +0,0 @@
1
- import json
2
- from typing import Dict
3
- from prefect import flow
4
- from functools import wraps
5
- from prefect.states import Completed
6
- from pydantic import BaseModel
7
- from .models import ClerkCodePayload
8
-
9
-
10
- def clerk_code():
11
- def wrapper(func):
12
- @wraps(func)
13
- @flow(persist_result=False, log_prints=True, result_serializer="json")
14
- def wrapped_flow(payload: Dict):
15
- payload = ClerkCodePayload(**payload)
16
- result = func(payload)
17
- if isinstance(result, BaseModel):
18
- result = result.model_dump()
19
- return Completed(message=json.dumps(result), data=result)
20
-
21
- return wrapped_flow
22
-
23
- return wrapper
@@ -1,3 +0,0 @@
1
- prefect==3.4.1
2
- pydantic>2.0.0
3
- backoff>2.0.0
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes