documente_shared 0.1.106__tar.gz → 0.1.108__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 (60) hide show
  1. {documente_shared-0.1.106 → documente_shared-0.1.108}/PKG-INFO +1 -1
  2. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/domain/entities/processing_case_item.py +75 -70
  3. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/infrastructure/repositories/http_document_processing.py +6 -3
  4. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/infrastructure/repositories/http_processing_case.py +2 -1
  5. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/infrastructure/repositories/http_processing_case_item.py +2 -0
  6. {documente_shared-0.1.106 → documente_shared-0.1.108}/pyproject.toml +1 -1
  7. {documente_shared-0.1.106 → documente_shared-0.1.108}/README.md +0 -0
  8. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/__init__.py +0 -0
  9. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/application/__init__.py +0 -0
  10. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/application/dates.py +0 -0
  11. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/application/digest.py +0 -0
  12. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/application/exceptions.py +0 -0
  13. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/application/files.py +0 -0
  14. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/application/json.py +0 -0
  15. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/application/numbers.py +0 -0
  16. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/application/payloads.py +0 -0
  17. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/application/query_params.py +0 -0
  18. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/application/time_utils.py +0 -0
  19. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/application/timezone.py +0 -0
  20. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/domain/__init__.py +0 -0
  21. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/domain/base_enum.py +0 -0
  22. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/domain/constants.py +0 -0
  23. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/domain/entities/__init__.py +0 -0
  24. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/domain/entities/document.py +0 -0
  25. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/domain/entities/document_metadata.py +0 -0
  26. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/domain/entities/in_memory_document.py +0 -0
  27. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/domain/entities/processing_case.py +0 -0
  28. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/domain/entities/processing_case_filters.py +0 -0
  29. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/domain/entities/processing_case_item_filters.py +0 -0
  30. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/domain/entities/processing_documents.py +0 -0
  31. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/domain/entities/processing_event.py +0 -0
  32. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/domain/entities/scaling.py +0 -0
  33. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/domain/enums/__init__.py +0 -0
  34. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/domain/enums/common.py +0 -0
  35. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/domain/enums/document.py +0 -0
  36. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/domain/enums/processing_case.py +0 -0
  37. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/domain/exceptions.py +0 -0
  38. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/domain/interfaces/__init__.py +0 -0
  39. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/domain/interfaces/scaling.py +0 -0
  40. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/domain/repositories/__init__.py +0 -0
  41. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/domain/repositories/document.py +0 -0
  42. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/domain/repositories/processing_case.py +0 -0
  43. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/domain/repositories/processing_case_item.py +0 -0
  44. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/infrastructure/__init__.py +0 -0
  45. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/infrastructure/documente_client.py +0 -0
  46. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/infrastructure/dynamo_table.py +0 -0
  47. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/infrastructure/lambdas.py +0 -0
  48. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/infrastructure/repositories/__init__.py +0 -0
  49. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/infrastructure/repositories/dynamo_document.py +0 -0
  50. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/infrastructure/repositories/dynamo_processing_case.py +0 -0
  51. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/infrastructure/repositories/dynamo_processing_case_item.py +0 -0
  52. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/infrastructure/repositories/mem_document.py +0 -0
  53. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/infrastructure/repositories/mem_processing_case.py +0 -0
  54. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/infrastructure/repositories/mem_processing_case_item.py +0 -0
  55. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/infrastructure/s3_bucket.py +0 -0
  56. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/infrastructure/services/__init__.py +0 -0
  57. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/infrastructure/services/http_scaling.py +0 -0
  58. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/infrastructure/sqs_queue.py +0 -0
  59. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/presentation/__init__.py +0 -0
  60. {documente_shared-0.1.106 → documente_shared-0.1.108}/documente_shared/presentation/presenters.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: documente_shared
3
- Version: 0.1.106
3
+ Version: 0.1.108
4
4
  Summary: Shared utilities for Documente AI projects
5
5
  License: MIT
6
6
  Author: Tech
@@ -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
- @property
44
- def has_processed_xlsx(self) -> bool:
45
- return self.processed_xlsx and self.processed_xlsx.is_valid
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
- (self.status.is_pending or self.status.is_enqueued)
55
- and self.digest
56
- and self.document
57
- and self.document.is_procesable
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
- self,
77
- error_message: Optional[str] = None,
78
- timezone: tzinfo = la_paz_tz,
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 __eq__(self, other: 'ProcessingCaseItem') -> bool:
98
- if not other:
99
- return False
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.uuid == other.uuid
103
- and self.digest == other.digest
104
- and self.status == other.status
105
- and self.document_type == other.document_type
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._build_processing_case(response)
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._build_processing_case(response)
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 _build_processing_case(cls, response: Response) -> DocumentProcessing:
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,
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "documente_shared"
3
- version = "0.1.106"
3
+ version = "0.1.108"
4
4
  description = "Shared utilities for Documente AI projects"
5
5
  authors = ["Tech <tech@llamitai.com>"]
6
6
  license = "MIT"