documente_shared 0.1.36__tar.gz → 0.1.38__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.

Files changed (19) hide show
  1. {documente_shared-0.1.36 → documente_shared-0.1.38}/PKG-INFO +1 -1
  2. {documente_shared-0.1.36 → documente_shared-0.1.38}/documente_shared/domain/entities/document_process.py +23 -0
  3. {documente_shared-0.1.36 → documente_shared-0.1.38}/documente_shared/domain/repositories.py +7 -1
  4. {documente_shared-0.1.36 → documente_shared-0.1.38}/documente_shared/infrastructure/dynamo_repositories.py +21 -2
  5. {documente_shared-0.1.36 → documente_shared-0.1.38}/documente_shared/infrastructure/dynamo_table.py +2 -2
  6. {documente_shared-0.1.36 → documente_shared-0.1.38}/pyproject.toml +1 -1
  7. {documente_shared-0.1.36 → documente_shared-0.1.38}/README.md +0 -0
  8. {documente_shared-0.1.36 → documente_shared-0.1.38}/documente_shared/__init__.py +0 -0
  9. {documente_shared-0.1.36 → documente_shared-0.1.38}/documente_shared/application/__init__.py +0 -0
  10. {documente_shared-0.1.36 → documente_shared-0.1.38}/documente_shared/application/digest.py +0 -0
  11. {documente_shared-0.1.36 → documente_shared-0.1.38}/documente_shared/application/time_utils.py +0 -0
  12. {documente_shared-0.1.36 → documente_shared-0.1.38}/documente_shared/domain/__init__.py +0 -0
  13. {documente_shared-0.1.36 → documente_shared-0.1.38}/documente_shared/domain/base_enum.py +0 -0
  14. {documente_shared-0.1.36 → documente_shared-0.1.38}/documente_shared/domain/entities/__init__.py +0 -0
  15. {documente_shared-0.1.36 → documente_shared-0.1.38}/documente_shared/domain/entities/document_process_metadata.py +0 -0
  16. {documente_shared-0.1.36 → documente_shared-0.1.38}/documente_shared/domain/enums.py +0 -0
  17. {documente_shared-0.1.36 → documente_shared-0.1.38}/documente_shared/infrastructure/__init__.py +0 -0
  18. {documente_shared-0.1.36 → documente_shared-0.1.38}/documente_shared/infrastructure/s3_bucket.py +0 -0
  19. {documente_shared-0.1.36 → documente_shared-0.1.38}/documente_shared/infrastructure/sqs_queue.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: documente_shared
3
- Version: 0.1.36
3
+ Version: 0.1.38
4
4
  Summary: Shared utilities for Documente AI projects
5
5
  License: MIT
6
6
  Author: Tech
@@ -69,6 +69,13 @@ class DocumentProcess(object):
69
69
  self.file_path,
70
70
  ])
71
71
 
72
+ @property
73
+ def is_finished(self) -> bool:
74
+ return self.status in [
75
+ DocumentProcessStatus.COMPLETED,
76
+ DocumentProcessStatus.FAILED,
77
+ ]
78
+
72
79
  def enqueue(self):
73
80
  self.status = DocumentProcessStatus.ENQUEUED
74
81
  self.enqueued_at = datetime.now()
@@ -114,6 +121,22 @@ class DocumentProcess(object):
114
121
  filename_with_extension = self.extended_filename
115
122
  return filename_with_extension.split('.')[0]
116
123
 
124
+ def __eq__(self, other: 'DocumentProcess') -> bool:
125
+ if not other:
126
+ return False
127
+
128
+ return (
129
+ self.digest == other.digest
130
+ and self.status == other.status
131
+ and self.file_path == other.file_path
132
+ and self.uploaded_at == other.uploaded_at
133
+ and self.enqueued_at == other.enqueued_at
134
+ and self.started_at == other.started_at
135
+ and self.failed_at == other.failed_at
136
+ and self.completed_at == other.completed_at
137
+ )
138
+
139
+
117
140
  @property
118
141
  def to_dict(self) -> dict:
119
142
  return {
@@ -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
  [tool.poetry]
2
2
  name = "documente_shared"
3
- version = "0.1.36"
3
+ version = "0.1.38"
4
4
  description = "Shared utilities for Documente AI projects"
5
5
  authors = ["Tech <tech@llamitai.com>"]
6
6
  license = "MIT"