clerk-sdk 0.5.9__py3-none-any.whl → 0.5.11__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/__init__.py +1 -1
- clerk/client.py +7 -77
- {clerk_sdk-0.5.9.dist-info → clerk_sdk-0.5.11.dist-info}/METADATA +1 -1
- {clerk_sdk-0.5.9.dist-info → clerk_sdk-0.5.11.dist-info}/RECORD +7 -7
- {clerk_sdk-0.5.9.dist-info → clerk_sdk-0.5.11.dist-info}/WHEEL +0 -0
- {clerk_sdk-0.5.9.dist-info → clerk_sdk-0.5.11.dist-info}/entry_points.txt +0 -0
- {clerk_sdk-0.5.9.dist-info → clerk_sdk-0.5.11.dist-info}/licenses/LICENSE +0 -0
clerk/__init__.py
CHANGED
clerk/client.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Any, Dict, List, Literal
|
|
1
|
+
from typing import Any, Dict, List, Literal, cast
|
|
2
2
|
|
|
3
3
|
from clerk.base import BaseClerk
|
|
4
4
|
from clerk.models.document import Document, GetDocumentsRequest, UploadDocumentRequest
|
|
@@ -71,95 +71,25 @@ class Clerk(BaseClerk):
|
|
|
71
71
|
files_data = [f.to_multipart_format() for f in files]
|
|
72
72
|
self.post_request(endpoint, params=params, files=files_data)
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
class ClerkDocument(BaseClerk):
|
|
76
|
-
endpoint: str = "/document"
|
|
77
|
-
|
|
78
|
-
def upload_document(self, request: UploadDocumentRequest) -> Document:
|
|
79
|
-
endpoint = "/document"
|
|
80
|
-
res = self.post_request(
|
|
81
|
-
endpoint=endpoint, data=request.data, files=request.files_
|
|
82
|
-
)
|
|
83
|
-
return Document(**res.data[0])
|
|
84
|
-
|
|
85
|
-
def reprocess_document(self, document_id: str, workflow_id: str) -> Document:
|
|
86
|
-
endpoint = f"/document/{document_id}/reprocess"
|
|
87
|
-
res = self.put_request(endpoint=endpoint, data={"workflow_id": workflow_id})
|
|
88
|
-
return Document(**res.data[0])
|
|
89
|
-
|
|
90
|
-
def cancel_document_run(self, document_id: str) -> Document:
|
|
91
|
-
endpoint = f"/document/{document_id}/cancel"
|
|
92
|
-
res = self.post_request(endpoint=endpoint)
|
|
93
|
-
return Document(**res.data[0])
|
|
94
|
-
|
|
95
|
-
def update_document_structured_data(
|
|
96
|
-
self, document_id: str, updated_structured_data: Dict[str, Any]
|
|
97
|
-
) -> Document:
|
|
98
|
-
endpoint = f"/document/{document_id}"
|
|
99
|
-
payload = dict(structured_data=updated_structured_data)
|
|
100
|
-
res = self.put_request(endpoint, json=payload)
|
|
101
|
-
|
|
102
|
-
return Document(**res.data[0])
|
|
103
|
-
|
|
104
|
-
def get_document(self, document_id: str) -> Document:
|
|
105
|
-
endpoint = f"/document/{document_id}"
|
|
106
|
-
res = self.get_request(endpoint=endpoint)
|
|
107
|
-
return Document(**res.data[0])
|
|
108
|
-
|
|
109
|
-
def get_documents(self, request: GetDocumentsRequest) -> List[Document]:
|
|
110
|
-
if not any(
|
|
111
|
-
[
|
|
112
|
-
request.organization_id,
|
|
113
|
-
request.project_id,
|
|
114
|
-
request.start_date,
|
|
115
|
-
request.end_date,
|
|
116
|
-
request.query,
|
|
117
|
-
request.include_statuses,
|
|
118
|
-
]
|
|
119
|
-
):
|
|
120
|
-
raise ValueError(
|
|
121
|
-
"At least one query parameter (organization_id, project_id, start_date, end_date, query, or include_statuses) must be provided."
|
|
122
|
-
)
|
|
123
|
-
|
|
124
|
-
endpoint = f"/documents"
|
|
125
|
-
params = request.model_dump(mode="json")
|
|
126
|
-
res = self.get_request(endpoint, params=params)
|
|
127
|
-
|
|
128
|
-
return [Document(**d) for d in res.data]
|
|
129
|
-
|
|
130
|
-
def get_files_document(self, document_id: str) -> List[ParsedFile]:
|
|
131
|
-
endpoint = f"/document/{document_id}/files"
|
|
132
|
-
res = self.get_request(endpoint=endpoint)
|
|
133
|
-
return [ParsedFile(**d) for d in res.data]
|
|
134
|
-
|
|
135
|
-
def add_files_to_document(
|
|
136
|
-
self,
|
|
137
|
-
document_id: str,
|
|
138
|
-
type: Literal["input", "output"],
|
|
139
|
-
files: List[UploadFile],
|
|
140
|
-
):
|
|
141
|
-
endpoint = f"/document/{document_id}/files/upload"
|
|
142
|
-
params = {"type": type}
|
|
143
|
-
files_data = [f.to_multipart_format() for f in files]
|
|
144
|
-
self.post_request(endpoint, params=params, files=files_data)
|
|
145
|
-
|
|
146
74
|
def prevalidate_file(
|
|
147
75
|
self, project_id: str, workflow_id: str, file: UploadFile
|
|
148
|
-
) ->
|
|
76
|
+
) -> str:
|
|
149
77
|
"""Submit a prevalidation for a specific file. Returns the id for fetching the results later."""
|
|
150
78
|
endpoint = f"/prevalidation/file"
|
|
151
|
-
files_data = [file.to_multipart_format()]
|
|
79
|
+
files_data = [file.to_multipart_format(key="file")]
|
|
152
80
|
res = self.post_request(
|
|
153
81
|
endpoint,
|
|
154
82
|
files=files_data,
|
|
155
83
|
data={"project_id": project_id, "workflow_id": workflow_id},
|
|
156
84
|
)
|
|
157
|
-
return res.data[0]
|
|
85
|
+
return cast(str, res.data[0])
|
|
158
86
|
|
|
159
87
|
def get_prevalidation_results(
|
|
160
88
|
self, workflow_run_id: str
|
|
161
|
-
) -> FileClassificationResponse:
|
|
89
|
+
) -> FileClassificationResponse | None:
|
|
162
90
|
"""Fetch the results of a previously submitted prevalidation."""
|
|
163
91
|
endpoint = f"/prevalidation/file"
|
|
164
92
|
res = self.get_request(endpoint, params={"workflow_run_id": workflow_run_id})
|
|
93
|
+
if not res.data:
|
|
94
|
+
return None
|
|
165
95
|
return FileClassificationResponse(**res.data[0])
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
clerk/__init__.py,sha256=
|
|
1
|
+
clerk/__init__.py,sha256=TgQHVvVyqe6XGQBjFfgoMaYHKaFPSzYZiyxASecQ2iU,51
|
|
2
2
|
clerk/base.py,sha256=lbFTdpdDfsmYIQUFH93S1aw0-L6GNJwAcubW1tdMFX4,3967
|
|
3
|
-
clerk/client.py,sha256=
|
|
3
|
+
clerk/client.py,sha256=3jvszxm-minbarXtpymTSu5iKXqfXF4ts0uZGmsC-8I,3591
|
|
4
4
|
clerk/decorator/__init__.py,sha256=yGGcS17VsZ7cZ-hVGCm3I3vGDJMiJIAqmDGzriIi0DI,65
|
|
5
5
|
clerk/decorator/models.py,sha256=nFMdVSG3nJ4hrEXs9YbI_GgjHbVjhSWZokOCzUh-lqQ,521
|
|
6
6
|
clerk/decorator/task_decorator.py,sha256=H8caRvNvvl-IRwyREP66gBGVM-SpQJ1W7oAFImO-6Jw,3769
|
|
@@ -64,8 +64,8 @@ clerk/models/ui_operator.py,sha256=mKTJUFZgv7PeEt5oys28HVZxHOJsofmRQOcRpqj0dbU,2
|
|
|
64
64
|
clerk/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
65
65
|
clerk/utils/logger.py,sha256=NrMIlJfVmRjjRw_N_Jngkl0qqv7btXUbg5wxcRmFEH4,3800
|
|
66
66
|
clerk/utils/save_artifact.py,sha256=94aYkYNVGcSUaSWZmdjiY6Oc-3yCKb2XWCZ56IAXQqk,1158
|
|
67
|
-
clerk_sdk-0.5.
|
|
68
|
-
clerk_sdk-0.5.
|
|
69
|
-
clerk_sdk-0.5.
|
|
70
|
-
clerk_sdk-0.5.
|
|
71
|
-
clerk_sdk-0.5.
|
|
67
|
+
clerk_sdk-0.5.11.dist-info/METADATA,sha256=q58VQdgwpWlrCHvVQbC09jcr5myHV1DnqSLnrzRZgmY,9636
|
|
68
|
+
clerk_sdk-0.5.11.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
69
|
+
clerk_sdk-0.5.11.dist-info/entry_points.txt,sha256=VoUmW07sRRSioms5pqQ4A6CYxNEyhGA93GtyBlB_wGw,53
|
|
70
|
+
clerk_sdk-0.5.11.dist-info/licenses/LICENSE,sha256=GTVQl3vH6ht70wJXKC0yMT8CmXKHxv_YyO_utAgm7EA,1065
|
|
71
|
+
clerk_sdk-0.5.11.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|