documente_shared 0.1.35__py3-none-any.whl → 0.1.37__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.

@@ -77,7 +77,8 @@ class DocumentProcess(object):
77
77
  self.status = DocumentProcessStatus.PROCESSING
78
78
  self.started_at = datetime.now()
79
79
 
80
- def failed(self):
80
+ def failed(self, error_message: Optional[str] = None):
81
+ self.failed_reason = error_message
81
82
  self.status = DocumentProcessStatus.FAILED
82
83
  self.failed_at = datetime.now()
83
84
 
@@ -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
+ ]
@@ -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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: documente_shared
3
- Version: 0.1.35
3
+ Version: 0.1.37
4
4
  Summary: Shared utilities for Documente AI projects
5
5
  License: MIT
6
6
  Author: Tech
@@ -5,15 +5,15 @@ documente_shared/application/time_utils.py,sha256=XDH27cKgoTFO8ad1JgrxKaeT7sZ1fd
5
5
  documente_shared/domain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  documente_shared/domain/base_enum.py,sha256=DojAfn-zQdtjtImeHUpBzE6TBTm07XrbMOdW3h8RVd8,1449
7
7
  documente_shared/domain/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- documente_shared/domain/entities/document_process.py,sha256=WtDz1WMVVgn2FvmTDRnQNVLl90Sp06P-ta4p8RTddfQ,7436
8
+ documente_shared/domain/entities/document_process.py,sha256=vDcri1NahlrTtE7wDStmMa135fqQZj2msW9xIQ0rF9E,7516
9
9
  documente_shared/domain/entities/document_process_metadata.py,sha256=rBHkDkoKwrxReKtXIScU1vrCO_6bg2LwWhrtXMcQ8TA,2351
10
10
  documente_shared/domain/enums.py,sha256=s3bFDkpplWvJWNpUwPOkC9a3OYUYsx8uTusN_FrzNQk,463
11
- documente_shared/domain/repositories.py,sha256=KEYbJKsfrRkJBCIjXQA3S5jdNqE5lUcQuvHiZig4B6M,526
11
+ documente_shared/domain/repositories.py,sha256=o9_ty3NPxCjb4hHIZbk71ECLqTjoKQI5MKWQje1KEyk,738
12
12
  documente_shared/infrastructure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- documente_shared/infrastructure/dynamo_repositories.py,sha256=WVyubQO8pUwm_y6VYU2n3fN4eofBXLBRzY1oehotp80,784
14
- documente_shared/infrastructure/dynamo_table.py,sha256=Lod8vwUCGX65SNH_8hvlpG6rRUYb4jfZqoFHD1YloAA,2096
13
+ documente_shared/infrastructure/dynamo_repositories.py,sha256=w_AW3IACVxRU7A3mNma2Elpbx7naRV4wY5mChW1WmZQ,1394
14
+ documente_shared/infrastructure/dynamo_table.py,sha256=dK05KgFvIYCmOdMpq9-OV_OBrP6cCngiUikCJrxlwt4,2112
15
15
  documente_shared/infrastructure/s3_bucket.py,sha256=Nf4bHSC3TJeaKvOQSVtV1hG8dWqEZZnA-JWU0PNTw24,1940
16
16
  documente_shared/infrastructure/sqs_queue.py,sha256=PSiTAnjXvQ-W-9mzLpH2UjbQJTvYkMiaxNaMecF-cR4,1505
17
- documente_shared-0.1.35.dist-info/METADATA,sha256=G_XmvO8Sciyg2UqOFU1YsXw-kPnDacy8Ih2fspFIOdI,640
18
- documente_shared-0.1.35.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
19
- documente_shared-0.1.35.dist-info/RECORD,,
17
+ documente_shared-0.1.37.dist-info/METADATA,sha256=7nRGwFRypTAO5ZW-hVLHkaJy6M0vm6c1-n5YpbiK8fs,640
18
+ documente_shared-0.1.37.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
19
+ documente_shared-0.1.37.dist-info/RECORD,,