documente_shared 0.1.33__tar.gz → 0.1.37__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.
Potentially problematic release.
This version of documente_shared might be problematic. Click here for more details.
- {documente_shared-0.1.33 → documente_shared-0.1.37}/PKG-INFO +1 -1
- {documente_shared-0.1.33 → documente_shared-0.1.37}/documente_shared/domain/entities/document_process.py +6 -2
- {documente_shared-0.1.33 → documente_shared-0.1.37}/documente_shared/domain/repositories.py +7 -1
- {documente_shared-0.1.33 → documente_shared-0.1.37}/documente_shared/infrastructure/dynamo_repositories.py +21 -2
- {documente_shared-0.1.33 → documente_shared-0.1.37}/documente_shared/infrastructure/dynamo_table.py +2 -2
- {documente_shared-0.1.33 → documente_shared-0.1.37}/pyproject.toml +1 -1
- {documente_shared-0.1.33 → documente_shared-0.1.37}/README.md +0 -0
- {documente_shared-0.1.33 → documente_shared-0.1.37}/documente_shared/__init__.py +0 -0
- {documente_shared-0.1.33 → documente_shared-0.1.37}/documente_shared/application/__init__.py +0 -0
- {documente_shared-0.1.33 → documente_shared-0.1.37}/documente_shared/application/digest.py +0 -0
- {documente_shared-0.1.33 → documente_shared-0.1.37}/documente_shared/application/time_utils.py +0 -0
- {documente_shared-0.1.33 → documente_shared-0.1.37}/documente_shared/domain/__init__.py +0 -0
- {documente_shared-0.1.33 → documente_shared-0.1.37}/documente_shared/domain/base_enum.py +0 -0
- {documente_shared-0.1.33 → documente_shared-0.1.37}/documente_shared/domain/entities/__init__.py +0 -0
- {documente_shared-0.1.33 → documente_shared-0.1.37}/documente_shared/domain/entities/document_process_metadata.py +0 -0
- {documente_shared-0.1.33 → documente_shared-0.1.37}/documente_shared/domain/enums.py +0 -0
- {documente_shared-0.1.33 → documente_shared-0.1.37}/documente_shared/infrastructure/__init__.py +0 -0
- {documente_shared-0.1.33 → documente_shared-0.1.37}/documente_shared/infrastructure/s3_bucket.py +0 -0
- {documente_shared-0.1.33 → documente_shared-0.1.37}/documente_shared/infrastructure/sqs_queue.py +0 -0
|
@@ -34,6 +34,7 @@ class DocumentProcess(object):
|
|
|
34
34
|
enqueued_at: Optional[datetime] = None
|
|
35
35
|
started_at: Optional[datetime] = None
|
|
36
36
|
failed_at: Optional[datetime] = None
|
|
37
|
+
failed_reason: Optional[str] = None
|
|
37
38
|
completed_at: Optional[datetime] = None
|
|
38
39
|
metadata_items: Optional[List[DocumentProcessMetadata]] = None
|
|
39
40
|
|
|
@@ -76,7 +77,8 @@ class DocumentProcess(object):
|
|
|
76
77
|
self.status = DocumentProcessStatus.PROCESSING
|
|
77
78
|
self.started_at = datetime.now()
|
|
78
79
|
|
|
79
|
-
def failed(self):
|
|
80
|
+
def failed(self, error_message: Optional[str] = None):
|
|
81
|
+
self.failed_reason = error_message
|
|
80
82
|
self.status = DocumentProcessStatus.FAILED
|
|
81
83
|
self.failed_at = datetime.now()
|
|
82
84
|
|
|
@@ -137,6 +139,7 @@ class DocumentProcess(object):
|
|
|
137
139
|
'enqueued_at': self.enqueued_at.isoformat() if self.enqueued_at else None,
|
|
138
140
|
'started_at': self.started_at.isoformat() if self.started_at else None,
|
|
139
141
|
'failed_at': self.failed_at.isoformat() if self.failed_at else None,
|
|
142
|
+
'failed_reason': self.failed_reason,
|
|
140
143
|
'completed_at': self.completed_at.isoformat() if self.completed_at else None,
|
|
141
144
|
'metadata_items': [metadata.to_dict for metadata in self.metadata_items],
|
|
142
145
|
}
|
|
@@ -156,7 +159,7 @@ class DocumentProcess(object):
|
|
|
156
159
|
'status', 'metadata', 'file_path', 'file_bytes', 'category', 'sub_category',
|
|
157
160
|
'processed_csv_path', 'processed_csv_bytes', 'processed_xlsx_path', 'processed_metadata_path',
|
|
158
161
|
'processed_xlsx_bytes', 'processing_time', 'uploaded_at',
|
|
159
|
-
'enqueued_at', 'started_at', 'failed_at', 'completed_at',
|
|
162
|
+
'enqueued_at', 'started_at', 'failed_at', 'failed_reason', 'completed_at',
|
|
160
163
|
]
|
|
161
164
|
for _property in instance_properties:
|
|
162
165
|
property_value = getattr(new_instance, _property)
|
|
@@ -190,6 +193,7 @@ class DocumentProcess(object):
|
|
|
190
193
|
enqueued_at=get_datetime_from_data(input_datetime=data.get('enqueued_at')),
|
|
191
194
|
started_at=get_datetime_from_data(input_datetime=data.get('started_at')),
|
|
192
195
|
failed_at=get_datetime_from_data(input_datetime=data.get('failed_at')),
|
|
196
|
+
failed_reason=data.get('failed_reason'),
|
|
193
197
|
completed_at=get_datetime_from_data(input_datetime=data.get('completed_at')),
|
|
194
198
|
metadata_items=[
|
|
195
199
|
DocumentProcessMetadata.from_dict(metadata)
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
from abc import ABC, abstractmethod
|
|
2
|
-
from typing import Optional
|
|
2
|
+
from typing import Optional, List
|
|
3
3
|
|
|
4
4
|
from documente_shared.domain.entities.document_process import DocumentProcess
|
|
5
|
+
from documente_shared.domain.enums import DocumentProcessStatus
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
class DocumentProcessRepository(ABC):
|
|
@@ -16,4 +17,9 @@ class DocumentProcessRepository(ABC):
|
|
|
16
17
|
|
|
17
18
|
@abstractmethod
|
|
18
19
|
def remove(self, instance: DocumentProcess):
|
|
20
|
+
raise NotImplementedError
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@abstractmethod
|
|
24
|
+
def filter(self, statuses: List[DocumentProcessStatus]) -> List[DocumentProcess]:
|
|
19
25
|
raise NotImplementedError
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
from typing import Optional
|
|
1
|
+
from typing import Optional, List
|
|
2
|
+
|
|
3
|
+
from boto3.dynamodb.conditions import Key
|
|
2
4
|
|
|
3
5
|
from documente_shared.domain.entities.document_process import DocumentProcess
|
|
6
|
+
from documente_shared.domain.enums import DocumentProcessStatus
|
|
4
7
|
from documente_shared.domain.repositories import DocumentProcessRepository
|
|
5
8
|
from documente_shared.infrastructure.dynamo_table import DynamoDBTable
|
|
6
9
|
|
|
@@ -21,4 +24,20 @@ class DynamoDocumentProcessRepository(
|
|
|
21
24
|
return instance
|
|
22
25
|
|
|
23
26
|
def remove(self, instance: DocumentProcess):
|
|
24
|
-
self.delete(key={'digest': instance.digest})
|
|
27
|
+
self.delete(key={'digest': instance.digest})
|
|
28
|
+
|
|
29
|
+
def filter(self, statuses: List[DocumentProcessStatus]) -> List[DocumentProcess]:
|
|
30
|
+
items = []
|
|
31
|
+
|
|
32
|
+
for status in statuses:
|
|
33
|
+
response = self._table.query(
|
|
34
|
+
IndexName='status',
|
|
35
|
+
KeyConditionExpression=Key('status').eq(status.value),
|
|
36
|
+
)
|
|
37
|
+
status_items = response.get('Items', [])
|
|
38
|
+
items.extend(status_items)
|
|
39
|
+
|
|
40
|
+
return [
|
|
41
|
+
DocumentProcess.from_dict(item)
|
|
42
|
+
for item in items
|
|
43
|
+
]
|
{documente_shared-0.1.33 → documente_shared-0.1.37}/documente_shared/infrastructure/dynamo_table.py
RENAMED
|
@@ -23,8 +23,8 @@ class DynamoDBTable(object):
|
|
|
23
23
|
return self.put({**key, **attributes})
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
def filter_by(self, attribute, target_value):
|
|
27
|
-
return self._table(
|
|
26
|
+
def filter_by(self, attribute: str, target_value: str):
|
|
27
|
+
return self._table.query(
|
|
28
28
|
FilterExpression=Key(attribute).eq(target_value),
|
|
29
29
|
).get('Items')
|
|
30
30
|
|
|
File without changes
|
|
File without changes
|
{documente_shared-0.1.33 → documente_shared-0.1.37}/documente_shared/application/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{documente_shared-0.1.33 → documente_shared-0.1.37}/documente_shared/application/time_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{documente_shared-0.1.33 → documente_shared-0.1.37}/documente_shared/domain/entities/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{documente_shared-0.1.33 → documente_shared-0.1.37}/documente_shared/infrastructure/__init__.py
RENAMED
|
File without changes
|
{documente_shared-0.1.33 → documente_shared-0.1.37}/documente_shared/infrastructure/s3_bucket.py
RENAMED
|
File without changes
|
{documente_shared-0.1.33 → documente_shared-0.1.37}/documente_shared/infrastructure/sqs_queue.py
RENAMED
|
File without changes
|