documente_shared 0.1.106__py3-none-any.whl → 0.1.108__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 +75 -70
- documente_shared/infrastructure/repositories/http_document_processing.py +6 -3
- documente_shared/infrastructure/repositories/http_processing_case.py +2 -1
- documente_shared/infrastructure/repositories/http_processing_case_item.py +2 -0
- {documente_shared-0.1.106.dist-info → documente_shared-0.1.108.dist-info}/METADATA +1 -1
- {documente_shared-0.1.106.dist-info → documente_shared-0.1.108.dist-info}/RECORD +7 -7
- {documente_shared-0.1.106.dist-info → documente_shared-0.1.108.dist-info}/WHEEL +0 -0
|
@@ -36,34 +36,25 @@ class ProcessingCaseItem(object):
|
|
|
36
36
|
self.feedback = self.feedback or []
|
|
37
37
|
self.metadata = self.metadata or {}
|
|
38
38
|
|
|
39
|
-
@property
|
|
40
|
-
def has_processed_csv(self) -> bool:
|
|
41
|
-
return self.processed_csv and self.processed_csv.is_valid
|
|
42
39
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
def __eq__(self, other: 'ProcessingCaseItem') -> bool:
|
|
41
|
+
if not other:
|
|
42
|
+
return False
|
|
46
43
|
|
|
47
|
-
@property
|
|
48
|
-
def has_processed_json(self) -> bool:
|
|
49
|
-
return self.processed_json and self.processed_json.is_valid
|
|
50
|
-
|
|
51
|
-
@property
|
|
52
|
-
def is_procesable(self) -> bool:
|
|
53
44
|
return (
|
|
54
|
-
|
|
55
|
-
and self.digest
|
|
56
|
-
and self.
|
|
57
|
-
and self.
|
|
45
|
+
self.uuid == other.uuid
|
|
46
|
+
and self.digest == other.digest
|
|
47
|
+
and self.status == other.status
|
|
48
|
+
and self.document_type == other.document_type
|
|
49
|
+
and self.document == other.document
|
|
50
|
+
and self.processing_time == other.processing_time
|
|
51
|
+
and self.processing_confidence == other.processing_confidence
|
|
52
|
+
and self.uploaded_at == other.uploaded_at
|
|
53
|
+
and self.started_at == other.started_at
|
|
54
|
+
and self.failed_at == other.failed_at
|
|
55
|
+
and self.completed_at == other.completed_at
|
|
58
56
|
)
|
|
59
57
|
|
|
60
|
-
@property
|
|
61
|
-
def is_finished(self) -> bool:
|
|
62
|
-
return self.status in [
|
|
63
|
-
ProcessingStatus.COMPLETED,
|
|
64
|
-
ProcessingStatus.FAILED,
|
|
65
|
-
]
|
|
66
|
-
|
|
67
58
|
def pending(self, timezone: tzinfo = la_paz_tz):
|
|
68
59
|
self.status = ProcessingStatus.PENDING
|
|
69
60
|
self.started_at = None
|
|
@@ -73,9 +64,9 @@ class ProcessingCaseItem(object):
|
|
|
73
64
|
self.started_at = datetime.now(tz=timezone)
|
|
74
65
|
|
|
75
66
|
def failed(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
67
|
+
self,
|
|
68
|
+
error_message: Optional[str] = None,
|
|
69
|
+
timezone: tzinfo = la_paz_tz,
|
|
79
70
|
):
|
|
80
71
|
self.status = ProcessingStatus.FAILED
|
|
81
72
|
self.failed_at = datetime.now(tz=timezone)
|
|
@@ -90,28 +81,71 @@ class ProcessingCaseItem(object):
|
|
|
90
81
|
|
|
91
82
|
def deleted(self):
|
|
92
83
|
self.status = ProcessingStatus.DELETED
|
|
93
|
-
|
|
84
|
+
|
|
94
85
|
def in_review(self):
|
|
95
86
|
self.status = ProcessingStatus.IN_REVIEW
|
|
96
87
|
|
|
97
|
-
def
|
|
98
|
-
|
|
99
|
-
|
|
88
|
+
def overload(
|
|
89
|
+
self,
|
|
90
|
+
new_instance: 'ProcessingCaseItem',
|
|
91
|
+
properties: List[str] = None,
|
|
92
|
+
):
|
|
93
|
+
instance_properties = properties or [
|
|
94
|
+
'status',
|
|
95
|
+
'document',
|
|
96
|
+
'document_type',
|
|
97
|
+
'uploaded_from',
|
|
98
|
+
'processed_csv',
|
|
99
|
+
'processed_xlsx',
|
|
100
|
+
'processed_json',
|
|
101
|
+
'processing_time',
|
|
102
|
+
'processing_confidence',
|
|
103
|
+
'uploaded_at',
|
|
104
|
+
'started_at',
|
|
105
|
+
'failed_at',
|
|
106
|
+
'completed_at',
|
|
107
|
+
'feedback',
|
|
108
|
+
'metadata',
|
|
109
|
+
]
|
|
110
|
+
for _property in instance_properties:
|
|
111
|
+
property_value = getattr(new_instance, _property)
|
|
112
|
+
if not hasattr(self, _property):
|
|
113
|
+
continue
|
|
114
|
+
setattr(self, _property, property_value)
|
|
115
|
+
return self
|
|
116
|
+
|
|
117
|
+
@property
|
|
118
|
+
def combined_id(self) -> str:
|
|
119
|
+
return f"{self.case_id}__{self.uuid}"
|
|
120
|
+
|
|
121
|
+
@property
|
|
122
|
+
def has_processed_csv(self) -> bool:
|
|
123
|
+
return self.processed_csv and self.processed_csv.is_valid
|
|
124
|
+
|
|
125
|
+
@property
|
|
126
|
+
def has_processed_xlsx(self) -> bool:
|
|
127
|
+
return self.processed_xlsx and self.processed_xlsx.is_valid
|
|
100
128
|
|
|
129
|
+
@property
|
|
130
|
+
def has_processed_json(self) -> bool:
|
|
131
|
+
return self.processed_json and self.processed_json.is_valid
|
|
132
|
+
|
|
133
|
+
@property
|
|
134
|
+
def is_procesable(self) -> bool:
|
|
101
135
|
return (
|
|
102
|
-
self.
|
|
103
|
-
and self.digest
|
|
104
|
-
and self.
|
|
105
|
-
and self.
|
|
106
|
-
and self.document == other.document
|
|
107
|
-
and self.processing_time == other.processing_time
|
|
108
|
-
and self.processing_confidence == other.processing_confidence
|
|
109
|
-
and self.uploaded_at == other.uploaded_at
|
|
110
|
-
and self.started_at == other.started_at
|
|
111
|
-
and self.failed_at == other.failed_at
|
|
112
|
-
and self.completed_at == other.completed_at
|
|
136
|
+
(self.status.is_pending or self.status.is_enqueued)
|
|
137
|
+
and self.digest
|
|
138
|
+
and self.document
|
|
139
|
+
and self.document.is_procesable
|
|
113
140
|
)
|
|
114
141
|
|
|
142
|
+
@property
|
|
143
|
+
def is_finished(self) -> bool:
|
|
144
|
+
return self.status in [
|
|
145
|
+
ProcessingStatus.COMPLETED,
|
|
146
|
+
ProcessingStatus.FAILED,
|
|
147
|
+
]
|
|
148
|
+
|
|
115
149
|
@property
|
|
116
150
|
def to_dict(self) -> dict:
|
|
117
151
|
return {
|
|
@@ -185,35 +219,6 @@ class ProcessingCaseItem(object):
|
|
|
185
219
|
simple_dict["processed_json_path"] = self.processed_json.file_path if self.processed_json else None
|
|
186
220
|
return simple_dict
|
|
187
221
|
|
|
188
|
-
def overload(
|
|
189
|
-
self,
|
|
190
|
-
new_instance: 'ProcessingCaseItem',
|
|
191
|
-
properties: List[str] = None,
|
|
192
|
-
):
|
|
193
|
-
instance_properties = properties or [
|
|
194
|
-
'status',
|
|
195
|
-
'document',
|
|
196
|
-
'document_type',
|
|
197
|
-
'uploaded_from',
|
|
198
|
-
'processed_csv',
|
|
199
|
-
'processed_xlsx',
|
|
200
|
-
'processed_json',
|
|
201
|
-
'processing_time',
|
|
202
|
-
'processing_confidence',
|
|
203
|
-
'uploaded_at',
|
|
204
|
-
'started_at',
|
|
205
|
-
'failed_at',
|
|
206
|
-
'completed_at',
|
|
207
|
-
'feedback',
|
|
208
|
-
'metadata',
|
|
209
|
-
]
|
|
210
|
-
for _property in instance_properties:
|
|
211
|
-
property_value = getattr(new_instance, _property)
|
|
212
|
-
if not hasattr(self, _property):
|
|
213
|
-
continue
|
|
214
|
-
setattr(self, _property, property_value)
|
|
215
|
-
return self
|
|
216
|
-
|
|
217
222
|
@classmethod
|
|
218
223
|
def from_dict(cls, data: dict) -> 'ProcessingCaseItem':
|
|
219
224
|
return cls(
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
2
|
from typing import List, Optional
|
|
3
|
+
|
|
4
|
+
from loguru import logger
|
|
3
5
|
from requests import Response
|
|
4
6
|
|
|
5
7
|
from documente_shared.application.payloads import camel_to_snake
|
|
@@ -17,17 +19,18 @@ class HttpDocumentProcessingRepository(
|
|
|
17
19
|
def find(self, digest: str) -> Optional[DocumentProcessing]:
|
|
18
20
|
response = self.session.get(f"{self.api_url}/documents/{digest}/")
|
|
19
21
|
if response.status_code == 200:
|
|
20
|
-
return self.
|
|
22
|
+
return self._build_document_processing(response)
|
|
21
23
|
return None
|
|
22
24
|
|
|
23
25
|
def persist(self, instance: DocumentProcessing) -> DocumentProcessing:
|
|
26
|
+
logger.info(f"PERSISTING_DOCUMENT: data={instance.to_simple_dict}")
|
|
24
27
|
response = self.session.put(
|
|
25
28
|
url=f"{self.api_url}/documents/{instance.digest}/",
|
|
26
29
|
json=instance.to_simple_dict,
|
|
27
30
|
)
|
|
28
31
|
if response.status_code in [200, 201]:
|
|
29
32
|
raise Exception(f'Error persisting document processing: {response.text}')
|
|
30
|
-
return self.
|
|
33
|
+
return self._build_document_processing(response)
|
|
31
34
|
|
|
32
35
|
def remove(self, instance: DocumentProcessing):
|
|
33
36
|
self.session.delete(f"{self.api_url}/documents/{instance.digest}/")
|
|
@@ -43,7 +46,7 @@ class HttpDocumentProcessingRepository(
|
|
|
43
46
|
return []
|
|
44
47
|
|
|
45
48
|
@classmethod
|
|
46
|
-
def
|
|
49
|
+
def _build_document_processing(cls, response: Response) -> DocumentProcessing:
|
|
47
50
|
response_json = response.json()
|
|
48
51
|
instance_data = response_json.get('data', {})
|
|
49
52
|
return DocumentProcessing.from_dict(camel_to_snake(instance_data))
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
2
|
from typing import List, Optional
|
|
3
3
|
|
|
4
|
+
from loguru import logger
|
|
4
5
|
from requests import Response
|
|
5
6
|
|
|
6
7
|
from documente_shared.application.payloads import camel_to_snake
|
|
@@ -22,13 +23,13 @@ class HttpProcessingCaseRepository(
|
|
|
22
23
|
return None
|
|
23
24
|
|
|
24
25
|
def persist(self, instance: ProcessingCase) -> ProcessingCase:
|
|
26
|
+
logger.info(f"PERSISTING_PROCESSING_CASE: data={instance.to_dict}")
|
|
25
27
|
response = self.session.put(
|
|
26
28
|
url=f"{self.api_url}/v1/processing-cases/{instance.uuid}/",
|
|
27
29
|
json=instance.to_dict,
|
|
28
30
|
)
|
|
29
31
|
if response.status_code not in [200, 201]:
|
|
30
32
|
raise Exception(f'Error persisting processing case: {response.text}')
|
|
31
|
-
|
|
32
33
|
return self._build_processing_case(response)
|
|
33
34
|
|
|
34
35
|
def remove(self, instance: ProcessingCase):
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
2
|
from typing import List, Optional
|
|
3
3
|
|
|
4
|
+
from loguru import logger
|
|
4
5
|
from requests import Response
|
|
5
6
|
|
|
6
7
|
from documente_shared.application.payloads import camel_to_snake
|
|
@@ -28,6 +29,7 @@ class HttpProcessingCaseItemRepository(
|
|
|
28
29
|
return None
|
|
29
30
|
|
|
30
31
|
def persist(self, instance: ProcessingCaseItem) -> ProcessingCaseItem:
|
|
32
|
+
logger.info(f"PERSISTING_PROCESSING_CASE_ITEM: data={instance.to_simple_dict}")
|
|
31
33
|
response: Response = self.session.put(
|
|
32
34
|
url=f"{self.api_url}/v1/processing-case-items/{instance.uuid}/",
|
|
33
35
|
json=instance.to_persist_dict,
|
|
@@ -19,7 +19,7 @@ documente_shared/domain/entities/document_metadata.py,sha256=ygyFIC5qwxlm8DUM5kv
|
|
|
19
19
|
documente_shared/domain/entities/in_memory_document.py,sha256=BswTG1LjrQ8nP3pb0T2bSODPjJ2ud4ifbnYxRdFlIhY,2116
|
|
20
20
|
documente_shared/domain/entities/processing_case.py,sha256=NwGGGMyXnNprtO1lCP6rkPbhGhZ6C_z30OeHi_LHXDY,5706
|
|
21
21
|
documente_shared/domain/entities/processing_case_filters.py,sha256=harKyu7QEuL1bI_Z8_UxkVCMo5r9vHeNHyi_Ja07vjs,1953
|
|
22
|
-
documente_shared/domain/entities/processing_case_item.py,sha256=
|
|
22
|
+
documente_shared/domain/entities/processing_case_item.py,sha256=p9cyJpitd7WPiiRevZW6jRrD3VzCtM2iiYtCXOiLSgs,10250
|
|
23
23
|
documente_shared/domain/entities/processing_case_item_filters.py,sha256=R_AvDCB496Lww1qn2OwtltqULKE3IpcJB0ejnmRkg7Q,2009
|
|
24
24
|
documente_shared/domain/entities/processing_documents.py,sha256=YYuTkdCNkqlO8cA0onJsZYtstxGt9M5NMuIO_87lB14,352
|
|
25
25
|
documente_shared/domain/entities/processing_event.py,sha256=izdBXEz0TMNjxxZVjcM3YclzOv250JOV-amSpqmtQ9c,2180
|
|
@@ -43,9 +43,9 @@ documente_shared/infrastructure/repositories/__init__.py,sha256=47DEQpj8HBSa-_TI
|
|
|
43
43
|
documente_shared/infrastructure/repositories/dynamo_document.py,sha256=_Yp4gtA-n-hJ2w2wAM5BMCs2Mf46Q2Kq3eHqlxudkL4,1443
|
|
44
44
|
documente_shared/infrastructure/repositories/dynamo_processing_case.py,sha256=jkTVHThKHshLI53OV7ivK-WchFoAZTnaXlgh_1OX52k,1446
|
|
45
45
|
documente_shared/infrastructure/repositories/dynamo_processing_case_item.py,sha256=B2ElsASpXNRkwwjdCqXyvDU-LBrLNdwPfHLMvvG9c-Y,1729
|
|
46
|
-
documente_shared/infrastructure/repositories/http_document_processing.py,sha256=
|
|
47
|
-
documente_shared/infrastructure/repositories/http_processing_case.py,sha256=
|
|
48
|
-
documente_shared/infrastructure/repositories/http_processing_case_item.py,sha256=
|
|
46
|
+
documente_shared/infrastructure/repositories/http_document_processing.py,sha256=cMAaDO15_j2bq2J0UHqLk-OuhN76WJPqb4ExRqTxZBw,2294
|
|
47
|
+
documente_shared/infrastructure/repositories/http_processing_case.py,sha256=zBHscJSlsqTLT-NrUT3spfLgS8ZB5Tv9IokCB2Iyvpo,2350
|
|
48
|
+
documente_shared/infrastructure/repositories/http_processing_case_item.py,sha256=0L8JMkia1-kyIIXydaLtkrAPbW8GgzzPWE3iZ-y51KU,3085
|
|
49
49
|
documente_shared/infrastructure/repositories/mem_document.py,sha256=jg4rIjgSZijymjY9o7Q1lLcaiW9h-O8j6XljO1bJI7c,1299
|
|
50
50
|
documente_shared/infrastructure/repositories/mem_processing_case.py,sha256=ZAQwp4j0DXQMt92Z-ZR4h9MtbUp9IYy0OHz_sHgkZxY,1147
|
|
51
51
|
documente_shared/infrastructure/repositories/mem_processing_case_item.py,sha256=kQufzDTouu3agIXpEzRPdjltjTUFExrFbKkAZarGrUg,1419
|
|
@@ -55,6 +55,6 @@ documente_shared/infrastructure/services/http_scaling.py,sha256=cIo-61nfIwbtO86E
|
|
|
55
55
|
documente_shared/infrastructure/sqs_queue.py,sha256=KZWeHZ9zmXmrxoNpOQX7GEdDhZ1knbPXgwSwFwJblGg,1504
|
|
56
56
|
documente_shared/presentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
57
57
|
documente_shared/presentation/presenters.py,sha256=GGAEwefmjCIVepsUA2oZOVLxXbhhiISPM0Jgt6dT6O0,423
|
|
58
|
-
documente_shared-0.1.
|
|
59
|
-
documente_shared-0.1.
|
|
60
|
-
documente_shared-0.1.
|
|
58
|
+
documente_shared-0.1.108.dist-info/METADATA,sha256=zQzQnLTguvzfldOwccU0YWyG2icaIJMffJWCyMFfsQ4,963
|
|
59
|
+
documente_shared-0.1.108.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
60
|
+
documente_shared-0.1.108.dist-info/RECORD,,
|
|
File without changes
|