documente_shared 0.1.122__tar.gz → 0.1.124__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.122 → documente_shared-0.1.124}/PKG-INFO +1 -1
  2. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/application/query_params.py +1 -1
  3. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/domain/entities/processing_case_item.py +1 -6
  4. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/domain/repositories/processing_case_item.py +1 -0
  5. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/infrastructure/repositories/dynamo_document.py +2 -2
  6. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/infrastructure/repositories/dynamo_processing_case_item.py +6 -1
  7. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/infrastructure/repositories/http_document.py +14 -3
  8. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/infrastructure/repositories/http_processing_case.py +7 -2
  9. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/infrastructure/repositories/http_processing_case_item.py +18 -6
  10. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/infrastructure/repositories/mem_processing_case_item.py +1 -0
  11. {documente_shared-0.1.122 → documente_shared-0.1.124}/pyproject.toml +1 -1
  12. {documente_shared-0.1.122 → documente_shared-0.1.124}/README.md +0 -0
  13. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/__init__.py +0 -0
  14. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/application/__init__.py +0 -0
  15. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/application/dates.py +0 -0
  16. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/application/digest.py +0 -0
  17. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/application/exceptions.py +0 -0
  18. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/application/files.py +0 -0
  19. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/application/json.py +0 -0
  20. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/application/numbers.py +0 -0
  21. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/application/payloads.py +0 -0
  22. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/application/time_utils.py +0 -0
  23. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/application/timezone.py +0 -0
  24. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/domain/__init__.py +0 -0
  25. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/domain/base_enum.py +0 -0
  26. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/domain/constants.py +0 -0
  27. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/domain/entities/__init__.py +0 -0
  28. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/domain/entities/document.py +0 -0
  29. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/domain/entities/document_metadata.py +0 -0
  30. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/domain/entities/in_memory_document.py +0 -0
  31. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/domain/entities/processing_case.py +0 -0
  32. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/domain/entities/processing_case_filters.py +0 -0
  33. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/domain/entities/processing_case_item_filters.py +0 -0
  34. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/domain/entities/processing_documents.py +0 -0
  35. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/domain/entities/processing_event.py +0 -0
  36. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/domain/entities/scaling.py +0 -0
  37. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/domain/enums/__init__.py +0 -0
  38. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/domain/enums/common.py +0 -0
  39. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/domain/enums/document.py +0 -0
  40. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/domain/enums/processing_case.py +0 -0
  41. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/domain/exceptions.py +0 -0
  42. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/domain/interfaces/__init__.py +0 -0
  43. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/domain/interfaces/scaling.py +0 -0
  44. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/domain/repositories/__init__.py +0 -0
  45. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/domain/repositories/document.py +0 -0
  46. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/domain/repositories/processing_case.py +0 -0
  47. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/infrastructure/__init__.py +0 -0
  48. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/infrastructure/documente_client.py +0 -0
  49. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/infrastructure/dynamo_table.py +0 -0
  50. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/infrastructure/lambdas.py +0 -0
  51. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/infrastructure/repositories/__init__.py +0 -0
  52. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/infrastructure/repositories/dynamo_processing_case.py +0 -0
  53. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/infrastructure/repositories/mem_document.py +0 -0
  54. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/infrastructure/repositories/mem_processing_case.py +0 -0
  55. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/infrastructure/s3_bucket.py +0 -0
  56. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/infrastructure/services/__init__.py +0 -0
  57. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/infrastructure/services/http_scaling.py +0 -0
  58. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/infrastructure/sqs_queue.py +0 -0
  59. {documente_shared-0.1.122 → documente_shared-0.1.124}/documente_shared/presentation/__init__.py +0 -0
  60. {documente_shared-0.1.122 → documente_shared-0.1.124}/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.122
3
+ Version: 0.1.124
4
4
  Summary: Shared utilities for Documente AI projects
5
5
  License: MIT
6
6
  Author: Tech
@@ -14,7 +14,7 @@ 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:
17
+ def parse_bool_to_str(input_value: bool) -> str:
18
18
  return str(input_value).lower()
19
19
 
20
20
 
@@ -233,12 +233,7 @@ class ProcessingCaseItem(object):
233
233
 
234
234
  @property
235
235
  def to_persist_dict(self) -> dict:
236
- simple_dict = self.to_dict.copy()
237
- simple_dict["document_path"] = self.document.file_path if self.document else None
238
- simple_dict["processed_csv_path"] = self.processed_csv.file_path if self.processed_csv else None
239
- simple_dict["processed_xlsx_path"] = self.processed_xlsx.file_path if self.processed_xlsx else None
240
- simple_dict["processed_json_path"] = self.processed_json.file_path if self.processed_json else None
241
- return simple_dict
236
+ return self.to_dict
242
237
 
243
238
  @classmethod
244
239
  def from_dict(cls, data: dict) -> 'ProcessingCaseItem':
@@ -28,6 +28,7 @@ class ProcessingCaseItemRepository(ABC):
28
28
  self,
29
29
  instance: ProcessingCaseItem,
30
30
  read_bytes: bool = False,
31
+ persist_bytes: bool = False,
31
32
  ) -> ProcessingCaseItem:
32
33
  raise NotImplementedError
33
34
 
@@ -13,13 +13,13 @@ class DynamoDocumentProcessingRepository(
13
13
  DynamoDBTable,
14
14
  DocumentProcessingRepository,
15
15
  ):
16
- def find(self, digest: str) -> Optional[DocumentProcessing]:
16
+ def find(self, digest: str, read_bytes: bool = False) -> Optional[DocumentProcessing]:
17
17
  item = self.get(key={'digest': digest})
18
18
  if item:
19
19
  return DocumentProcessing.from_dict(item)
20
20
  return None
21
21
 
22
- def persist(self, instance: DocumentProcessing) -> DocumentProcessing:
22
+ def persist(self, instance: DocumentProcessing, read_bytes: bool = False) -> DocumentProcessing:
23
23
  self.put(instance.to_simple_dict)
24
24
  return instance
25
25
 
@@ -25,7 +25,12 @@ class DynamoProcessingCaseItemRepository(
25
25
  return ProcessingCaseItem.from_dict(item)
26
26
  return None
27
27
 
28
- def persist(self, instance: ProcessingCaseItem, read_bytes: bool = False) -> ProcessingCaseItem:
28
+ def persist(
29
+ self,
30
+ instance: ProcessingCaseItem,
31
+ read_bytes: bool = False,
32
+ persist_bytes: bool = False,
33
+ ) -> ProcessingCaseItem:
29
34
  self.put(instance.to_simple_dict)
30
35
  return instance
31
36
 
@@ -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_to_str
8
9
  from documente_shared.domain.entities.document import DocumentProcessing
9
10
  from documente_shared.domain.enums.document import DocumentProcessingStatus
10
11
  from documente_shared.domain.repositories.document import DocumentProcessingRepository
@@ -16,16 +17,26 @@ class HttpDocumentProcessingRepository(
16
17
  DocumenteClientMixin,
17
18
  DocumentProcessingRepository,
18
19
  ):
19
- def find(self, digest: str) -> Optional[DocumentProcessing]:
20
- response = self.session.get(f"{self.api_url}/v1/documents/{digest}/")
20
+ def find(self, digest: str, read_bytes: bool = False) -> Optional[DocumentProcessing]:
21
+ params = {
22
+ "read_bytes": parse_bool_to_str(read_bytes),
23
+ }
24
+ response = self.session.get(
25
+ url=f"{self.api_url}/v1/documents/{digest}/",
26
+ params=params,
27
+ )
21
28
  if response.status_code not in [200, 201]:
22
29
  return None
23
30
  return self._build_document_processing(response)
24
31
 
25
- def persist(self, instance: DocumentProcessing) -> DocumentProcessing:
32
+ def persist(self, instance: DocumentProcessing, read_bytes: bool = False) -> DocumentProcessing:
26
33
  logger.info(f"PERSISTING_DOCUMENT: data={instance.to_simple_dict}")
34
+ params = {
35
+ "read_bytes": parse_bool_to_str(read_bytes),
36
+ }
27
37
  response = self.session.put(
28
38
  url=f"{self.api_url}/v1/documents/{instance.digest}/",
39
+ params=params,
29
40
  json=instance.to_simple_dict,
30
41
  )
31
42
  if response.status_code not in [200, 201]:
@@ -1,11 +1,12 @@
1
1
  from dataclasses import dataclass
2
+ from sqlite3.dbapi2 import paramstyle
2
3
  from typing import List, Optional
3
4
 
4
5
  from loguru import logger
5
6
  from requests import Response
6
7
 
7
8
  from documente_shared.application.payloads import camel_to_snake
8
- from documente_shared.application.query_params import parse_bool
9
+ from documente_shared.application.query_params import parse_bool_to_str
9
10
  from documente_shared.domain.entities.processing_case import ProcessingCase
10
11
  from documente_shared.domain.entities.processing_case_filters import ProcessingCaseFilters
11
12
  from documente_shared.domain.repositories.processing_case import ProcessingCaseRepository
@@ -34,8 +35,12 @@ class HttpProcessingCaseRepository(
34
35
  persist_items: bool = False,
35
36
  ) -> ProcessingCase:
36
37
  logger.info(f"PERSISTING_PROCESSING_CASE: data={instance.to_queue_dict}")
38
+ params = {
39
+ "persist_items": parse_bool_to_str(persist_items),
40
+ }
37
41
  response = self.session.put(
38
- url=f"{self.api_url}/v1/processing-cases/{instance.uuid}/?persist_items={parse_bool(persist_items)}",
42
+ url=f"{self.api_url}/v1/processing-cases/{instance.uuid}/",
43
+ params=params,
39
44
  json=instance.to_dict,
40
45
  )
41
46
  if response.status_code not in [200, 201]:
@@ -5,7 +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
+ from documente_shared.application.query_params import parse_bool_to_str
9
9
  from documente_shared.domain.entities.processing_case_item import ProcessingCaseItem
10
10
  from documente_shared.domain.entities.processing_case_item_filters import ProcessingCaseItemFilters
11
11
  from documente_shared.domain.repositories.processing_case_item import ProcessingCaseItemRepository
@@ -19,7 +19,7 @@ class HttpProcessingCaseItemRepository(
19
19
  ):
20
20
  def find(self, uuid: str, read_bytes: bool = False) -> Optional[ProcessingCaseItem]:
21
21
  response = self.session.get(
22
- url=f"{self.api_url}/v1/processing-case-items/{uuid}/?read_bytes={parse_bool(read_bytes)}",
22
+ url=f"{self.api_url}/v1/processing-case-items/{uuid}/?read_bytes={parse_bool_to_str(read_bytes)}",
23
23
  )
24
24
  if response.status_code not in [200, 201]:
25
25
  return None
@@ -27,17 +27,29 @@ class HttpProcessingCaseItemRepository(
27
27
 
28
28
  def find_by_digest(self, digest: str, read_bytes: bool = False) -> Optional[ProcessingCaseItem]:
29
29
  response = self.session.get(
30
- url=f"{self.api_url}/v1/processing-case-items/{digest}/?read_bytes={parse_bool(read_bytes)}",
30
+ url=f"{self.api_url}/v1/processing-case-items/{digest}/?read_bytes={parse_bool_to_str(read_bytes)}",
31
31
  )
32
32
  if response.status_code not in [200, 201]:
33
33
  return None
34
34
  return self._build_processing_case_item(response)
35
35
 
36
- def persist(self, instance: ProcessingCaseItem, read_bytes: bool = False) -> ProcessingCaseItem:
36
+ def persist(
37
+ self,
38
+ instance: ProcessingCaseItem,
39
+ read_bytes: bool = False,
40
+ persist_bytes: bool = False,
41
+ ) -> ProcessingCaseItem:
37
42
  logger.info(f"PERSISTING_PROCESSING_CASE_ITEM: data={instance.to_queue_dict}")
43
+ params = {
44
+ "read_bytes": parse_bool_to_str(read_bytes),
45
+ }
38
46
  response: Response = self.session.put(
39
- url=f"{self.api_url}/v1/processing-case-items/{instance.uuid}/?read_bytes={parse_bool(read_bytes)}",
40
- json=instance.to_persist_dict,
47
+ url=f"{self.api_url}/v1/processing-case-items/{instance.uuid}/",
48
+ params=params,
49
+ json=(
50
+ instance.to_persist_dict
51
+ if persist_bytes else instance.to_queue_dict
52
+ ),
41
53
  )
42
54
  if response.status_code not in [200, 201]:
43
55
  logger.info(f"PERSISTING_PROCESSING_CASE_ITEM ERROR: data={response.text}")
@@ -38,6 +38,7 @@ class MemoryProcessingCaseItemRepository(ProcessingCaseItemRepository):
38
38
  self,
39
39
  instance: ProcessingCaseItem,
40
40
  read_bytes: bool = False,
41
+ persist_bytes: bool = False,
41
42
  ) -> ProcessingCaseItem:
42
43
  self.collection[instance.uuid] = instance
43
44
  return instance
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "documente_shared"
3
- version = "0.1.122"
3
+ version = "0.1.124"
4
4
  description = "Shared utilities for Documente AI projects"
5
5
  authors = ["Tech <tech@llamitai.com>"]
6
6
  license = "MIT"