clerk-sdk 0.1.1__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 (24) hide show
  1. {clerk_sdk-0.1.1/clerk_sdk.egg-info → clerk_sdk-0.1.2}/PKG-INFO +28 -7
  2. {clerk_sdk-0.1.1 → clerk_sdk-0.1.2}/README.md +27 -6
  3. clerk_sdk-0.1.2/clerk/decorator/task_decorator.py +51 -0
  4. {clerk_sdk-0.1.1 → clerk_sdk-0.1.2/clerk_sdk.egg-info}/PKG-INFO +28 -7
  5. {clerk_sdk-0.1.1 → clerk_sdk-0.1.2}/setup.py +1 -1
  6. clerk_sdk-0.1.1/clerk/decorator/task_decorator.py +0 -43
  7. {clerk_sdk-0.1.1 → clerk_sdk-0.1.2}/LICENSE +0 -0
  8. {clerk_sdk-0.1.1 → clerk_sdk-0.1.2}/MANIFEST.in +0 -0
  9. {clerk_sdk-0.1.1 → clerk_sdk-0.1.2}/clerk/__init__.py +0 -0
  10. {clerk_sdk-0.1.1 → clerk_sdk-0.1.2}/clerk/client.py +0 -0
  11. {clerk_sdk-0.1.1 → clerk_sdk-0.1.2}/clerk/decorator/__init__.py +0 -0
  12. {clerk_sdk-0.1.1 → clerk_sdk-0.1.2}/clerk/decorator/models.py +0 -0
  13. {clerk_sdk-0.1.1 → clerk_sdk-0.1.2}/clerk/models/__init__.py +0 -0
  14. {clerk_sdk-0.1.1 → clerk_sdk-0.1.2}/clerk/models/document.py +0 -0
  15. {clerk_sdk-0.1.1 → clerk_sdk-0.1.2}/clerk/models/document_statuses.py +0 -0
  16. {clerk_sdk-0.1.1 → clerk_sdk-0.1.2}/clerk/models/file.py +0 -0
  17. {clerk_sdk-0.1.1 → clerk_sdk-0.1.2}/clerk/models/response_model.py +0 -0
  18. {clerk_sdk-0.1.1 → clerk_sdk-0.1.2}/clerk_sdk.egg-info/SOURCES.txt +0 -0
  19. {clerk_sdk-0.1.1 → clerk_sdk-0.1.2}/clerk_sdk.egg-info/dependency_links.txt +0 -0
  20. {clerk_sdk-0.1.1 → clerk_sdk-0.1.2}/clerk_sdk.egg-info/requires.txt +0 -0
  21. {clerk_sdk-0.1.1 → clerk_sdk-0.1.2}/clerk_sdk.egg-info/top_level.txt +0 -0
  22. {clerk_sdk-0.1.1 → clerk_sdk-0.1.2}/pyproject.toml +0 -0
  23. {clerk_sdk-0.1.1 → clerk_sdk-0.1.2}/requirements.txt +0 -0
  24. {clerk_sdk-0.1.1 → 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.1
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
@@ -26,14 +26,14 @@ Dynamic: summary
26
26
 
27
27
  # CLERK
28
28
 
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. 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.
30
30
 
31
31
  ## Features
32
32
 
33
33
  - **Document Management**: Retrieve and manage documents and their associated files.
34
34
  - **API Request Handling**: Simplified GET and POST requests with automatic retries and error handling.
35
35
  - **Data Models**: Predefined Pydantic models for structured data validation and serialization.
36
- - **Task Flow Integration**: Prefect-based decorators for creating and managing task flows.
36
+ - **Task Flow Integration**: Decorator for creating and managing task flows.
37
37
  - **Extensibility**: Easily extend and customize the library to fit your specific use case.
38
38
 
39
39
  ## Installation
@@ -69,17 +69,38 @@ for file in files:
69
69
  print(file.name)
70
70
  ```
71
71
 
72
- ### Use the Prefect Task Decorator
72
+ ### Use the Task Decorator
73
+
74
+ #### PROD
73
75
 
74
76
  ```python
75
77
  from clerk.decorator import clerk_code
78
+ from clerk.decorator.models import ClerkCodePayload
76
79
 
77
80
  @clerk_code()
78
- def process_document(payload):
79
- # Your processing logic here
80
- return {"status": "processed"}
81
+ def main(payload: ClerkCodePayload) -> ClerkCodePayload:
82
+ payload.structured_data["status"] = "ok"
83
+ return payload
84
+
85
+ main()
81
86
  ```
82
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
+
83
104
  ## Requirements
84
105
 
85
106
  - Python 3.10+
@@ -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,17 +43,38 @@ 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+
@@ -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.1
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
@@ -26,14 +26,14 @@ Dynamic: summary
26
26
 
27
27
  # CLERK
28
28
 
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. 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.
30
30
 
31
31
  ## Features
32
32
 
33
33
  - **Document Management**: Retrieve and manage documents and their associated files.
34
34
  - **API Request Handling**: Simplified GET and POST requests with automatic retries and error handling.
35
35
  - **Data Models**: Predefined Pydantic models for structured data validation and serialization.
36
- - **Task Flow Integration**: Prefect-based decorators for creating and managing task flows.
36
+ - **Task Flow Integration**: Decorator for creating and managing task flows.
37
37
  - **Extensibility**: Easily extend and customize the library to fit your specific use case.
38
38
 
39
39
  ## Installation
@@ -69,17 +69,38 @@ for file in files:
69
69
  print(file.name)
70
70
  ```
71
71
 
72
- ### Use the Prefect Task Decorator
72
+ ### Use the Task Decorator
73
+
74
+ #### PROD
73
75
 
74
76
  ```python
75
77
  from clerk.decorator import clerk_code
78
+ from clerk.decorator.models import ClerkCodePayload
76
79
 
77
80
  @clerk_code()
78
- def process_document(payload):
79
- # Your processing logic here
80
- return {"status": "processed"}
81
+ def main(payload: ClerkCodePayload) -> ClerkCodePayload:
82
+ payload.structured_data["status"] = "ok"
83
+ return payload
84
+
85
+ main()
81
86
  ```
82
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
+
83
104
  ## Requirements
84
105
 
85
106
  - Python 3.10+
@@ -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.1",
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,43 +0,0 @@
1
- import pickle
2
- from typing import Callable
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():
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
40
-
41
- return wrapper
42
-
43
- return decorator
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes