nedo-vision-worker 1.3.6__py3-none-any.whl → 1.3.8__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.
Files changed (32) hide show
  1. nedo_vision_worker/__init__.py +1 -1
  2. nedo_vision_worker/bootstrap.py +51 -0
  3. nedo_vision_worker/cli.py +43 -192
  4. nedo_vision_worker/config/ConfigurationManager.py +101 -106
  5. nedo_vision_worker/config/ConfigurationManagerInterface.py +12 -0
  6. nedo_vision_worker/config/DummyConfigurationManager.py +52 -0
  7. nedo_vision_worker/protos/AIModelService_pb2_grpc.py +2 -2
  8. nedo_vision_worker/protos/DatasetSourceService_pb2_grpc.py +2 -2
  9. nedo_vision_worker/protos/HumanDetectionService_pb2_grpc.py +2 -2
  10. nedo_vision_worker/protos/PPEDetectionService_pb2_grpc.py +2 -2
  11. nedo_vision_worker/protos/VisionWorkerService_pb2_grpc.py +2 -2
  12. nedo_vision_worker/protos/WorkerSourcePipelineService_pb2_grpc.py +2 -2
  13. nedo_vision_worker/protos/WorkerSourceService_pb2.py +11 -11
  14. nedo_vision_worker/protos/WorkerSourceService_pb2_grpc.py +2 -2
  15. nedo_vision_worker/services/ConnectionInfoClient.py +1 -1
  16. nedo_vision_worker/services/DirectDeviceToRTMPStreamer.py +64 -19
  17. nedo_vision_worker/services/GrpcClientBase.py +1 -0
  18. nedo_vision_worker/services/WorkerSourceClient.py +14 -3
  19. nedo_vision_worker/services/WorkerSourcePipelineClient.py +0 -2
  20. nedo_vision_worker/services/WorkerSourceUpdater.py +0 -4
  21. nedo_vision_worker/util/CorruptedImageValidator.py +55 -0
  22. nedo_vision_worker/worker/DataSenderWorker.py +1 -1
  23. nedo_vision_worker/worker/DatasetFrameWorker.py +4 -6
  24. nedo_vision_worker/worker/RabbitMQListener.py +0 -4
  25. nedo_vision_worker/worker_service.py +13 -96
  26. {nedo_vision_worker-1.3.6.dist-info → nedo_vision_worker-1.3.8.dist-info}/METADATA +2 -1
  27. {nedo_vision_worker-1.3.6.dist-info → nedo_vision_worker-1.3.8.dist-info}/RECORD +30 -28
  28. nedo_vision_worker/initializer/AppInitializer.py +0 -138
  29. nedo_vision_worker/initializer/__init__.py +0 -1
  30. {nedo_vision_worker-1.3.6.dist-info → nedo_vision_worker-1.3.8.dist-info}/WHEEL +0 -0
  31. {nedo_vision_worker-1.3.6.dist-info → nedo_vision_worker-1.3.8.dist-info}/entry_points.txt +0 -0
  32. {nedo_vision_worker-1.3.6.dist-info → nedo_vision_worker-1.3.8.dist-info}/top_level.txt +0 -0
@@ -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.6"
9
+ __version__ = "1.3.8"
10
10
  __all__ = ["WorkerService"]
@@ -0,0 +1,51 @@
1
+ import logging
2
+ from nedo_vision_worker.config.ConfigurationManager import ConfigurationManager
3
+ from nedo_vision_worker.database.DatabaseManager import set_storage_path, DatabaseManager
4
+ from nedo_vision_worker.worker_service import WorkerService
5
+
6
+
7
+ def start_worker(
8
+ *,
9
+ server_host: str,
10
+ server_port: int,
11
+ token: str,
12
+ system_usage_interval: int,
13
+ rtmp_server: str,
14
+ storage_path: str,
15
+ log_level: str = "INFO",
16
+ ) -> WorkerService:
17
+ # Logging (only once, force allowed)
18
+ logging.basicConfig(
19
+ level=getattr(logging, log_level),
20
+ format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
21
+ force=True,
22
+ )
23
+
24
+ logger = logging.getLogger("nedo-worker")
25
+
26
+ # Storage & DB
27
+ set_storage_path(storage_path)
28
+ DatabaseManager.init_databases()
29
+
30
+ # Configuration
31
+ configuration_manager = ConfigurationManager(
32
+ worker_token=token,
33
+ server_host=server_host,
34
+ server_port=server_port,
35
+ rtmp_server_url=rtmp_server,
36
+ logger=logging.getLogger("configuration_manager"),
37
+ )
38
+
39
+ service = WorkerService(
40
+ configuration_manager=configuration_manager,
41
+ server_host=server_host,
42
+ token=token,
43
+ system_usage_interval=system_usage_interval,
44
+ rtmp_server=rtmp_server,
45
+ storage_path=storage_path,
46
+ )
47
+
48
+ logger.info("🚀 Starting Nedo Vision Worker Service")
49
+ service.run()
50
+
51
+ return service
nedo_vision_worker/cli.py CHANGED
@@ -1,224 +1,75 @@
1
1
  import argparse
2
2
  import signal
3
3
  import sys
4
- import traceback
5
4
  import logging
6
5
  from typing import NoReturn
7
6
 
8
- from .worker_service import WorkerService
7
+ from nedo_vision_worker.bootstrap import start_worker
9
8
 
10
9
 
11
10
  class NedoWorkerCLI:
12
- """Main CLI application for Nedo Vision Worker Service."""
13
-
14
11
  def __init__(self):
15
12
  self.logger = logging.getLogger(__name__)
16
13
  self._setup_signal_handlers()
17
-
14
+ self._service = None
15
+
18
16
  def _setup_signal_handlers(self) -> None:
19
- """Set up signal handlers for graceful shutdown."""
20
17
  signal.signal(signal.SIGINT, self._signal_handler)
21
18
  signal.signal(signal.SIGTERM, self._signal_handler)
22
-
19
+
23
20
  def _signal_handler(self, signum: int, frame) -> NoReturn:
24
- """Handle system signals for graceful shutdown."""
25
- self.logger.info(f"Received signal {signum}, shutting down...")
21
+ self.logger.info("🛑 Shutdown signal received")
22
+ if self._service and hasattr(self._service, "stop"):
23
+ self._service.stop()
26
24
  sys.exit(0)
27
-
25
+
28
26
  def create_parser(self) -> argparse.ArgumentParser:
29
- """Create and configure the argument parser."""
30
- parser = argparse.ArgumentParser(
31
- description="Nedo Vision Worker Service",
32
- formatter_class=argparse.RawDescriptionHelpFormatter,
33
- epilog="""
34
- Examples:
35
- # Check system dependencies and requirements
36
- nedo-worker doctor
37
-
38
- # Start worker service
39
- nedo-worker run --token your-token-here
40
-
41
- # Start with custom configuration
42
- nedo-worker run --token your-token-here \\
43
- --rtmp-server rtmp://custom.server.com:1935/live \\
44
- --server-host custom.server.com \\
45
- --storage-path /custom/storage/path
46
- """
47
- )
48
-
49
- parser.add_argument(
50
- "--version",
51
- action="version",
52
- version="nedo-vision-worker 1.2.1"
53
- )
54
-
55
- subparsers = parser.add_subparsers(
56
- dest='command',
57
- help='Available commands',
58
- required=True
59
- )
60
-
61
- self._add_doctor_command(subparsers)
62
- self._add_run_command(subparsers)
63
-
27
+ parser = argparse.ArgumentParser(description="Nedo Vision Worker Service")
28
+
29
+ parser.add_argument("--version", action="version", version="nedo-vision-worker 1.2.1")
30
+
31
+ subparsers = parser.add_subparsers(dest="command", required=True)
32
+
33
+ subparsers.add_parser("doctor", help="Check system dependencies")
34
+
35
+ run = subparsers.add_parser("run", help="Start worker")
36
+
37
+ run.add_argument("--token", required=True)
38
+ run.add_argument("--server-host", default="be.vision.sindika.co.id")
39
+ run.add_argument("--server-port", type=int, default=50051)
40
+ run.add_argument("--rtmp-server", default="rtmp://live.vision.sindika.co.id:1935/live")
41
+ run.add_argument("--storage-path", default="data")
42
+ run.add_argument("--system-usage-interval", type=int, default=30)
43
+ run.add_argument("--log-level", default="INFO")
44
+
64
45
  return parser
65
-
66
- def _add_doctor_command(self, subparsers) -> None:
67
- """Add the doctor command."""
68
- subparsers.add_parser(
69
- 'doctor',
70
- help='Check system dependencies and requirements',
71
- description='Run diagnostic checks for FFmpeg, OpenCV, gRPC and other dependencies'
72
- )
73
-
74
- def _add_run_command(self, subparsers) -> None:
75
- """Add the run command with its arguments."""
76
- run_parser = subparsers.add_parser(
77
- 'run',
78
- help='Start the worker service',
79
- description='Start the Nedo Vision Worker Service'
80
- )
81
-
82
- run_parser.add_argument(
83
- "--token",
84
- required=True,
85
- help="Authentication token for the worker (obtained from frontend)"
86
- )
87
-
88
- run_parser.add_argument(
89
- "--server-host",
90
- default="be.vision.sindika.co.id",
91
- help="Server hostname for communication (default: %(default)s)"
92
- )
93
-
94
- run_parser.add_argument(
95
- "--server-port",
96
- type=int,
97
- default=50051,
98
- help="Server port for gRPC communication (default: %(default)s)"
99
- )
100
-
101
- run_parser.add_argument(
102
- "--rtmp-server",
103
- default="rtmp://live.vision.sindika.co.id:1935/live",
104
- help="RTMP server URL for video streaming (default: %(default)s)"
105
- )
106
-
107
- run_parser.add_argument(
108
- "--storage-path",
109
- default="data",
110
- help="Storage path for databases and files (default: %(default)s)"
111
- )
112
-
113
- run_parser.add_argument(
114
- "--system-usage-interval",
115
- type=int,
116
- default=30,
117
- metavar="SECONDS",
118
- help="System usage reporting interval in seconds (default: %(default)s)"
119
- )
120
-
121
- run_parser.add_argument(
122
- "--log-level",
123
- choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
124
- default="INFO",
125
- help="Set the logging level (default: %(default)s)"
126
- )
127
-
128
- def run_doctor_command(self) -> int:
129
- """Execute the doctor command."""
130
- try:
131
- from .doctor import main as doctor_main
46
+
47
+ def run(self) -> int:
48
+ parser = self.create_parser()
49
+ args = parser.parse_args()
50
+
51
+ if args.command == "doctor":
52
+ from nedo_vision_worker.doctor import main as doctor_main
132
53
  return doctor_main()
133
- except ImportError as e:
134
- self.logger.error(f"Failed to import doctor module: {e}")
135
- return 1
136
- except Exception as e:
137
- self.logger.error(f"Doctor command failed: {e}")
138
- return 1
139
-
140
- def run_worker_service(self, args: argparse.Namespace) -> int:
141
- """Start and run the worker service."""
142
- # Configure logging
143
- logging.basicConfig(
144
- level=getattr(logging, args.log_level),
145
- format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
146
- )
147
-
148
- try:
149
- # Create the worker service
150
- service = WorkerService(
54
+
55
+ if args.command == "run":
56
+ self._service = start_worker(
151
57
  server_host=args.server_host,
58
+ server_port=args.server_port,
152
59
  token=args.token,
153
60
  system_usage_interval=args.system_usage_interval,
154
61
  rtmp_server=args.rtmp_server,
155
62
  storage_path=args.storage_path,
156
- server_port=args.server_port
63
+ log_level=args.log_level,
157
64
  )
158
-
159
- # Log startup information
160
- self._log_startup_info(args)
161
-
162
- # Start the service
163
- service.run()
164
-
165
- # Keep the service running
166
- self._wait_for_service(service)
167
-
168
- return 0
169
-
170
- except KeyboardInterrupt:
171
- self.logger.info("Shutdown requested by user")
172
- return 0
173
- except Exception as e:
174
- self.logger.error(f"Service failed: {e}")
175
- if args.log_level == "DEBUG":
176
- traceback.print_exc()
177
- return 1
178
-
179
- def _log_startup_info(self, args: argparse.Namespace) -> None:
180
- """Log service startup information."""
181
- self.logger.info("🚀 Starting Nedo Vision Worker Service...")
182
- self.logger.info(f"🌐 Server: {args.server_host}")
183
- self.logger.info(f"🔑 Token: {args.token[:8]}{'*' * (len(args.token) - 8)}")
184
- self.logger.info(f"⏱️ System Usage Interval: {args.system_usage_interval}s")
185
- self.logger.info(f"📡 RTMP Server: {args.rtmp_server}")
186
- self.logger.info(f"💾 Storage Path: {args.storage_path}")
187
- self.logger.info("Press Ctrl+C to stop the service")
188
-
189
- def _wait_for_service(self, service: WorkerService) -> None:
190
- """Wait for the service to run and handle shutdown."""
191
- import time
192
-
193
- try:
194
- while getattr(service, 'running', False):
195
- time.sleep(1)
196
- except KeyboardInterrupt:
197
- self.logger.info("🛑 Shutdown requested...")
198
- finally:
199
- if hasattr(service, 'stop'):
200
- service.stop()
201
- self.logger.info("✅ Service stopped successfully")
202
-
203
- def run(self) -> int:
204
- """Main entry point for the CLI application."""
205
- parser = self.create_parser()
206
- args = parser.parse_args()
207
-
208
- if args.command == 'doctor':
209
- return self.run_doctor_command()
210
- elif args.command == 'run':
211
- return self.run_worker_service(args)
212
- else:
213
- parser.print_help()
214
- return 1
65
+ signal.pause() # wait for signal
66
+
67
+ return 0
215
68
 
216
69
 
217
70
  def main() -> int:
218
- """Main CLI entry point."""
219
- cli = NedoWorkerCLI()
220
- return cli.run()
71
+ return NedoWorkerCLI().run()
221
72
 
222
73
 
223
74
  if __name__ == "__main__":
224
- sys.exit(main())
75
+ sys.exit(main())
@@ -1,84 +1,138 @@
1
1
  import logging
2
+ import grpc
3
+ from typing import Optional
2
4
  from ..models.config import ConfigEntity # ORM model for server_config
3
5
  from ..database.DatabaseManager import DatabaseManager # DatabaseManager for managing sessions
4
6
 
7
+ from ..util.HardwareID import HardwareID
8
+ from ..services.ConnectionInfoClient import ConnectionInfoClient
9
+ from .ConfigurationManagerInterface import ConfigurationManagerInterface
5
10
 
6
- class ConfigurationManager:
11
+ class ConfigurationManager(ConfigurationManagerInterface):
7
12
  """
8
- A class to manage server configuration stored in the 'config' database using SQLAlchemy.
13
+ A class to manage local and remote configuration stored in the 'config' database.
9
14
  """
10
15
 
11
- @staticmethod
12
- def init_database():
13
- """
14
- Initialize the 'config' database and create the `server_config` table if it doesn't exist.
15
- """
16
+ def __init__(self, worker_token: str, server_host: str, server_port: int, rtmp_server_url: str, logger: logging.Logger):
16
17
  try:
17
- DatabaseManager.init_databases()
18
+ self._logger = logger
19
+ self._worker_token = worker_token
20
+ self._server_host = server_host
21
+ self._server_port = server_port
22
+ self._rtmp_server_url = rtmp_server_url
23
+
24
+ self._initialize_remote_configuration()
25
+
18
26
  logging.info("✅ [APP] Configuration database initialized successfully.")
19
27
  except Exception as e:
20
28
  logging.exception("❌ [APP] Failed to initialize the configuration database.")
21
29
  raise RuntimeError("Database initialization failed.") from e
22
-
23
- @staticmethod
24
- def is_config_initialized() -> bool:
30
+
31
+ def get_config(self, key: str) -> str:
25
32
  """
26
- Check if the configuration is already initialized.
33
+ Retrieve the value of a specific configuration key from the 'config' database.
34
+
35
+ Args:
36
+ key (str): The configuration key.
27
37
 
28
38
  Returns:
29
- bool: True if configuration exists, False otherwise.
39
+ str: The configuration value, or None if the key does not exist.
30
40
  """
41
+ if not key or not isinstance(key, str):
42
+ raise ValueError("⚠️ The 'key' must be a non-empty string.")
43
+
31
44
  session = None
32
45
  try:
33
46
  session = DatabaseManager.get_session("config")
34
- config_count = session.query(ConfigEntity).count()
35
- return config_count > 0 # True if at least one config exists
47
+ logging.info(f"🔍 [APP] Retrieving configuration key: {key}")
48
+ config = session.query(ConfigEntity).filter_by(key=key).first()
49
+ if config:
50
+ logging.info(f"✅ [APP] Configuration key '{key}' retrieved successfully.")
51
+ return config.value
52
+ else:
53
+ logging.warning(f"⚠️ [APP] Configuration key '{key}' not found.")
54
+ return ""
36
55
  except Exception as e:
37
- logging.exception("❌ [APP] Failed to check if configuration is initialized.")
38
- return False
56
+ logging.exception(f"❌ [APP] Failed to retrieve configuration key '{key}': {e}")
57
+ raise RuntimeError(f"Failed to retrieve configuration key '{key}'") from e
39
58
  finally:
40
59
  if session:
41
60
  session.close()
42
-
43
- @staticmethod
44
- def set_config(key: str, value: str):
61
+
62
+ def get_all_configs(self) -> Optional[dict]:
45
63
  """
46
- Set or update a configuration key-value pair in the 'config' database.
64
+ Retrieve all configuration key-value pairs from the 'config' database.
47
65
 
48
- Args:
49
- key (str): The configuration key.
50
- value (str): The configuration value.
66
+ Returns:
67
+ dict: A dictionary of all configuration key-value pairs.
51
68
  """
52
- if not key or not isinstance(key, str):
53
- raise ValueError("⚠️ [APP] The 'key' must be a non-empty string.")
54
- if not isinstance(value, str):
55
- raise ValueError("⚠️ [APP] The 'value' must be a string.")
56
-
57
69
  session = None
58
70
  try:
59
71
  session = DatabaseManager.get_session("config")
60
- logging.info(f"🔧 Attempting to set configuration: {key} = {value}")
61
- existing_config = session.query(ConfigEntity).filter_by(key=key).first()
62
- if existing_config:
63
- logging.info(f"🔄 [APP] Updating configuration key: {key}")
64
- existing_config.value = value
72
+ logging.info("🔍 [APP] Retrieving all configuration keys.")
73
+ configs = session.query(ConfigEntity).all()
74
+ if configs:
75
+ logging.info(" [APP] All configuration keys retrieved successfully.")
76
+ return {config.key: config.value for config in configs}
65
77
  else:
66
- logging.info(f" [APP] Adding new configuration key: {key}")
67
- new_config = ConfigEntity(key=key, value=value)
68
- session.add(new_config)
69
- session.commit()
70
- logging.info(f"✅ [APP] Configuration key '{key}' set successfully.")
78
+ logging.info("⚠️ [APP] No configuration keys found.")
79
+ return None
71
80
  except Exception as e:
72
- if session:
73
- session.rollback()
74
- logging.exception(f"❌ [APP] Failed to set configuration key '{key}': {e}")
75
- raise RuntimeError(f"Failed to set configuration key '{key}'") from e
81
+ logging.exception("❌ [APP] Failed to retrieve all configuration keys.")
82
+ raise RuntimeError("Failed to retrieve all configuration keys.") from e
76
83
  finally:
77
84
  if session:
78
85
  session.close()
79
86
 
80
- @staticmethod
81
- def set_config_batch(configs: dict):
87
+ def _initialize_remote_configuration(self):
88
+ """
89
+ Initialize the application configuration using the provided token
90
+ and saving configuration data locally.
91
+ """
92
+ try:
93
+ # Get hardware ID
94
+ hardware_id = HardwareID.get_unique_id()
95
+
96
+ self._logger.info(f"🖥️ [APP] Detected Hardware ID: {hardware_id}")
97
+ self._logger.info(f"🌐 [APP] Using Server Host: {self._server_host}")
98
+
99
+ # Check if token is provided
100
+ if not self._worker_token:
101
+ raise ValueError("Token is required for worker initialization. Please provide a token obtained from the frontend.")
102
+
103
+ # Get connection info using the ConnectionInfoClient
104
+ connection_client = ConnectionInfoClient(self._server_host, self._server_port, self._worker_token)
105
+ connection_result = connection_client.get_connection_info()
106
+
107
+ if not connection_result["success"]:
108
+ logging.error(f"Device connection info failed: {connection_result['message']}")
109
+ raise ValueError(f"Initializing remote config failed, reason: {connection_result['message']}")
110
+
111
+ worker_id = connection_result.get('id')
112
+ if not worker_id:
113
+ raise ValueError("No worker_id returned from connection info!")
114
+
115
+ self._set_config_batch({
116
+ "worker_id": worker_id,
117
+ "server_host": self._server_host,
118
+ "rtmp_server": self._rtmp_server_url,
119
+ "server_port": str(self._server_port),
120
+ "token": self._worker_token,
121
+ "rabbitmq_host": connection_result['rabbitmq_host'],
122
+ "rabbitmq_port": str(connection_result['rabbitmq_port']),
123
+ "rabbitmq_username": connection_result['rabbitmq_username'],
124
+ "rabbitmq_password": connection_result['rabbitmq_password']
125
+ })
126
+ self._print_config()
127
+
128
+ except ValueError as ve:
129
+ logging.error(f"Validation error: {ve}")
130
+ except grpc.RpcError as ge:
131
+ logging.error(f"Grpc Error: {ge}")
132
+ except Exception as e:
133
+ logging.error(f"Unexpected error during initialization: {e}")
134
+
135
+ def _set_config_batch(self, configs: dict):
82
136
  """
83
137
  Set or update multiple configuration key-value pairs in the 'config' database in a batch operation.
84
138
 
@@ -116,71 +170,12 @@ class ConfigurationManager:
116
170
  if session:
117
171
  session.close()
118
172
 
119
- @staticmethod
120
- def get_config(key: str) -> str:
121
- """
122
- Retrieve the value of a specific configuration key from the 'config' database.
123
-
124
- Args:
125
- key (str): The configuration key.
126
-
127
- Returns:
128
- str: The configuration value, or None if the key does not exist.
129
- """
130
- if not key or not isinstance(key, str):
131
- raise ValueError("⚠️ The 'key' must be a non-empty string.")
132
-
133
- session = None
134
- try:
135
- session = DatabaseManager.get_session("config")
136
- logging.info(f"🔍 [APP] Retrieving configuration key: {key}")
137
- config = session.query(ConfigEntity).filter_by(key=key).first()
138
- if config:
139
- logging.info(f"✅ [APP] Configuration key '{key}' retrieved successfully.")
140
- return config.value
141
- else:
142
- logging.warning(f"⚠️ [APP] Configuration key '{key}' not found.")
143
- return None
144
- except Exception as e:
145
- logging.exception(f"❌ [APP] Failed to retrieve configuration key '{key}': {e}")
146
- raise RuntimeError(f"Failed to retrieve configuration key '{key}'") from e
147
- finally:
148
- if session:
149
- session.close()
150
-
151
- @staticmethod
152
- def get_all_configs() -> dict:
153
- """
154
- Retrieve all configuration key-value pairs from the 'config' database.
155
-
156
- Returns:
157
- dict: A dictionary of all configuration key-value pairs.
158
- """
159
- session = None
160
- try:
161
- session = DatabaseManager.get_session("config")
162
- logging.info("🔍 [APP] Retrieving all configuration keys.")
163
- configs = session.query(ConfigEntity).all()
164
- if configs:
165
- logging.info("✅ [APP] All configuration keys retrieved successfully.")
166
- return {config.key: config.value for config in configs}
167
- else:
168
- logging.info("⚠️ [APP] No configuration keys found.")
169
- return {}
170
- except Exception as e:
171
- logging.exception("❌ [APP] Failed to retrieve all configuration keys.")
172
- raise RuntimeError("Failed to retrieve all configuration keys.") from e
173
- finally:
174
- if session:
175
- session.close()
176
-
177
- @staticmethod
178
- def print_config():
173
+ def _print_config(self):
179
174
  """
180
175
  Print all configuration key-value pairs to the console.
181
176
  """
182
177
  try:
183
- configs = ConfigurationManager.get_all_configs()
178
+ configs = self.get_all_configs()
184
179
  if configs:
185
180
  print("📄 Current Configuration:")
186
181
  for key, value in configs.items():
@@ -0,0 +1,12 @@
1
+ from typing import Optional
2
+ from abc import ABC, abstractmethod
3
+
4
+
5
+ class ConfigurationManagerInterface(ABC):
6
+ @abstractmethod
7
+ def get_config(self, key: str) -> str:
8
+ pass
9
+
10
+ @abstractmethod
11
+ def get_all_configs(self) -> Optional[dict]:
12
+ pass
@@ -0,0 +1,52 @@
1
+ import logging
2
+ from typing import Optional
3
+
4
+ from .ConfigurationManagerInterface import ConfigurationManagerInterface
5
+
6
+ class DummyConfigurationManager(ConfigurationManagerInterface):
7
+ """
8
+ A class to manage local and remote configuration stored in the 'config' database.
9
+ """
10
+
11
+ def __init__(
12
+ self,
13
+ worker_id: str,
14
+ worker_token: str,
15
+ server_host: str,
16
+ server_port: str,
17
+ rtmp_server_url: str,
18
+ rabbitmq_host: str,
19
+ rabbitmq_port: str,
20
+ rabbitmq_username: str,
21
+ rabbitmq_password: str,
22
+ logger: logging.Logger
23
+ ):
24
+ self._logger = logger
25
+ self._worker_id = worker_id
26
+ self._worker_token = worker_token
27
+ self._server_host = server_host
28
+ self._server_port = server_port
29
+ self._rtmp_server_url = rtmp_server_url
30
+ self._rabbitmq_host = rabbitmq_host
31
+ self._rabbitmq_port = rabbitmq_port
32
+ self._rabbitmq_username = rabbitmq_username
33
+ self._rabbitmq_password = rabbitmq_password
34
+
35
+ self._config = {
36
+ "worker_id": self._worker_id,
37
+ "token": self._worker_token,
38
+ "server_host": self._server_host,
39
+ "server_port": str(self._server_port),
40
+ "rtmp_server": self._rtmp_server_url,
41
+ "rabbitmq_host": self._rabbitmq_host,
42
+ "rabbitmq_port": self._rabbitmq_port,
43
+ "rabbitmq_username": self._rabbitmq_username,
44
+ "rabbitmq_password": self._rabbitmq_password,
45
+ }
46
+
47
+
48
+ def get_config(self, key: str) -> str:
49
+ return self._config[key]
50
+
51
+ def get_all_configs(self) -> Optional[dict]:
52
+ return self._config
@@ -5,7 +5,7 @@ import warnings
5
5
 
6
6
  from nedo_vision_worker.protos import AIModelService_pb2 as nedo__vision__worker_dot_protos_dot_AIModelService__pb2
7
7
 
8
- GRPC_GENERATED_VERSION = '1.74.0'
8
+ GRPC_GENERATED_VERSION = '1.76.0'
9
9
  GRPC_VERSION = grpc.__version__
10
10
  _version_not_supported = False
11
11
 
@@ -18,7 +18,7 @@ except ImportError:
18
18
  if _version_not_supported:
19
19
  raise RuntimeError(
20
20
  f'The grpc package installed is at version {GRPC_VERSION},'
21
- + f' but the generated code in nedo_vision_worker/protos/AIModelService_pb2_grpc.py depends on'
21
+ + ' but the generated code in nedo_vision_worker/protos/AIModelService_pb2_grpc.py depends on'
22
22
  + f' grpcio>={GRPC_GENERATED_VERSION}.'
23
23
  + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
24
24
  + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'