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

@@ -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
  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
@@ -7,7 +7,7 @@ documente_shared/application/files.py,sha256=_qkpeFPVmHyNhD6_PFZdzhyYvshJVeeSiwu
7
7
  documente_shared/application/json.py,sha256=5y67-DoiJlq_fLefgJ8YBVsdyua4KykxbSUKQqcwnnQ,1223
8
8
  documente_shared/application/numbers.py,sha256=rik1SqMxLzXNL2S5Yh1Q8CSONdcjjoCBnByFasxR4_Q,212
9
9
  documente_shared/application/payloads.py,sha256=s6SjaNN18_aQ6IL083Zq2J8thRCZ_zC2sn7hkfjK_Go,453
10
- documente_shared/application/query_params.py,sha256=JscPqFBx28p-x9i2g6waY7Yl4FQM1zn2zSbEoTrkK1k,3938
10
+ documente_shared/application/query_params.py,sha256=hsYmRghwk9pgmzPww08eu_KS8JhCMtek_bxxCQ478l0,4018
11
11
  documente_shared/application/time_utils.py,sha256=_fxgh8VoGPkdsft47COJ16vFwt8pMbHIJCgDFHLSlrU,435
12
12
  documente_shared/application/timezone.py,sha256=NHpzTzOPD_fWQiJ4BrRqt_TIDs5XyB5ZMR7x8vUk8gQ,183
13
13
  documente_shared/domain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -19,7 +19,7 @@ documente_shared/domain/entities/document_metadata.py,sha256=ygyFIC5qwxlm8DUM5kv
19
19
  documente_shared/domain/entities/in_memory_document.py,sha256=BswTG1LjrQ8nP3pb0T2bSODPjJ2ud4ifbnYxRdFlIhY,2116
20
20
  documente_shared/domain/entities/processing_case.py,sha256=NwGGGMyXnNprtO1lCP6rkPbhGhZ6C_z30OeHi_LHXDY,5706
21
21
  documente_shared/domain/entities/processing_case_filters.py,sha256=harKyu7QEuL1bI_Z8_UxkVCMo5r9vHeNHyi_Ja07vjs,1953
22
- documente_shared/domain/entities/processing_case_item.py,sha256=p9cyJpitd7WPiiRevZW6jRrD3VzCtM2iiYtCXOiLSgs,10250
22
+ documente_shared/domain/entities/processing_case_item.py,sha256=KtH5JpJOcGLzVGQrcIGQY7CNWTwkm3_sriHM0ROF7SM,10255
23
23
  documente_shared/domain/entities/processing_case_item_filters.py,sha256=R_AvDCB496Lww1qn2OwtltqULKE3IpcJB0ejnmRkg7Q,2009
24
24
  documente_shared/domain/entities/processing_documents.py,sha256=YYuTkdCNkqlO8cA0onJsZYtstxGt9M5NMuIO_87lB14,352
25
25
  documente_shared/domain/entities/processing_event.py,sha256=izdBXEz0TMNjxxZVjcM3YclzOv250JOV-amSpqmtQ9c,2180
@@ -32,9 +32,9 @@ documente_shared/domain/exceptions.py,sha256=S2xkkFPiR8jVmA6UhRb-bPVrm6JvohXw2MU
32
32
  documente_shared/domain/interfaces/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
33
  documente_shared/domain/interfaces/scaling.py,sha256=yWAud0rcLKMMf2-QxEE__GRpzqUY0H9_qxlQTfnRYmw,249
34
34
  documente_shared/domain/repositories/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
- documente_shared/domain/repositories/document.py,sha256=vJzr6c92gqBzyhaEdjrvnoneKRrWmJ0AsvocPnhxiLU,767
35
+ documente_shared/domain/repositories/document.py,sha256=EZCbz8ManC1C2JcGuQQIJKON28AUAnUITZjy2zotRbY,819
36
36
  documente_shared/domain/repositories/processing_case.py,sha256=ruML2bciJ-3RShl0e6Ca09OXGtslBsH89j96ctnRC6I,912
37
- documente_shared/domain/repositories/processing_case_item.py,sha256=uBgJN2fJnZDcKUk018P_Fv25dQRZD5FBxFxsCQNaGAQ,948
37
+ documente_shared/domain/repositories/processing_case_item.py,sha256=Q3h0C1sGkMn41cmtzOhyz0yKzHqTe1MXd_ts3c6UZwo,1119
38
38
  documente_shared/infrastructure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
39
  documente_shared/infrastructure/documente_client.py,sha256=u6k73yIefuEkCsHULMpVCydFzrSXclf_5oQd2D7CkKU,698
40
40
  documente_shared/infrastructure/dynamo_table.py,sha256=TMQbcuty7wjDMbuhI8PbT0IGXelgELsNTtqTEQeZ824,2112
@@ -42,19 +42,19 @@ documente_shared/infrastructure/lambdas.py,sha256=sGgkw7Mhvuq2TpbW_RNdf5JvQnuzxW
42
42
  documente_shared/infrastructure/repositories/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
43
  documente_shared/infrastructure/repositories/dynamo_document.py,sha256=_Yp4gtA-n-hJ2w2wAM5BMCs2Mf46Q2Kq3eHqlxudkL4,1443
44
44
  documente_shared/infrastructure/repositories/dynamo_processing_case.py,sha256=n99X6OGTG5bHtIJY_1Z9HqabgWz-jbFXnQeqzeas7R8,1580
45
- documente_shared/infrastructure/repositories/dynamo_processing_case_item.py,sha256=B2ElsASpXNRkwwjdCqXyvDU-LBrLNdwPfHLMvvG9c-Y,1729
45
+ documente_shared/infrastructure/repositories/dynamo_processing_case_item.py,sha256=tKmJl_bSZoQ8jrAbXHlv8f3JILgvxse4H-89A-FAMRQ,1807
46
46
  documente_shared/infrastructure/repositories/http_document.py,sha256=TQdjKmly1m0L26_ksq9ce0_jv5NxtXvN8AT3Zd06yCE,2289
47
47
  documente_shared/infrastructure/repositories/http_processing_case.py,sha256=E4Rw2rBnwZl9a4GFlPddFSZO3ScwAe6UudLQiBryTYY,2583
48
- documente_shared/infrastructure/repositories/http_processing_case_item.py,sha256=rztS_5oE2VDN9LOUATrjCuiKBkxmIwKAakp9AFo8Obc,3185
48
+ documente_shared/infrastructure/repositories/http_processing_case_item.py,sha256=vwzFCSwcWQd80YRXD6ewkfBdakY0Xf-dQyOux-5aIDY,3490
49
49
  documente_shared/infrastructure/repositories/mem_document.py,sha256=jg4rIjgSZijymjY9o7Q1lLcaiW9h-O8j6XljO1bJI7c,1299
50
50
  documente_shared/infrastructure/repositories/mem_processing_case.py,sha256=59ZHCU32fu7MMvLvhxFfG7sKmJQ1R0449WVoTtfzpqY,1250
51
- documente_shared/infrastructure/repositories/mem_processing_case_item.py,sha256=kQufzDTouu3agIXpEzRPdjltjTUFExrFbKkAZarGrUg,1419
51
+ documente_shared/infrastructure/repositories/mem_processing_case_item.py,sha256=MShKyXrbwa1NOXhFPGsCieL7j2VhNg7cBLN77Kz7CJk,1529
52
52
  documente_shared/infrastructure/s3_bucket.py,sha256=vT_yN42RFQXubtUn8ln-j13Os_-25UGClVtXg5Bkv6I,1932
53
53
  documente_shared/infrastructure/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
54
  documente_shared/infrastructure/services/http_scaling.py,sha256=cIo-61nfIwbtO86EGi5r1tFi9g3VJXldhguddt4JUyc,906
55
55
  documente_shared/infrastructure/sqs_queue.py,sha256=KZWeHZ9zmXmrxoNpOQX7GEdDhZ1knbPXgwSwFwJblGg,1504
56
56
  documente_shared/presentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
57
57
  documente_shared/presentation/presenters.py,sha256=GGAEwefmjCIVepsUA2oZOVLxXbhhiISPM0Jgt6dT6O0,423
58
- documente_shared-0.1.113.dist-info/METADATA,sha256=XFRAW1tyebmHDw8fn1rLSahjdtMNY0vU2v009QEq8UQ,963
59
- documente_shared-0.1.113.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
60
- documente_shared-0.1.113.dist-info/RECORD,,
58
+ documente_shared-0.1.115.dist-info/METADATA,sha256=Jej_jT_-7b__6xiNpA4oiOdYUTPVmn-Z8haN3MIfxOI,963
59
+ documente_shared-0.1.115.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
60
+ documente_shared-0.1.115.dist-info/RECORD,,