nedo-vision-worker 1.3.3__py3-none-any.whl → 1.3.6__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.
@@ -6,5 +6,5 @@ A library for running worker agents in the Nedo Vision platform.
6
6
 
7
7
  from .worker_service import WorkerService
8
8
 
9
- __version__ = "1.3.3"
9
+ __version__ = "1.3.6"
10
10
  __all__ = ["WorkerService"]
@@ -2,7 +2,7 @@ import os
2
2
  import logging
3
3
  from pathlib import Path
4
4
  from sqlalchemy.orm import Session, joinedload
5
- from sqlalchemy import asc
5
+ from sqlalchemy import desc
6
6
  from sqlalchemy.exc import SQLAlchemyError
7
7
  from ..database.DatabaseManager import DatabaseManager, get_storage_path
8
8
  from ..models.ppe_detection import PPEDetectionEntity
@@ -33,7 +33,7 @@ class PPEDetectionRepository:
33
33
  latest_detections = (
34
34
  self.session.query(PPEDetectionEntity)
35
35
  .options(joinedload(PPEDetectionEntity.ppe_labels))
36
- .order_by(asc(PPEDetectionEntity.created_at))
36
+ .order_by(desc(PPEDetectionEntity.created_at))
37
37
  .limit(limit)
38
38
  .all()
39
39
  )
@@ -2,7 +2,7 @@ import os
2
2
  import logging
3
3
  from pathlib import Path
4
4
  from sqlalchemy.orm import Session
5
- from sqlalchemy import asc
5
+ from sqlalchemy import desc
6
6
  from sqlalchemy.exc import SQLAlchemyError
7
7
  from ..database.DatabaseManager import DatabaseManager, get_storage_path
8
8
  from ..models.restricted_area_violation import RestrictedAreaViolationEntity
@@ -29,7 +29,7 @@ class RestrictedAreaRepository:
29
29
  try:
30
30
  latest_violations = (
31
31
  self.session.query(RestrictedAreaViolationEntity)
32
- .order_by(asc(RestrictedAreaViolationEntity.created_at))
32
+ .order_by(desc(RestrictedAreaViolationEntity.created_at))
33
33
  .limit(limit)
34
34
  .all()
35
35
  )
@@ -152,28 +152,17 @@ class DataSenderWorker:
152
152
 
153
153
  def _calculate_sleep_interval(self, ppe_pending: int, violation_pending: int) -> float:
154
154
  """
155
- Calculate optimal sleep interval based on pending data.
156
- Conservative approach to prevent server overload.
155
+ Returns fixed sleep interval to prevent storage rate limits.
157
156
 
158
157
  Args:
159
158
  ppe_pending: Number of pending PPE detections
160
159
  violation_pending: Number of pending violations
161
160
 
162
161
  Returns:
163
- float: Sleep interval in seconds
162
+ float: Sleep interval in seconds (fixed at 5s)
164
163
  """
165
- total_pending = ppe_pending + violation_pending
166
-
167
- if total_pending == 0:
168
- return self.send_interval
169
- elif total_pending < 50:
170
- return self.send_interval
171
- elif total_pending < 200:
172
- return 3.0
173
- elif total_pending < 500:
174
- return 2.0
175
- else:
176
- return 1.5
164
+ # Fixed 5 second interval to respect storage rate limits
165
+ return self.send_interval
177
166
 
178
167
  def _run_worker_source_updater(self):
179
168
  """Dedicated loop for updating worker sources at a different interval."""
@@ -51,25 +51,6 @@ class PPEDetectionManager:
51
51
 
52
52
  logger.info("📡 [APP] PPE detection monitoring started.")
53
53
 
54
- def _calculate_fetch_size(self, pending_count: int) -> int:
55
- """
56
- Dynamically calculates how many records to fetch based on pending count.
57
-
58
- Args:
59
- pending_count (int): Number of pending detections
60
-
61
- Returns:
62
- int: Number of records to fetch
63
- """
64
- if pending_count <= 50:
65
- return min(pending_count, 10)
66
- elif pending_count <= 200:
67
- return min(pending_count, 30)
68
- elif pending_count <= 1000:
69
- return min(pending_count, 50)
70
- else:
71
- return min(pending_count, 100)
72
-
73
54
  def _calculate_batch_by_size(self, all_detections: list, max_size_mb: int = 40) -> list:
74
55
  """
75
56
  Calculates batch based on actual image file sizes to stay within gRPC limit.
@@ -110,15 +91,15 @@ class PPEDetectionManager:
110
91
  return batch
111
92
 
112
93
  def send_ppe_detection_batch(self):
113
- """Sends a batch of collected PPE detection data to the server with dynamic size-based batching."""
94
+ """Sends a batch of collected PPE detection data to the server with fixed 5 detection batch size."""
114
95
  try:
115
96
  pending_count = self.ppe_detection_repo.get_total_pending_count()
116
97
 
117
98
  if pending_count == 0:
118
99
  return
119
100
 
120
- fetch_size = self._calculate_fetch_size(pending_count)
121
- all_detections = self.ppe_detection_repo.get_latest_detections(fetch_size)
101
+ # Fixed batch size of 5 to prevent storage rate limits
102
+ all_detections = self.ppe_detection_repo.get_latest_detections(5)
122
103
 
123
104
  if not all_detections:
124
105
  return
@@ -51,25 +51,6 @@ class RestrictedAreaManager:
51
51
 
52
52
  logger.info("📡 [APP] Restricted area violation monitoring started.")
53
53
 
54
- def _calculate_fetch_size(self, pending_count: int) -> int:
55
- """
56
- Dynamically calculates how many records to fetch based on pending count.
57
-
58
- Args:
59
- pending_count (int): Number of pending violations
60
-
61
- Returns:
62
- int: Number of records to fetch
63
- """
64
- if pending_count <= 50:
65
- return min(pending_count, 10)
66
- elif pending_count <= 200:
67
- return min(pending_count, 30)
68
- elif pending_count <= 1000:
69
- return min(pending_count, 50)
70
- else:
71
- return min(pending_count, 100)
72
-
73
54
  def _calculate_batch_by_size(self, all_violations: list, max_size_mb: int = 40) -> list:
74
55
  """
75
56
  Calculates batch based on actual image file sizes to stay within gRPC limit.
@@ -108,15 +89,15 @@ class RestrictedAreaManager:
108
89
  return batch
109
90
 
110
91
  def send_violation_batch(self):
111
- """Sends a batch of collected violation data to the server with dynamic size-based batching."""
92
+ """Sends a batch of collected violation data to the server with fixed 5 violation batch size."""
112
93
  try:
113
94
  pending_count = self.repo.get_total_pending_count()
114
95
 
115
96
  if pending_count == 0:
116
97
  return
117
98
 
118
- fetch_size = self._calculate_fetch_size(pending_count)
119
- all_violations = self.repo.get_latest_violations(fetch_size)
99
+ # Fixed batch size of 5 to prevent storage rate limits
100
+ all_violations = self.repo.get_latest_violations(5)
120
101
 
121
102
  if not all_violations:
122
103
  return
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nedo-vision-worker
3
- Version: 1.3.3
3
+ Version: 1.3.6
4
4
  Summary: Nedo Vision Worker Service Library for AI Vision Processing
5
5
  Author-email: Willy Achmat Fauzi <willy.achmat@gmail.com>
6
6
  Maintainer-email: Willy Achmat Fauzi <willy.achmat@gmail.com>
@@ -1,4 +1,4 @@
1
- nedo_vision_worker/__init__.py,sha256=mruTFM9bN3wUaU6J78iDRbVibwSTdSYqqoPcPYr4094,203
1
+ nedo_vision_worker/__init__.py,sha256=_g6zmNHn0tjdnmSRMJzHoj7sw2hYWxnkRUYNQz3AO4E,203
2
2
  nedo_vision_worker/cli.py,sha256=ddWspJmSgVkcUYvRdkvTtMNuMTDvNCqLLuMVU9KE3Ik,7457
3
3
  nedo_vision_worker/doctor.py,sha256=wNkpe8gLVd76Y_ViyK2h1ZFdqeSl37MnzZN5frWKu30,48410
4
4
  nedo_vision_worker/worker_service.py,sha256=9zz8hKwDwqwpfS0KPQfftGJtRci0uj_wiwcr_TGf-E0,11039
@@ -40,8 +40,8 @@ nedo_vision_worker/protos/WorkerSourceService_pb2_grpc.py,sha256=23Zj3WSogfhmp_Y
40
40
  nedo_vision_worker/protos/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
41
41
  nedo_vision_worker/repositories/AIModelRepository.py,sha256=35cQ2EnJvMdArewumPrVIaiwueGy6cXU_g5J1Qcj6_Y,1415
42
42
  nedo_vision_worker/repositories/DatasetSourceRepository.py,sha256=MOUbXY1-7WUPhY15aMpdXl6rl0afSvu3Cq8jNtp9nzM,8595
43
- nedo_vision_worker/repositories/PPEDetectionRepository.py,sha256=WYPrmMs3wSsaALR4ixsgMNOUbHbmYDGPbjMQdjSnIE4,6161
44
- nedo_vision_worker/repositories/RestrictedAreaRepository.py,sha256=nk8DV5dkBfAm2AT8wY9la6yv6Q7pFi00YXLbvofqNkc,5158
43
+ nedo_vision_worker/repositories/PPEDetectionRepository.py,sha256=Vsj0H6Ztw1LXqQq-i5O_CSRXTAlz6oRlfPkHIJFel4w,6163
44
+ nedo_vision_worker/repositories/RestrictedAreaRepository.py,sha256=SoXX5MmoNM0o34YUnjLCjnwOH9olsuDQRcDeZk1nn6E,5160
45
45
  nedo_vision_worker/repositories/WorkerSourcePipelineDebugRepository.py,sha256=kOlVEnPOoDRZdZIm8uWXlc89GMvBPI-36QyKecX7ucE,3350
46
46
  nedo_vision_worker/repositories/WorkerSourcePipelineDetectionRepository.py,sha256=cbgg_7p0eNUIgCHoPDZBaRZ1b2Y68p_dfSxpvuGMtRE,1773
47
47
  nedo_vision_worker/repositories/WorkerSourcePipelineRepository.py,sha256=xfmEvgnyt-DdfSApGyFfy0H0dXjFFkjeo4LMr0fVFXU,10053
@@ -80,22 +80,22 @@ nedo_vision_worker/util/SystemMonitor.py,sha256=2kkqj9mOlywAS2fHdN1TaIXSXvCApcIH
80
80
  nedo_vision_worker/util/VideoProbeUtil.py,sha256=cF-vJ7hIDlXfEJby2a0s9tqwkPGVz_6B3Vv4D5pMmIw,12876
81
81
  nedo_vision_worker/util/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
82
82
  nedo_vision_worker/worker/CoreActionWorker.py,sha256=lb7zPY3yui6I3F4rX4Ii7JwpWZahLEO72rh3iWOgFmg,5441
83
- nedo_vision_worker/worker/DataSenderWorker.py,sha256=BNA5mL2guBVp0O5MKULEWd78dY32YjiyWZX7ECFjVFc,9089
83
+ nedo_vision_worker/worker/DataSenderWorker.py,sha256=Z1jJKqA5Z1gpLkqttnMOh81JyMD1zTG_EbdsCUJVKI0,8793
84
84
  nedo_vision_worker/worker/DataSyncWorker.py,sha256=LmDPt2J1frmXwuR46L6b0MjlFOHfgG-4_0MGQa78zF4,6288
85
85
  nedo_vision_worker/worker/DatasetFrameSender.py,sha256=1SFYj8LJFNi-anBTapsbq8U_NGMM7mnoMKg9NeFAHys,8087
86
86
  nedo_vision_worker/worker/DatasetFrameWorker.py,sha256=Hh_wZuMjwovxsEKFqXSuTRin9eYRBZCbcFKm3CKLMbE,19335
87
- nedo_vision_worker/worker/PPEDetectionManager.py,sha256=7KwAsI1_dwUDBCdDeSDRrr5hS0002dK0vVyLclkphDk,6686
87
+ nedo_vision_worker/worker/PPEDetectionManager.py,sha256=sXeOjvhCzi4oUhDZwH5-8DSxI9b__Jp0de8QksgaYGw,6063
88
88
  nedo_vision_worker/worker/PipelineActionWorker.py,sha256=xgvryjKtEsMj4BKqWzDIaK_lFny-DfMCj5Y2DxHnWww,5651
89
89
  nedo_vision_worker/worker/PipelineImageWorker.py,sha256=J8VBUG0cwcH3qOJp2zTl30B-XhmPFyvJLjxitKJYq0E,5642
90
90
  nedo_vision_worker/worker/PipelinePreviewWorker.py,sha256=owFiBbktcOZkdImQeykZSeBIR2-mpt6HNkmYIkLRKzE,6397
91
91
  nedo_vision_worker/worker/RabbitMQListener.py,sha256=9gR49MDplgpyb-D5HOH0K77-DJQFvhS2E7biL92SjSU,6950
92
- nedo_vision_worker/worker/RestrictedAreaManager.py,sha256=_OALBwum09tHjrh14qDK7AQ-9l0xJoGolYAemH5tryM,6550
92
+ nedo_vision_worker/worker/RestrictedAreaManager.py,sha256=Pz2M9KPSMa1QPXZeYhyN9ih4eX6wmkNS_ZPu5KrvNxY,5927
93
93
  nedo_vision_worker/worker/SystemUsageManager.py,sha256=mkh4sT-HkIEY1CJHMEG6LP9ATu39YXvLRLyf995OkoQ,5315
94
94
  nedo_vision_worker/worker/VideoStreamWorker.py,sha256=5n6v1PNO7IB-jj_McALLkUP-cBjJoIEw4UiSAs3vTb0,7606
95
95
  nedo_vision_worker/worker/WorkerManager.py,sha256=2bxXi19fp3p1qjYBStYRdVVgko8dnevXx1_M_sqH5og,5521
96
96
  nedo_vision_worker/worker/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
97
- nedo_vision_worker-1.3.3.dist-info/METADATA,sha256=kZDc0x5Wbvi4MzF12blE6-jzr_WEl-k75tjwORMQTDY,14728
98
- nedo_vision_worker-1.3.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
99
- nedo_vision_worker-1.3.3.dist-info/entry_points.txt,sha256=LrglS-8nCi8C_PL_pa6uxdgCe879hBETHDVXAckvs-8,60
100
- nedo_vision_worker-1.3.3.dist-info/top_level.txt,sha256=vgilhlkyD34YsEKkaBabmhIpcKSvF3XpzD2By68L-XI,19
101
- nedo_vision_worker-1.3.3.dist-info/RECORD,,
97
+ nedo_vision_worker-1.3.6.dist-info/METADATA,sha256=vcU6h0ZLPZD45KaGWde06KJ-YsUO39Ar2bXb_iq1Ups,14728
98
+ nedo_vision_worker-1.3.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
99
+ nedo_vision_worker-1.3.6.dist-info/entry_points.txt,sha256=LrglS-8nCi8C_PL_pa6uxdgCe879hBETHDVXAckvs-8,60
100
+ nedo_vision_worker-1.3.6.dist-info/top_level.txt,sha256=vgilhlkyD34YsEKkaBabmhIpcKSvF3XpzD2By68L-XI,19
101
+ nedo_vision_worker-1.3.6.dist-info/RECORD,,