documente_shared 0.1.78__py3-none-any.whl → 0.1.80__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.
Potentially problematic release.
This version of documente_shared might be problematic. Click here for more details.
- documente_shared/domain/entities/processing_case_item.py +48 -8
- documente_shared/domain/repositories/processing_case.py +1 -1
- documente_shared/infrastructure/repositories/dynamo_processing_case.py +4 -4
- documente_shared/infrastructure/repositories/http_processing_case.py +10 -5
- documente_shared/infrastructure/repositories/http_processing_case_item.py +4 -4
- {documente_shared-0.1.78.dist-info → documente_shared-0.1.80.dist-info}/METADATA +1 -1
- {documente_shared-0.1.78.dist-info → documente_shared-0.1.80.dist-info}/RECORD +8 -8
- {documente_shared-0.1.78.dist-info → documente_shared-0.1.80.dist-info}/WHEEL +0 -0
|
@@ -16,8 +16,8 @@ class ProcessingCaseItem(object):
|
|
|
16
16
|
case_id: str
|
|
17
17
|
digest: str
|
|
18
18
|
status: ProcessingStatus
|
|
19
|
-
document_type: ProcessingDocumentType
|
|
20
19
|
document: InMemoryDocument
|
|
20
|
+
document_type: Optional[ProcessingDocumentType] = None
|
|
21
21
|
uploaded_from: Optional[ProcessingSource] = None
|
|
22
22
|
processed_csv: Optional[InMemoryDocument] = None
|
|
23
23
|
processed_xlsx: Optional[InMemoryDocument] = None
|
|
@@ -107,7 +107,10 @@ class ProcessingCaseItem(object):
|
|
|
107
107
|
'digest': self.digest,
|
|
108
108
|
'status': str(self.status),
|
|
109
109
|
'document': self.document.to_dict,
|
|
110
|
-
'document_type':
|
|
110
|
+
'document_type': (
|
|
111
|
+
str(self.document_type)
|
|
112
|
+
if self.document_type else None
|
|
113
|
+
),
|
|
111
114
|
'uploaded_from': (
|
|
112
115
|
str(self.uploaded_from)
|
|
113
116
|
if self.uploaded_from else None
|
|
@@ -132,12 +135,24 @@ class ProcessingCaseItem(object):
|
|
|
132
135
|
str(self.processing_confidence.quantize(Decimal('0.001')))
|
|
133
136
|
if self.processing_confidence else None
|
|
134
137
|
),
|
|
135
|
-
'uploaded_at':
|
|
136
|
-
|
|
137
|
-
|
|
138
|
+
'uploaded_at': (
|
|
139
|
+
self.uploaded_at.isoformat()
|
|
140
|
+
if self.uploaded_at else None
|
|
141
|
+
),
|
|
142
|
+
'started_at': (
|
|
143
|
+
self.started_at.isoformat()
|
|
144
|
+
if self.started_at else None
|
|
145
|
+
),
|
|
146
|
+
'failed_at': (
|
|
147
|
+
self.failed_at.isoformat()
|
|
148
|
+
if self.failed_at else None
|
|
149
|
+
),
|
|
138
150
|
'feedback': self.feedback,
|
|
139
151
|
'metadata': self.metadata,
|
|
140
|
-
'completed_at':
|
|
152
|
+
'completed_at': (
|
|
153
|
+
self.completed_at.isoformat()
|
|
154
|
+
if self.completed_at else None
|
|
155
|
+
),
|
|
141
156
|
}
|
|
142
157
|
|
|
143
158
|
@property
|
|
@@ -145,6 +160,15 @@ class ProcessingCaseItem(object):
|
|
|
145
160
|
simple_dict = self.to_dict.copy()
|
|
146
161
|
return simple_dict
|
|
147
162
|
|
|
163
|
+
@property
|
|
164
|
+
def to_persist_dict(self) -> dict:
|
|
165
|
+
simple_dict = self.to_dict.copy()
|
|
166
|
+
simple_dict["document_path"] = self.document.file_path if self.document else None
|
|
167
|
+
simple_dict["processed_csv_path"] = self.processed_csv.file_path if self.processed_csv else None
|
|
168
|
+
simple_dict["processed_xlsx_path"] = self.processed_xlsx.file_path if self.processed_xlsx else None
|
|
169
|
+
simple_dict["processed_json_path"] = self.processed_json.file_path if self.processed_json else None
|
|
170
|
+
return simple_dict
|
|
171
|
+
|
|
148
172
|
def overload(
|
|
149
173
|
self,
|
|
150
174
|
new_instance: 'ProcessingCaseItem',
|
|
@@ -152,8 +176,8 @@ class ProcessingCaseItem(object):
|
|
|
152
176
|
):
|
|
153
177
|
instance_properties = properties or [
|
|
154
178
|
'status',
|
|
155
|
-
'document_type',
|
|
156
179
|
'document',
|
|
180
|
+
'document_type',
|
|
157
181
|
'uploaded_from',
|
|
158
182
|
'processed_csv',
|
|
159
183
|
'processed_xlsx',
|
|
@@ -182,7 +206,10 @@ class ProcessingCaseItem(object):
|
|
|
182
206
|
digest=data.get('digest'),
|
|
183
207
|
status=ProcessingStatus.from_value(data.get('status')),
|
|
184
208
|
document=InMemoryDocument.from_dict(data.get('document')),
|
|
185
|
-
document_type=
|
|
209
|
+
document_type=(
|
|
210
|
+
ProcessingDocumentType.from_value(data.get('document_type'))
|
|
211
|
+
if data.get('document_type') else None
|
|
212
|
+
),
|
|
186
213
|
uploaded_from=(
|
|
187
214
|
ProcessingSource.from_value(data.get('uploaded_from'))
|
|
188
215
|
if data.get('uploaded_from') else None
|
|
@@ -214,3 +241,16 @@ class ProcessingCaseItem(object):
|
|
|
214
241
|
metadata=data.get('metadata', {}),
|
|
215
242
|
completed_at=get_datetime_from_data(input_datetime=data.get('completed_at')),
|
|
216
243
|
)
|
|
244
|
+
|
|
245
|
+
@classmethod
|
|
246
|
+
def from_persist_dict(cls, data: dict) -> 'ProcessingCaseItem':
|
|
247
|
+
instance = cls.from_dict(data)
|
|
248
|
+
if "document_path" in data:
|
|
249
|
+
instance.document = InMemoryDocument(file_path=data["document_path"])
|
|
250
|
+
if "processed_csv_path" in data:
|
|
251
|
+
instance.processed_csv = InMemoryDocument(file_path=data["processed_csv_path"])
|
|
252
|
+
if "processed_xlsx_path" in data:
|
|
253
|
+
instance.processed_xlsx = InMemoryDocument(file_path=data["processed_xlsx_path"])
|
|
254
|
+
if "processed_json_path" in data:
|
|
255
|
+
instance.processed_json = InMemoryDocument(file_path=data["processed_json_path"])
|
|
256
|
+
return instance
|
|
@@ -8,7 +8,7 @@ from documente_shared.domain.entities.processing_case_filters import ProcessingC
|
|
|
8
8
|
class ProcessingCaseRepository(ABC):
|
|
9
9
|
|
|
10
10
|
@abstractmethod
|
|
11
|
-
def find(self, uuid: str) -> Optional[ProcessingCase]:
|
|
11
|
+
def find(self, uuid: str, include_items: bool = False) -> Optional[ProcessingCase]:
|
|
12
12
|
raise NotImplementedError
|
|
13
13
|
|
|
14
14
|
@abstractmethod
|
|
@@ -3,7 +3,7 @@ from typing import Optional, List
|
|
|
3
3
|
from boto3.dynamodb.conditions import Key
|
|
4
4
|
|
|
5
5
|
from documente_shared.domain.entities.processing_case import ProcessingCase
|
|
6
|
-
from documente_shared.domain.
|
|
6
|
+
from documente_shared.domain.entities.processing_case_filters import ProcessingCaseFilters
|
|
7
7
|
from documente_shared.domain.repositories.processing_case import ProcessingCaseRepository
|
|
8
8
|
|
|
9
9
|
from documente_shared.infrastructure.dynamo_table import DynamoDBTable
|
|
@@ -13,7 +13,7 @@ class DynamoProcessingCaseRepository(
|
|
|
13
13
|
DynamoDBTable,
|
|
14
14
|
ProcessingCaseRepository,
|
|
15
15
|
):
|
|
16
|
-
def find(self, uuid: str) -> Optional[ProcessingCase]:
|
|
16
|
+
def find(self, uuid: str, include_items: bool = False) -> Optional[ProcessingCase]:
|
|
17
17
|
item = self.get(key={'uuid': uuid})
|
|
18
18
|
if item:
|
|
19
19
|
return ProcessingCase.from_dict(item)
|
|
@@ -26,10 +26,10 @@ class DynamoProcessingCaseRepository(
|
|
|
26
26
|
def remove(self, instance: ProcessingCase):
|
|
27
27
|
self.delete(key={'uuid': instance.uuid})
|
|
28
28
|
|
|
29
|
-
def filter(self,
|
|
29
|
+
def filter(self, tenant_slug: str, filters: ProcessingCaseFilters) -> List[ProcessingCase]:
|
|
30
30
|
items = []
|
|
31
31
|
|
|
32
|
-
for status in statuses:
|
|
32
|
+
for status in filters.statuses:
|
|
33
33
|
response = self._table.query(
|
|
34
34
|
IndexName='status',
|
|
35
35
|
KeyConditionExpression=Key('status').eq(status.value),
|
|
@@ -12,15 +12,15 @@ class HttpProcessingCaseRepository(
|
|
|
12
12
|
DocumenteClientMixin,
|
|
13
13
|
ProcessingCaseRepository,
|
|
14
14
|
):
|
|
15
|
-
def find(self, uuid: str) -> Optional[ProcessingCase]:
|
|
16
|
-
response = self.session.get(f"{self.api_url}/processing-cases/{uuid}/")
|
|
15
|
+
def find(self, uuid: str, include_items: bool = False) -> Optional[ProcessingCase]:
|
|
16
|
+
response = self.session.get(f"{self.api_url}/v1/processing-cases/{uuid}/")
|
|
17
17
|
if response.status_code == 200:
|
|
18
18
|
return ProcessingCase.from_dict(response.json())
|
|
19
19
|
return None
|
|
20
20
|
|
|
21
21
|
def persist(self, instance: ProcessingCase) -> ProcessingCase:
|
|
22
22
|
response = self.session.put(
|
|
23
|
-
url=f"{self.api_url}/processing-cases/{instance.uuid}/",
|
|
23
|
+
url=f"{self.api_url}/v1/processing-cases/{instance.uuid}/",
|
|
24
24
|
json=instance.to_dict,
|
|
25
25
|
)
|
|
26
26
|
if response.status_code not in [200, 201]:
|
|
@@ -28,10 +28,15 @@ class HttpProcessingCaseRepository(
|
|
|
28
28
|
return ProcessingCase.from_dict(response.json())
|
|
29
29
|
|
|
30
30
|
def remove(self, instance: ProcessingCase):
|
|
31
|
-
self.session.delete(f"{self.api_url}/processing-cases/{instance.uuid}/")
|
|
31
|
+
self.session.delete(f"{self.api_url}/v1/processing-cases/{instance.uuid}/")
|
|
32
32
|
|
|
33
33
|
def filter(self, tenant_slug: str, filters: ProcessingCaseFilters) -> List[ProcessingCase]:
|
|
34
|
-
response = self.session.get(
|
|
34
|
+
response = self.session.get(
|
|
35
|
+
url=f"{self.api_url}/v1/processing-cases/",
|
|
36
|
+
headers={
|
|
37
|
+
"X-Tenant": tenant_slug,
|
|
38
|
+
}
|
|
39
|
+
)
|
|
35
40
|
if response.status_code == 200:
|
|
36
41
|
raw_response = response.json()
|
|
37
42
|
return [
|
|
@@ -16,19 +16,19 @@ class HttpProcessingCaseItemRepository(
|
|
|
16
16
|
def find(self, uuid: str) -> Optional[ProcessingCaseItem]:
|
|
17
17
|
response = self.session.get(f"{self.api_url}/processing-case-items/{uuid}/")
|
|
18
18
|
if response.status_code == 200:
|
|
19
|
-
return ProcessingCaseItem.
|
|
19
|
+
return ProcessingCaseItem.from_persist_dict(response.json())
|
|
20
20
|
return None
|
|
21
21
|
|
|
22
22
|
def find_by_digest(self, digest: str) -> Optional[ProcessingCaseItem]:
|
|
23
23
|
response = self.session.get(f"{self.api_url}/processing-case-items/{digest}/")
|
|
24
24
|
if response.status_code == 200:
|
|
25
|
-
return ProcessingCaseItem.
|
|
25
|
+
return ProcessingCaseItem.from_persist_dict(response.json())
|
|
26
26
|
return None
|
|
27
27
|
|
|
28
28
|
def persist(self, instance: ProcessingCaseItem) -> ProcessingCaseItem:
|
|
29
29
|
response = self.session.put(
|
|
30
30
|
url=f"{self.api_url}/processing-case-items/{instance.uuid}/",
|
|
31
|
-
json=instance.
|
|
31
|
+
json=instance.to_persist_dict,
|
|
32
32
|
)
|
|
33
33
|
if response.status_code in [200, 201]:
|
|
34
34
|
return ProcessingCaseItem.from_dict(response.json())
|
|
@@ -46,7 +46,7 @@ class HttpProcessingCaseItemRepository(
|
|
|
46
46
|
if response.status_code == 200:
|
|
47
47
|
raw_response = response.json()
|
|
48
48
|
return [
|
|
49
|
-
ProcessingCaseItem.
|
|
49
|
+
ProcessingCaseItem.from_persist_dict(item)
|
|
50
50
|
for item in raw_response.get('data', [])
|
|
51
51
|
]
|
|
52
52
|
return []
|
|
@@ -15,7 +15,7 @@ documente_shared/domain/entities/document_metadata.py,sha256=ygyFIC5qwxlm8DUM5kv
|
|
|
15
15
|
documente_shared/domain/entities/in_memory_result.py,sha256=Q1E9vnLL5Hz5xunOqWtQmJOMjoK5KN42LZr18GlBAZo,1246
|
|
16
16
|
documente_shared/domain/entities/processing_case.py,sha256=3bL6BgFwWe6F5keZ6A1K_lLsrwGpkcKg98roM_i6kEQ,5167
|
|
17
17
|
documente_shared/domain/entities/processing_case_filters.py,sha256=FgyxB4mQb0nEGjIbUB9OiazkKL4yHRRC6bvmjD5NT8k,1915
|
|
18
|
-
documente_shared/domain/entities/processing_case_item.py,sha256=
|
|
18
|
+
documente_shared/domain/entities/processing_case_item.py,sha256=zav9tZ3EjQIJMccQzguF_0UJY4vc3yzfcNEQI_evMj4,9578
|
|
19
19
|
documente_shared/domain/entities/processing_case_item_filters.py,sha256=-cAQTSWOepMMcGCBg2X3dd0W_8XHuBTlvOB1d-3sVVM,1971
|
|
20
20
|
documente_shared/domain/entities/processing_event.py,sha256=m1O0gcNaE_SszeIhxM3uYPHSpyOUmize6mfRw1_bYZo,1723
|
|
21
21
|
documente_shared/domain/enums/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -24,19 +24,19 @@ documente_shared/domain/enums/document.py,sha256=NltZA1YVgJ7dVfSQdJFIE0ZUGf9Y-nx
|
|
|
24
24
|
documente_shared/domain/enums/processing_case.py,sha256=LhFhcoWlockxcpplsVdC6M2kpXn7sOdzQySf24wFhx8,1572
|
|
25
25
|
documente_shared/domain/repositories/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
26
|
documente_shared/domain/repositories/document.py,sha256=vJzr6c92gqBzyhaEdjrvnoneKRrWmJ0AsvocPnhxiLU,767
|
|
27
|
-
documente_shared/domain/repositories/processing_case.py,sha256=
|
|
27
|
+
documente_shared/domain/repositories/processing_case.py,sha256=9jGpnUnXaDgQE1ZKiet7zDVCc7wVvHUrcPOeacebb3s,796
|
|
28
28
|
documente_shared/domain/repositories/processing_case_item.py,sha256=gPZaQCMYlD6vlnEt6cVIqRmi1K-JWvmDx1f74nd97Cs,974
|
|
29
29
|
documente_shared/infrastructure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
30
30
|
documente_shared/infrastructure/documente_client.py,sha256=UjVWs9DKa-yhw5DVbcEs8iJxalHOarusVayi_ob6QhE,494
|
|
31
31
|
documente_shared/infrastructure/dynamo_table.py,sha256=TMQbcuty7wjDMbuhI8PbT0IGXelgELsNTtqTEQeZ824,2112
|
|
32
32
|
documente_shared/infrastructure/repositories/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
33
33
|
documente_shared/infrastructure/repositories/dynamo_document.py,sha256=_Yp4gtA-n-hJ2w2wAM5BMCs2Mf46Q2Kq3eHqlxudkL4,1443
|
|
34
|
-
documente_shared/infrastructure/repositories/dynamo_processing_case.py,sha256=
|
|
34
|
+
documente_shared/infrastructure/repositories/dynamo_processing_case.py,sha256=IoIHtlaEe4G5TqIV9IvG45a3HRBVHLfNC9sSgQjabUk,1464
|
|
35
35
|
documente_shared/infrastructure/repositories/dynamo_processing_case_item.py,sha256=4guM8V3YfP7kzYcuVWunGJGmXi0kSSUW8otks39g1vs,1754
|
|
36
|
-
documente_shared/infrastructure/repositories/http_processing_case.py,sha256
|
|
37
|
-
documente_shared/infrastructure/repositories/http_processing_case_item.py,sha256=
|
|
36
|
+
documente_shared/infrastructure/repositories/http_processing_case.py,sha256=-zNGiFCfINFWgE2ISWcEvPZThZCp45WRQhKFEL7QZW8,1869
|
|
37
|
+
documente_shared/infrastructure/repositories/http_processing_case_item.py,sha256=OSkOd7WdksS4O75uALU530kCsLkpjRTEBCmg3wg0ZFY,2110
|
|
38
38
|
documente_shared/infrastructure/s3_bucket.py,sha256=vT_yN42RFQXubtUn8ln-j13Os_-25UGClVtXg5Bkv6I,1932
|
|
39
39
|
documente_shared/infrastructure/sqs_queue.py,sha256=KZWeHZ9zmXmrxoNpOQX7GEdDhZ1knbPXgwSwFwJblGg,1504
|
|
40
|
-
documente_shared-0.1.
|
|
41
|
-
documente_shared-0.1.
|
|
42
|
-
documente_shared-0.1.
|
|
40
|
+
documente_shared-0.1.80.dist-info/METADATA,sha256=2RZnPEBEtepeyxgb9XCEQ8jbrItRuEyhQf6MvAfbOgY,881
|
|
41
|
+
documente_shared-0.1.80.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
42
|
+
documente_shared-0.1.80.dist-info/RECORD,,
|
|
File without changes
|