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

File without changes
@@ -0,0 +1,7 @@
1
+ import hashlib
2
+
3
+
4
+ def get_file_digest(file_bytes: bytes) -> str:
5
+ sha256_hash = hashlib.sha256()
6
+ sha256_hash.update(file_bytes)
7
+ return sha256_hash.hexdigest()
@@ -3,7 +3,11 @@ from datetime import datetime
3
3
  from decimal import Decimal
4
4
  from typing import Optional
5
5
 
6
- from documente_shared.domain.enums import DocumentProcessStatus
6
+ from documente_shared.domain.enums import (
7
+ DocumentProcessStatus,
8
+ DocumentProcessSubCategory,
9
+ DocumentProcessCategory,
10
+ )
7
11
 
8
12
 
9
13
  @dataclass
@@ -11,13 +15,16 @@ class DocumentProcess(object):
11
15
  digest: str
12
16
  status: DocumentProcessStatus
13
17
  file_path: str
18
+ category: Optional[DocumentProcessCategory] = None
19
+ sub_category: Optional[DocumentProcessSubCategory] = None
14
20
  processed_csv_path: Optional[str] = None
15
21
  processed_xlsx_path: Optional[str] = None
16
22
  processing_time: Optional[Decimal] = None
23
+ uploded_at: Optional[datetime] = None
17
24
  enqueued_at: Optional[datetime] = None
18
25
  started_at: Optional[datetime] = None
19
26
  failed_at: Optional[datetime] = None
20
- processed_at: Optional[datetime] = None
27
+ completed_at: Optional[datetime] = None
21
28
 
22
29
  @property
23
30
  def is_pending(self) -> bool:
@@ -61,7 +68,7 @@ class DocumentProcess(object):
61
68
 
62
69
  def completed(self):
63
70
  self.status = DocumentProcessStatus.COMPLETED
64
- self.processed_at = datetime.now()
71
+ self.completed_at = datetime.now()
65
72
 
66
73
  def deleted(self):
67
74
  self.status = DocumentProcessStatus.DELETED
@@ -77,16 +84,25 @@ class DocumentProcess(object):
77
84
  'digest': self.digest,
78
85
  'status': self.status.value,
79
86
  'file_path': self.file_path,
87
+ 'category': (
88
+ str(self.category)
89
+ if self.category else None
90
+ ),
91
+ 'sub_category': (
92
+ str(self.sub_category)
93
+ if self.sub_category else None
94
+ ),
80
95
  'processed_csv_path': self.processed_csv_path,
81
96
  'processed_xlsx_path': self.processed_xlsx_path,
82
97
  'processing_time': (
83
98
  str(self.processing_time)
84
99
  if self.processing_time else None
85
100
  ),
101
+ 'uploded_at': self.uploded_at.isoformat() if self.uploded_at else None,
86
102
  'enqueued_at': self.enqueued_at.isoformat() if self.enqueued_at else None,
87
103
  'started_at': self.started_at.isoformat() if self.started_at else None,
88
104
  'failed_at': self.failed_at.isoformat() if self.failed_at else None,
89
- 'processed_at': self.processed_at.isoformat() if self.processed_at else None,
105
+ 'completed_at': self.completed_at.isoformat() if self.completed_at else None,
90
106
  }
91
107
 
92
108
  @classmethod
@@ -95,12 +111,24 @@ class DocumentProcess(object):
95
111
  digest=data.get('digest'),
96
112
  status=DocumentProcessStatus.from_value(data.get('status')),
97
113
  file_path=data.get('file_path'),
114
+ category=(
115
+ DocumentProcessCategory.from_value(data.get('category'))
116
+ if data.get('category') else None
117
+ ),
118
+ sub_category=(
119
+ DocumentProcessSubCategory.from_value(data.get('sub_category'))
120
+ if data.get('sub_category') else None
121
+ ),
98
122
  processed_csv_path=data.get('processed_csv_path'),
99
123
  processed_xlsx_path=data.get('processed_xlsx_path'),
100
124
  processing_time=(
101
125
  Decimal(data.get('processing_time'))
102
126
  if data.get('processing_time') else None
103
127
  ),
128
+ uploded_at=(
129
+ datetime.fromisoformat(data.get('uploded_at'))
130
+ if data.get('uploded_at') else None
131
+ ),
104
132
  enqueued_at=(
105
133
  datetime.fromisoformat(data.get('enqueued_at'))
106
134
  if data.get('enqueued_at') else None
@@ -113,8 +141,8 @@ class DocumentProcess(object):
113
141
  datetime.fromisoformat(data.get('failed_at'))
114
142
  if data.get('failed_at') else None
115
143
  ),
116
- processed_at=(
117
- datetime.fromisoformat(data.get('processed_at'))
144
+ completed_at=(
145
+ datetime.fromisoformat(data.get('completed_at'))
118
146
  if data.get('processed_at') else None
119
147
  ),
120
148
  )
@@ -9,3 +9,13 @@ class DocumentProcessStatus(BaseEnum):
9
9
  FAILED = 'FAILED'
10
10
  DELETED = 'DELETED'
11
11
 
12
+
13
+ class DocumentProcessCategory(BaseEnum):
14
+ CIRCULAR = 'CIRCULAR'
15
+
16
+
17
+ class DocumentProcessSubCategory(BaseEnum):
18
+ CC_COMBINADA = 'CC_COMBINADA'
19
+ CC_NORMATIVA = 'CC_NORMATIVA'
20
+
21
+
@@ -1,10 +1,15 @@
1
1
  from abc import ABC, abstractmethod
2
2
 
3
3
  from documente_shared.domain.entities import DocumentProcess
4
+ from python_layer.python.typing_extensions import Optional
4
5
 
5
6
 
6
7
  class DocumentProcessRepository(ABC):
7
8
 
9
+ @abstractmethod
10
+ def find(self, digest: str) ->Optional[DocumentProcess]:
11
+ raise NotImplementedError
12
+
8
13
  @abstractmethod
9
14
  def persist(self, instance: DocumentProcess) -> DocumentProcess:
10
15
  raise NotImplementedError
@@ -1,12 +1,18 @@
1
1
  from documente_shared.domain.entities import DocumentProcess
2
2
  from documente_shared.domain.repositories import DocumentProcessRepository
3
3
  from documente_shared.infrastructure.dynamo_table import DynamoDBTable
4
+ from python_layer.python.typing_extensions import Optional
4
5
 
5
6
 
6
7
  class DynamoDocumentProcessRepository(
7
8
  DynamoDBTable,
8
9
  DocumentProcessRepository,
9
10
  ):
11
+ def find(self, digest: str) -> Optional[DocumentProcess]:
12
+ item = self.get(key=digest)
13
+ if item:
14
+ return DocumentProcess.from_dict(item)
15
+ return None
10
16
 
11
17
  def persist(self, instance: DocumentProcess) -> DocumentProcess:
12
18
  self.put(instance.to_dict)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: documente_shared
3
- Version: 0.1.14
3
+ Version: 0.1.16
4
4
  Summary: Shared utilities for Documente AI projects
5
5
  License: MIT
6
6
  Author: Tech
@@ -0,0 +1,16 @@
1
+ documente_shared/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ documente_shared/application/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ documente_shared/application/digest.py,sha256=Um6E8WfFri2_lly4RFWydJyvSfPZGFcOX-opEOzDCWc,172
4
+ documente_shared/domain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ documente_shared/domain/base_enum.py,sha256=DojAfn-zQdtjtImeHUpBzE6TBTm07XrbMOdW3h8RVd8,1449
6
+ documente_shared/domain/entities.py,sha256=gDXhFuTEMH4M3HGR0TwPk11qwz9blZPSEdTLKeU5i7o,5052
7
+ documente_shared/domain/enums.py,sha256=wrMpM-1KgXFkd-He-3onNcqR3Zf53Q-_axjXGjx7MIY,435
8
+ documente_shared/domain/repositories.py,sha256=OJ6HKYx93RAHtj5M2uMk1P8cPdw7ubfhs1GMeUT_blU,540
9
+ documente_shared/infrastructure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ documente_shared/infrastructure/dynamo_repositories.py,sha256=0bnDxw-fQglpXXg5E4p0wyIbLn4gUy6nbusosveXpyU,777
11
+ documente_shared/infrastructure/dynamo_table.py,sha256=5yF5EVQkHTZe4tLYZsfEDS8tp_iorMlMjNu-qn3Oj9E,2095
12
+ documente_shared/infrastructure/s3_bucket.py,sha256=s4VWcl0HK6uhjjZmKefOYW5A3Dx74R9KCuMmXQKUXnQ,1582
13
+ documente_shared/infrastructure/sqs_queue.py,sha256=PSiTAnjXvQ-W-9mzLpH2UjbQJTvYkMiaxNaMecF-cR4,1505
14
+ documente_shared-0.1.16.dist-info/METADATA,sha256=skZ3CFocB7w-KTNk-0qJRUJZbHidRhi3DYtuBCy6pr4,640
15
+ documente_shared-0.1.16.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
16
+ documente_shared-0.1.16.dist-info/RECORD,,
@@ -1,14 +0,0 @@
1
- documente_shared/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- documente_shared/domain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- documente_shared/domain/base_enum.py,sha256=DojAfn-zQdtjtImeHUpBzE6TBTm07XrbMOdW3h8RVd8,1449
4
- documente_shared/domain/entities.py,sha256=1TFf8OcZwNmwqCFwIfI-U4QzJHpeDJ-z88gKzhGQR0s,3997
5
- documente_shared/domain/enums.py,sha256=o20YJClja9FQbbZhdfreGCWYwjd3AH7q2kIzV9wn2dw,251
6
- documente_shared/domain/repositories.py,sha256=h_nArptP5Xh7Jrhden-Ii9rZQqzgLFHhuzj1p78LgmU,365
7
- documente_shared/infrastructure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- documente_shared/infrastructure/dynamo_repositories.py,sha256=9t_ufQBSF7cJbeHYzfJABOQydj1HAvhI8UnqDEDPryA,532
9
- documente_shared/infrastructure/dynamo_table.py,sha256=5yF5EVQkHTZe4tLYZsfEDS8tp_iorMlMjNu-qn3Oj9E,2095
10
- documente_shared/infrastructure/s3_bucket.py,sha256=s4VWcl0HK6uhjjZmKefOYW5A3Dx74R9KCuMmXQKUXnQ,1582
11
- documente_shared/infrastructure/sqs_queue.py,sha256=PSiTAnjXvQ-W-9mzLpH2UjbQJTvYkMiaxNaMecF-cR4,1505
12
- documente_shared-0.1.14.dist-info/METADATA,sha256=gAxsMatjQ7SsuaOZ_TjJ_fmqhVBCaAhKOxHKoemuCcE,640
13
- documente_shared-0.1.14.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
14
- documente_shared-0.1.14.dist-info/RECORD,,