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

@@ -8,7 +8,12 @@ from documente_shared.domain.entities.processing_case_filters import ProcessingC
8
8
  class ProcessingCaseRepository(ABC):
9
9
 
10
10
  @abstractmethod
11
- def find(self, uuid: str, include_items: bool = False) -> Optional[ProcessingCase]:
11
+ def find(
12
+ self,
13
+ uuid: str,
14
+ include_items: bool = False,
15
+ include_items_bytes: bool = False,
16
+ ) -> Optional[ProcessingCase]:
12
17
  raise NotImplementedError
13
18
 
14
19
  @abstractmethod
@@ -13,7 +13,12 @@ class DynamoProcessingCaseRepository(
13
13
  DynamoDBTable,
14
14
  ProcessingCaseRepository,
15
15
  ):
16
- def find(self, uuid: str, include_items: bool = False) -> Optional[ProcessingCase]:
16
+ def find(
17
+ self,
18
+ uuid: str,
19
+ include_items: bool = False,
20
+ include_items_bytes: bool = False,
21
+ ) -> Optional[ProcessingCase]:
17
22
  item = self.get(key={'uuid': uuid})
18
23
  if item:
19
24
  return ProcessingCase.from_dict(item)
@@ -18,9 +18,9 @@ class HttpDocumentProcessingRepository(
18
18
  ):
19
19
  def find(self, digest: str) -> Optional[DocumentProcessing]:
20
20
  response = self.session.get(f"{self.api_url}/v1/documents/{digest}/")
21
- if response.status_code == 200:
22
- return self._build_document_processing(response)
23
- return None
21
+ if response.status_code not in [200, 201]:
22
+ return None
23
+ return self._build_document_processing(response)
24
24
 
25
25
  def persist(self, instance: DocumentProcessing) -> DocumentProcessing:
26
26
  logger.info(f"PERSISTING_DOCUMENT: data={instance.to_simple_dict}")
@@ -28,8 +28,7 @@ class HttpDocumentProcessingRepository(
28
28
  url=f"{self.api_url}/v1/documents/{instance.digest}/",
29
29
  json=instance.to_simple_dict,
30
30
  )
31
- if response.status_code in [200, 201]:
32
- logger.warning(f"PERSISTING_DOCUMENT ERROR: response={response.text}")
31
+ if response.status_code not in [200, 201]:
33
32
  raise Exception(f'Error persisting document processing: {response.text}')
34
33
  return self._build_document_processing(response)
35
34
 
@@ -38,13 +37,14 @@ class HttpDocumentProcessingRepository(
38
37
 
39
38
  def filter(self, statuses: List[DocumentProcessingStatus]) -> List[DocumentProcessing]:
40
39
  response = self.session.get(f"{self.api_url}/v1/documents/?statuses={statuses}")
41
- if response.status_code == 200:
42
- raw_response = response.json()
43
- return [
44
- DocumentProcessing.from_dict(camel_to_snake(item['documentProcessing']))
45
- for item in raw_response.get('data', [])
46
- ]
47
- return []
40
+ if response.status_code not in [200, 201]:
41
+ return []
42
+ raw_response = response.json()
43
+ return [
44
+ DocumentProcessing.from_dict(camel_to_snake(item['documentProcessing']))
45
+ for item in raw_response.get('data', [])
46
+ ]
47
+
48
48
 
49
49
  @classmethod
50
50
  def _build_document_processing(cls, response: Response) -> DocumentProcessing:
@@ -16,11 +16,16 @@ class HttpProcessingCaseRepository(
16
16
  DocumenteClientMixin,
17
17
  ProcessingCaseRepository,
18
18
  ):
19
- def find(self, uuid: str, include_items: bool = False) -> Optional[ProcessingCase]:
19
+ def find(
20
+ self,
21
+ uuid: str,
22
+ include_items: bool = False,
23
+ include_items_bytes: bool = False,
24
+ ) -> Optional[ProcessingCase]:
20
25
  response = self.session.get(f"{self.api_url}/v1/processing-cases/{uuid}/")
21
- if response.status_code == 200:
22
- return self._build_processing_case(response)
23
- return None
26
+ if response.status_code not in [200, 201]:
27
+ return None
28
+ return self._build_processing_case(response)
24
29
 
25
30
  def persist(self, instance: ProcessingCase) -> ProcessingCase:
26
31
  logger.info(f"PERSISTING_PROCESSING_CASE: data={instance.to_dict}")
@@ -42,13 +47,13 @@ class HttpProcessingCaseRepository(
42
47
  "X-Tenant": filters.tenant_slug,
43
48
  }
44
49
  )
45
- if response.status_code == 200:
46
- raw_response = response.json()
47
- return [
48
- ProcessingCase.from_persist_dict(camel_to_snake(item_data))
49
- for item_data in raw_response.get('data', [])
50
- ]
51
- return []
50
+ if response.status_code not in [200, 201]:
51
+ return []
52
+ raw_response = response.json()
53
+ return [
54
+ ProcessingCase.from_persist_dict(camel_to_snake(item_data))
55
+ for item_data in raw_response.get('data', [])
56
+ ]
52
57
 
53
58
 
54
59
  @classmethod
@@ -18,15 +18,15 @@ class HttpProcessingCaseItemRepository(
18
18
  ):
19
19
  def find(self, uuid: str) -> Optional[ProcessingCaseItem]:
20
20
  response = self.session.get(f"{self.api_url}/v1/processing-case-items/{uuid}/")
21
- if response.status_code == 200:
22
- return self._build_processing_case_item(response)
23
- return None
21
+ if response.status_code not in [200, 201]:
22
+ return None
23
+ return self._build_processing_case_item(response)
24
24
 
25
25
  def find_by_digest(self, digest: str) -> Optional[ProcessingCaseItem]:
26
26
  response = self.session.get(f"{self.api_url}/v1/processing-case-items/{digest}/")
27
- if response.status_code == 200:
28
- return self._build_processing_case_item(response)
29
- return None
27
+ if response.status_code not in [200, 201]:
28
+ return None
29
+ return self._build_processing_case_item(response)
30
30
 
31
31
  def persist(self, instance: ProcessingCaseItem) -> ProcessingCaseItem:
32
32
  logger.info(f"PERSISTING_PROCESSING_CASE_ITEM: data={instance.to_simple_dict}")
@@ -34,10 +34,10 @@ class HttpProcessingCaseItemRepository(
34
34
  url=f"{self.api_url}/v1/processing-case-items/{instance.uuid}/",
35
35
  json=instance.to_persist_dict,
36
36
  )
37
- if response.status_code in [200, 201]:
38
- logger.warning(f"PERSISTING_PROCESSING_CASE_ITEM ERROR: response={response.text}")
39
- return self._build_processing_case_item(response)
40
- return instance
37
+ if response.status_code not in [200, 201]:
38
+ logger.info(f"PERSISTING_PROCESSING_CASE_ITEM ERROR: data={response.text}")
39
+ return instance
40
+ return self._build_processing_case_item(response)
41
41
 
42
42
  def remove(self, instance: ProcessingCaseItem):
43
43
  self.session.delete(f"{self.api_url}/v1/processing-case-items/{instance.uuid}/")
@@ -47,27 +47,27 @@ class HttpProcessingCaseItemRepository(
47
47
  filters: ProcessingCaseItemFilters,
48
48
  ) -> List[ProcessingCaseItem]:
49
49
  response = self.session.get(f"{self.api_url}/v1/processing-case-items/")
50
- if response.status_code == 200:
51
- raw_response = response.json()
52
- return [
53
- ProcessingCaseItem.from_dict(camel_to_snake(item_data))
54
- for item_data in raw_response.get('data', [])
55
- ]
56
- return []
57
-
50
+ if response.status_code not in [200, 201]:
51
+ return []
52
+ raw_response = response.json()
53
+ return [
54
+ ProcessingCaseItem.from_dict(camel_to_snake(item_data))
55
+ for item_data in raw_response.get('data', [])
56
+ ]
57
+
58
58
  def filter_with_tenant(
59
59
  self,
60
60
  tenant_slug: str,
61
61
  filters: ProcessingCaseItemFilters,
62
62
  ) -> List[ProcessingCaseItem]:
63
63
  response = self.session.get(f"{self.api_url}/v1/processing-case-items/")
64
- if response.status_code == 200:
65
- raw_response = response.json()
66
- return [
67
- ProcessingCaseItem.from_dict(camel_to_snake(item_data))
68
- for item_data in raw_response.get('data', [])
69
- ]
70
- return []
64
+ if response.status_code not in [200, 201]:
65
+ return []
66
+ raw_response = response.json()
67
+ return [
68
+ ProcessingCaseItem.from_dict(camel_to_snake(item_data))
69
+ for item_data in raw_response.get('data', [])
70
+ ]
71
71
 
72
72
  @classmethod
73
73
  def _build_processing_case_item(cls, response: Response) -> ProcessingCaseItem:
@@ -18,6 +18,7 @@ class MemoryProcessingCaseRepository(ProcessingCaseRepository):
18
18
  self,
19
19
  uuid: str,
20
20
  include_items: bool = False,
21
+ include_items_bytes: bool = False,
21
22
  ) -> Optional[ProcessingCase]:
22
23
  if uuid in self.collection:
23
24
  return self.collection[uuid]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: documente_shared
3
- Version: 0.1.110
3
+ Version: 0.1.112
4
4
  Summary: Shared utilities for Documente AI projects
5
5
  License: MIT
6
6
  Author: Tech
@@ -33,7 +33,7 @@ documente_shared/domain/interfaces/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQe
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
35
  documente_shared/domain/repositories/document.py,sha256=vJzr6c92gqBzyhaEdjrvnoneKRrWmJ0AsvocPnhxiLU,767
36
- documente_shared/domain/repositories/processing_case.py,sha256=QcY0LumRokRLmL3IWkOZTgN-LQ-Kku5_v7DWujO1Dfw,778
36
+ documente_shared/domain/repositories/processing_case.py,sha256=sLmvqj2zAUGellRran9WYXbJjyuEtU56h9rklqkOdzY,852
37
37
  documente_shared/domain/repositories/processing_case_item.py,sha256=uBgJN2fJnZDcKUk018P_Fv25dQRZD5FBxFxsCQNaGAQ,948
38
38
  documente_shared/infrastructure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
39
  documente_shared/infrastructure/documente_client.py,sha256=u6k73yIefuEkCsHULMpVCydFzrSXclf_5oQd2D7CkKU,698
@@ -41,13 +41,13 @@ documente_shared/infrastructure/dynamo_table.py,sha256=TMQbcuty7wjDMbuhI8PbT0IGX
41
41
  documente_shared/infrastructure/lambdas.py,sha256=sGgkw7Mhvuq2TpbW_RNdf5JvQnuzxWYH6gPOVtQ4DtE,357
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
- documente_shared/infrastructure/repositories/dynamo_processing_case.py,sha256=jkTVHThKHshLI53OV7ivK-WchFoAZTnaXlgh_1OX52k,1446
44
+ documente_shared/infrastructure/repositories/dynamo_processing_case.py,sha256=UV4IIJXolCasMUQAXlFJ18qxsCpL2seY5v8ZYMOvFj0,1520
45
45
  documente_shared/infrastructure/repositories/dynamo_processing_case_item.py,sha256=B2ElsASpXNRkwwjdCqXyvDU-LBrLNdwPfHLMvvG9c-Y,1729
46
- documente_shared/infrastructure/repositories/http_document.py,sha256=xDFC4DcVC6FChtkuyKIc5-eRaJlVEXvfWsjslQ_PwaU,2361
47
- documente_shared/infrastructure/repositories/http_processing_case.py,sha256=zBHscJSlsqTLT-NrUT3spfLgS8ZB5Tv9IokCB2Iyvpo,2350
48
- documente_shared/infrastructure/repositories/http_processing_case_item.py,sha256=iKdk7qK7VKJcffrm0WAv3HKUBha1hjDl-ed9N_N4rFc,3180
46
+ documente_shared/infrastructure/repositories/http_document.py,sha256=TQdjKmly1m0L26_ksq9ce0_jv5NxtXvN8AT3Zd06yCE,2289
47
+ documente_shared/infrastructure/repositories/http_processing_case.py,sha256=J9aUgUI1xTysQEbM8K1LepVpzgQU8RlvJn56jVa-l-E,2430
48
+ documente_shared/infrastructure/repositories/http_processing_case_item.py,sha256=rztS_5oE2VDN9LOUATrjCuiKBkxmIwKAakp9AFo8Obc,3185
49
49
  documente_shared/infrastructure/repositories/mem_document.py,sha256=jg4rIjgSZijymjY9o7Q1lLcaiW9h-O8j6XljO1bJI7c,1299
50
- documente_shared/infrastructure/repositories/mem_processing_case.py,sha256=ZAQwp4j0DXQMt92Z-ZR4h9MtbUp9IYy0OHz_sHgkZxY,1147
50
+ documente_shared/infrastructure/repositories/mem_processing_case.py,sha256=WgOPednF0rpz7g9AIUExmRfGSAWRBBgbqH_bg0jp4-c,1190
51
51
  documente_shared/infrastructure/repositories/mem_processing_case_item.py,sha256=kQufzDTouu3agIXpEzRPdjltjTUFExrFbKkAZarGrUg,1419
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
@@ -55,6 +55,6 @@ documente_shared/infrastructure/services/http_scaling.py,sha256=cIo-61nfIwbtO86E
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.110.dist-info/METADATA,sha256=o6kBqCT8Qq-8y5KJYsMJcYZ2nXFtFBDhUJJYuLvJzRY,963
59
- documente_shared-0.1.110.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
60
- documente_shared-0.1.110.dist-info/RECORD,,
58
+ documente_shared-0.1.112.dist-info/METADATA,sha256=kOijsDEs6Frxgtc95ms9lkfn1dxkVIYBa71-qnigBQ4,963
59
+ documente_shared-0.1.112.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
60
+ documente_shared-0.1.112.dist-info/RECORD,,