documente_shared 0.1.113__tar.gz → 0.1.115__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.113 → documente_shared-0.1.115}/PKG-INFO +1 -1
  2. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/application/query_params.py +4 -0
  3. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/domain/entities/processing_case_item.py +4 -4
  4. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/domain/repositories/document.py +2 -2
  5. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/domain/repositories/processing_case_item.py +15 -3
  6. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/infrastructure/repositories/dynamo_processing_case_item.py +3 -3
  7. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/infrastructure/repositories/http_processing_case_item.py +11 -6
  8. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/infrastructure/repositories/mem_processing_case_item.py +11 -3
  9. {documente_shared-0.1.113 → documente_shared-0.1.115}/pyproject.toml +1 -1
  10. {documente_shared-0.1.113 → documente_shared-0.1.115}/README.md +0 -0
  11. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/__init__.py +0 -0
  12. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/application/__init__.py +0 -0
  13. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/application/dates.py +0 -0
  14. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/application/digest.py +0 -0
  15. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/application/exceptions.py +0 -0
  16. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/application/files.py +0 -0
  17. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/application/json.py +0 -0
  18. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/application/numbers.py +0 -0
  19. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/application/payloads.py +0 -0
  20. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/application/time_utils.py +0 -0
  21. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/application/timezone.py +0 -0
  22. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/domain/__init__.py +0 -0
  23. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/domain/base_enum.py +0 -0
  24. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/domain/constants.py +0 -0
  25. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/domain/entities/__init__.py +0 -0
  26. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/domain/entities/document.py +0 -0
  27. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/domain/entities/document_metadata.py +0 -0
  28. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/domain/entities/in_memory_document.py +0 -0
  29. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/domain/entities/processing_case.py +0 -0
  30. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/domain/entities/processing_case_filters.py +0 -0
  31. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/domain/entities/processing_case_item_filters.py +0 -0
  32. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/domain/entities/processing_documents.py +0 -0
  33. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/domain/entities/processing_event.py +0 -0
  34. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/domain/entities/scaling.py +0 -0
  35. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/domain/enums/__init__.py +0 -0
  36. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/domain/enums/common.py +0 -0
  37. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/domain/enums/document.py +0 -0
  38. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/domain/enums/processing_case.py +0 -0
  39. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/domain/exceptions.py +0 -0
  40. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/domain/interfaces/__init__.py +0 -0
  41. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/domain/interfaces/scaling.py +0 -0
  42. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/domain/repositories/__init__.py +0 -0
  43. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/domain/repositories/processing_case.py +0 -0
  44. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/infrastructure/__init__.py +0 -0
  45. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/infrastructure/documente_client.py +0 -0
  46. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/infrastructure/dynamo_table.py +0 -0
  47. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/infrastructure/lambdas.py +0 -0
  48. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/infrastructure/repositories/__init__.py +0 -0
  49. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/infrastructure/repositories/dynamo_document.py +0 -0
  50. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/infrastructure/repositories/dynamo_processing_case.py +0 -0
  51. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/infrastructure/repositories/http_document.py +0 -0
  52. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/infrastructure/repositories/http_processing_case.py +0 -0
  53. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/infrastructure/repositories/mem_document.py +0 -0
  54. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/infrastructure/repositories/mem_processing_case.py +0 -0
  55. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/infrastructure/s3_bucket.py +0 -0
  56. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/infrastructure/services/__init__.py +0 -0
  57. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/infrastructure/services/http_scaling.py +0 -0
  58. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/infrastructure/sqs_queue.py +0 -0
  59. {documente_shared-0.1.113 → documente_shared-0.1.115}/documente_shared/presentation/__init__.py +0 -0
  60. {documente_shared-0.1.113 → documente_shared-0.1.115}/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.113
3
+ Version: 0.1.115
4
4
  Summary: Shared utilities for Documente AI projects
5
5
  License: MIT
6
6
  Author: Tech
@@ -14,6 +14,10 @@ def camelize_string(value: str) -> str:
14
14
  return value[:1].lower() + value[1:]
15
15
 
16
16
 
17
+ def parse_bool(input_value: bool) -> str:
18
+ return str(input_value).lower()
19
+
20
+
17
21
  @dataclass
18
22
  class QueryParams(object):
19
23
  params: Union[dict]
@@ -17,7 +17,7 @@ class ProcessingCaseItem(object):
17
17
  case_id: str
18
18
  digest: str
19
19
  status: ProcessingStatus
20
- document: InMemoryDocument
20
+ document: Optional[InMemoryDocument] = None
21
21
  document_type: Optional[ProcessingDocumentType] = None
22
22
  uploaded_from: Optional[ProcessingSource] = None
23
23
  processed_csv: Optional[InMemoryDocument] = None
@@ -64,9 +64,9 @@ class ProcessingCaseItem(object):
64
64
  self.started_at = datetime.now(tz=timezone)
65
65
 
66
66
  def failed(
67
- self,
68
- error_message: Optional[str] = None,
69
- timezone: tzinfo = la_paz_tz,
67
+ self,
68
+ error_message: Optional[str] = None,
69
+ timezone: tzinfo = la_paz_tz,
70
70
  ):
71
71
  self.status = ProcessingStatus.FAILED
72
72
  self.failed_at = datetime.now(tz=timezone)
@@ -8,11 +8,11 @@ from documente_shared.domain.enums.document import DocumentProcessingStatus
8
8
  class DocumentProcessingRepository(ABC):
9
9
 
10
10
  @abstractmethod
11
- def find(self, digest: str) -> Optional[DocumentProcessing]:
11
+ def find(self, digest: str, read_bytes: bool = False) -> Optional[DocumentProcessing]:
12
12
  raise NotImplementedError
13
13
 
14
14
  @abstractmethod
15
- def persist(self, instance: DocumentProcessing) -> DocumentProcessing:
15
+ def persist(self, instance: DocumentProcessing, read_bytes: bool = False) -> DocumentProcessing:
16
16
  raise NotImplementedError
17
17
 
18
18
  @abstractmethod
@@ -8,15 +8,27 @@ from documente_shared.domain.entities.processing_case_item_filters import Proces
8
8
  class ProcessingCaseItemRepository(ABC):
9
9
 
10
10
  @abstractmethod
11
- def find(self, uuid: str) -> Optional[ProcessingCaseItem]:
11
+ def find(
12
+ self,
13
+ uuid: str,
14
+ read_bytes: bool = False,
15
+ ) -> Optional[ProcessingCaseItem]:
12
16
  raise NotImplementedError
13
17
 
14
18
  @abstractmethod
15
- def find_by_digest(self, digest: str) -> Optional[ProcessingCaseItem]:
19
+ def find_by_digest(
20
+ self,
21
+ digest: str,
22
+ read_bytes: bool = False,
23
+ ) -> Optional[ProcessingCaseItem]:
16
24
  raise NotImplementedError
17
25
 
18
26
  @abstractmethod
19
- def persist(self, instance: ProcessingCaseItem) -> ProcessingCaseItem:
27
+ def persist(
28
+ self,
29
+ instance: ProcessingCaseItem,
30
+ read_bytes: bool = False,
31
+ ) -> ProcessingCaseItem:
20
32
  raise NotImplementedError
21
33
 
22
34
  @abstractmethod
@@ -13,19 +13,19 @@ class DynamoProcessingCaseItemRepository(
13
13
  DynamoDBTable,
14
14
  ProcessingCaseItemRepository,
15
15
  ):
16
- def find(self, uuid: str) -> Optional[ProcessingCaseItem]:
16
+ def find(self, uuid: str, read_bytes: bool = False) -> Optional[ProcessingCaseItem]:
17
17
  item = self.get(key={'digest': uuid})
18
18
  if item:
19
19
  return ProcessingCaseItem.from_dict(item)
20
20
  return None
21
21
 
22
- def find_by_digest(self, digest: str) -> Optional[ProcessingCaseItem]:
22
+ def find_by_digest(self, digest: str, read_bytes: bool = False) -> Optional[ProcessingCaseItem]:
23
23
  item = self.get(key={'digest': digest})
24
24
  if item:
25
25
  return ProcessingCaseItem.from_dict(item)
26
26
  return None
27
27
 
28
- def persist(self, instance: ProcessingCaseItem) -> ProcessingCaseItem:
28
+ def persist(self, instance: ProcessingCaseItem, read_bytes: bool = False) -> ProcessingCaseItem:
29
29
  self.put(instance.to_simple_dict)
30
30
  return instance
31
31
 
@@ -5,6 +5,7 @@ from loguru import logger
5
5
  from requests import Response
6
6
 
7
7
  from documente_shared.application.payloads import camel_to_snake
8
+ from documente_shared.application.query_params import parse_bool
8
9
  from documente_shared.domain.entities.processing_case_item import ProcessingCaseItem
9
10
  from documente_shared.domain.entities.processing_case_item_filters import ProcessingCaseItemFilters
10
11
  from documente_shared.domain.repositories.processing_case_item import ProcessingCaseItemRepository
@@ -16,22 +17,26 @@ class HttpProcessingCaseItemRepository(
16
17
  DocumenteClientMixin,
17
18
  ProcessingCaseItemRepository,
18
19
  ):
19
- def find(self, uuid: str) -> Optional[ProcessingCaseItem]:
20
- response = self.session.get(f"{self.api_url}/v1/processing-case-items/{uuid}/")
20
+ def find(self, uuid: str, read_bytes: bool = False) -> Optional[ProcessingCaseItem]:
21
+ response = self.session.get(
22
+ url=f"{self.api_url}/v1/processing-case-items/{uuid}/?read_bytes={parse_bool(read_bytes)}",
23
+ )
21
24
  if response.status_code not in [200, 201]:
22
25
  return None
23
26
  return self._build_processing_case_item(response)
24
27
 
25
- def find_by_digest(self, digest: str) -> Optional[ProcessingCaseItem]:
26
- response = self.session.get(f"{self.api_url}/v1/processing-case-items/{digest}/")
28
+ def find_by_digest(self, digest: str, read_bytes: bool = False) -> Optional[ProcessingCaseItem]:
29
+ response = self.session.get(
30
+ url=f"{self.api_url}/v1/processing-case-items/{digest}/?read_bytes={parse_bool(read_bytes)}",
31
+ )
27
32
  if response.status_code not in [200, 201]:
28
33
  return None
29
34
  return self._build_processing_case_item(response)
30
35
 
31
- def persist(self, instance: ProcessingCaseItem) -> ProcessingCaseItem:
36
+ def persist(self, instance: ProcessingCaseItem, read_bytes: bool = False) -> ProcessingCaseItem:
32
37
  logger.info(f"PERSISTING_PROCESSING_CASE_ITEM: data={instance.to_simple_dict}")
33
38
  response: Response = self.session.put(
34
- url=f"{self.api_url}/v1/processing-case-items/{instance.uuid}/",
39
+ url=f"{self.api_url}/v1/processing-case-items/{instance.uuid}/?read_bytes={parse_bool(read_bytes)}",
35
40
  json=instance.to_persist_dict,
36
41
  )
37
42
  if response.status_code not in [200, 201]:
@@ -17,20 +17,28 @@ class MemoryProcessingCaseItemRepository(ProcessingCaseItemRepository):
17
17
  def find(
18
18
  self,
19
19
  uuid: str,
20
- include_items: bool = False,
20
+ read_items: bool = False,
21
21
  ) -> Optional[ProcessingCaseItem]:
22
22
  if uuid in self.collection:
23
23
  return self.collection[uuid]
24
24
  return None
25
25
 
26
- def find_by_digest(self, digest: str) -> Optional[ProcessingCaseItem]:
26
+ def find_by_digest(
27
+ self,
28
+ digest: str,
29
+ read_bytes: bool = False
30
+ ) -> Optional[ProcessingCaseItem]:
27
31
  for item in self.collection.values():
28
32
  if item.digest == digest:
29
33
  return item
30
34
  return None
31
35
 
32
36
 
33
- def persist(self, instance: ProcessingCaseItem) -> ProcessingCaseItem:
37
+ def persist(
38
+ self,
39
+ instance: ProcessingCaseItem,
40
+ read_bytes: bool = False,
41
+ ) -> ProcessingCaseItem:
34
42
  self.collection[instance.uuid] = instance
35
43
  return instance
36
44
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "documente_shared"
3
- version = "0.1.113"
3
+ version = "0.1.115"
4
4
  description = "Shared utilities for Documente AI projects"
5
5
  authors = ["Tech <tech@llamitai.com>"]
6
6
  license = "MIT"