matrice-compute 0.1.33__tar.gz → 0.1.35__tar.gz
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.
- {matrice_compute-0.1.33 → matrice_compute-0.1.35}/PKG-INFO +1 -1
- {matrice_compute-0.1.33 → matrice_compute-0.1.35}/matrice_compute.egg-info/PKG-INFO +1 -1
- {matrice_compute-0.1.33 → matrice_compute-0.1.35}/src/matrice_compute/action_instance.py +73 -9
- matrice_compute-0.1.35/src/matrice_compute/resources_tracker.py +1485 -0
- matrice_compute-0.1.33/src/matrice_compute/resources_tracker.py +0 -842
- {matrice_compute-0.1.33 → matrice_compute-0.1.35}/LICENSE.txt +0 -0
- {matrice_compute-0.1.33 → matrice_compute-0.1.35}/README.md +0 -0
- {matrice_compute-0.1.33 → matrice_compute-0.1.35}/matrice_compute.egg-info/SOURCES.txt +0 -0
- {matrice_compute-0.1.33 → matrice_compute-0.1.35}/matrice_compute.egg-info/dependency_links.txt +0 -0
- {matrice_compute-0.1.33 → matrice_compute-0.1.35}/matrice_compute.egg-info/not-zip-safe +0 -0
- {matrice_compute-0.1.33 → matrice_compute-0.1.35}/matrice_compute.egg-info/top_level.txt +0 -0
- {matrice_compute-0.1.33 → matrice_compute-0.1.35}/pyproject.toml +0 -0
- {matrice_compute-0.1.33 → matrice_compute-0.1.35}/setup.cfg +0 -0
- {matrice_compute-0.1.33 → matrice_compute-0.1.35}/setup.py +0 -0
- {matrice_compute-0.1.33 → matrice_compute-0.1.35}/src/matrice_compute/__init__.py +0 -0
- {matrice_compute-0.1.33 → matrice_compute-0.1.35}/src/matrice_compute/actions_manager.py +0 -0
- {matrice_compute-0.1.33 → matrice_compute-0.1.35}/src/matrice_compute/actions_scaledown_manager.py +0 -0
- {matrice_compute-0.1.33 → matrice_compute-0.1.35}/src/matrice_compute/compute_operations_handler.py +0 -0
- {matrice_compute-0.1.33 → matrice_compute-0.1.35}/src/matrice_compute/instance_manager.py +0 -0
- {matrice_compute-0.1.33 → matrice_compute-0.1.35}/src/matrice_compute/instance_utils.py +0 -0
- {matrice_compute-0.1.33 → matrice_compute-0.1.35}/src/matrice_compute/prechecks.py +0 -0
- {matrice_compute-0.1.33 → matrice_compute-0.1.35}/src/matrice_compute/py.typed +0 -0
- {matrice_compute-0.1.33 → matrice_compute-0.1.35}/src/matrice_compute/scaling.py +0 -0
- {matrice_compute-0.1.33 → matrice_compute-0.1.35}/src/matrice_compute/shutdown_manager.py +0 -0
- {matrice_compute-0.1.33 → matrice_compute-0.1.35}/src/matrice_compute/task_utils.py +0 -0
|
@@ -83,7 +83,8 @@ class ActionInstance:
|
|
|
83
83
|
"inference_ws_server": inference_ws_server_execute,
|
|
84
84
|
"fe_analytics_service": fe_analytics_service_execute,
|
|
85
85
|
"lpr_setup": lpr_setup_execute,
|
|
86
|
-
"inference_tracker_server": inference_tracker_setup_execute
|
|
86
|
+
"inference_tracker_server": inference_tracker_setup_execute,
|
|
87
|
+
"video_storage_setup" : video_storage_setup_execute
|
|
87
88
|
}
|
|
88
89
|
if self.action_type not in self.actions_map:
|
|
89
90
|
raise ValueError(f"Unknown action type: {self.action_type}")
|
|
@@ -309,7 +310,7 @@ class ActionInstance:
|
|
|
309
310
|
)
|
|
310
311
|
|
|
311
312
|
@log_errors(default_return=None, raise_exception=False, log_error=False)
|
|
312
|
-
def
|
|
313
|
+
def get_action_details(self):
|
|
313
314
|
"""Get action details from scaling service.
|
|
314
315
|
|
|
315
316
|
Returns:
|
|
@@ -494,6 +495,10 @@ class ActionInstance:
|
|
|
494
495
|
# Build container name option if provided
|
|
495
496
|
name_option = f"--name {container_name}" if container_name else ""
|
|
496
497
|
|
|
498
|
+
# if the service provider is local, then put --restart unless-stopped
|
|
499
|
+
if os.environ.get("SERVICE_PROVIDER") in ("local", "LOCAL"):
|
|
500
|
+
env_exports += " && export DOCKER_RESTART_POLICY='--restart unless-stopped' "
|
|
501
|
+
|
|
497
502
|
cmd_parts = [
|
|
498
503
|
f"docker run -d {use_gpu} ",
|
|
499
504
|
name_option,
|
|
@@ -1270,7 +1275,7 @@ def database_setup_execute(self: ActionInstance):
|
|
|
1270
1275
|
)
|
|
1271
1276
|
self.docker_container = existing_container_id
|
|
1272
1277
|
cmd = "docker restart " + self.docker_container
|
|
1273
|
-
self.start(cmd, "
|
|
1278
|
+
self.start(cmd, "database_setup")
|
|
1274
1279
|
|
|
1275
1280
|
# qdrant restart
|
|
1276
1281
|
qdrant_cmd = f"docker restart {qdrant_container_name}"
|
|
@@ -1284,11 +1289,15 @@ def database_setup_execute(self: ActionInstance):
|
|
|
1284
1289
|
)
|
|
1285
1290
|
# Fall through to create new containers
|
|
1286
1291
|
|
|
1292
|
+
dbPath = action_details["jobParams"].get("dbPath", "/host/data/path/mongodb_data")
|
|
1293
|
+
|
|
1287
1294
|
# MongoDB container with --net=host (Port: 27020:27017)
|
|
1288
1295
|
cmd = (
|
|
1289
1296
|
f"docker run --pull=always --net=host "
|
|
1290
1297
|
f"--name {mongodb_container_name} "
|
|
1291
1298
|
f"-v matrice_myvol:/matrice_data "
|
|
1299
|
+
f"-v {dbPath}:{dbPath} "
|
|
1300
|
+
f"-v /var/run/docker.sock:/var/run/docker.sock "
|
|
1292
1301
|
f"--cidfile ./{self.action_record_id}.cid "
|
|
1293
1302
|
f"-e ACTION_RECORD_ID={self.action_record_id} "
|
|
1294
1303
|
f"-e MATRICE_ACCESS_KEY_ID={self.matrice_access_key_id} "
|
|
@@ -1297,22 +1306,29 @@ def database_setup_execute(self: ActionInstance):
|
|
|
1297
1306
|
f'-e ENV="{os.environ.get("ENV", "prod")}" '
|
|
1298
1307
|
f"{image} "
|
|
1299
1308
|
)
|
|
1300
|
-
logging.info("Starting
|
|
1309
|
+
logging.info("Starting DB container (Port: 27020:27017): %s", cmd)
|
|
1301
1310
|
|
|
1302
1311
|
# Qdrant container with --net=host (Port: 6334)
|
|
1303
1312
|
qdrant_cmd = (
|
|
1304
|
-
f"docker run --pull=always --net=host "
|
|
1313
|
+
f"docker run -d --pull=always --net=host "
|
|
1305
1314
|
f"--name {qdrant_container_name} "
|
|
1306
1315
|
f"-v matrice_myvol:/matrice_data "
|
|
1307
|
-
f"
|
|
1316
|
+
f"qdrant/qdrant:latest "
|
|
1308
1317
|
)
|
|
1309
1318
|
logging.info("Starting Qdrant container (Port: 6334): %s", qdrant_cmd)
|
|
1310
1319
|
|
|
1320
|
+
# Start Qdrant container
|
|
1321
|
+
qdrant_process = subprocess.Popen(
|
|
1322
|
+
qdrant_cmd,
|
|
1323
|
+
shell=True,
|
|
1324
|
+
stdout=subprocess.PIPE,
|
|
1325
|
+
stderr=subprocess.PIPE,
|
|
1326
|
+
)
|
|
1327
|
+
logging.info("Qdrant container started successfully")
|
|
1328
|
+
|
|
1311
1329
|
# Docker Command run
|
|
1312
1330
|
self.start(cmd, "database_setup")
|
|
1313
1331
|
|
|
1314
|
-
# Docker for qdrant
|
|
1315
|
-
self.start(qdrant_cmd, 'qdrant_setup')
|
|
1316
1332
|
|
|
1317
1333
|
@log_errors(raise_exception=False)
|
|
1318
1334
|
def facial_recognition_setup_execute(self: ActionInstance):
|
|
@@ -1358,6 +1374,7 @@ def facial_recognition_setup_execute(self: ActionInstance):
|
|
|
1358
1374
|
f'-e MATRICE_SECRET_ACCESS_KEY="{self.matrice_secret_access_key}" '
|
|
1359
1375
|
f'-e MATRICE_ACCESS_KEY_ID="{self.matrice_access_key_id}" '
|
|
1360
1376
|
f'-e ACTION_ID="{self.action_record_id}" '
|
|
1377
|
+
f' --restart=unless-stopped '
|
|
1361
1378
|
f"{image}"
|
|
1362
1379
|
)
|
|
1363
1380
|
logging.info("Starting facial recognition worker (Port: 8081): %s", worker_cmd)
|
|
@@ -1410,6 +1427,7 @@ def lpr_setup_execute(self: ActionInstance):
|
|
|
1410
1427
|
f'-e MATRICE_ACCESS_KEY_ID="{self.matrice_access_key_id}" '
|
|
1411
1428
|
f'-e ACTION_ID="{self.action_record_id}" '
|
|
1412
1429
|
f'-e PORT=8082 '
|
|
1430
|
+
f' --restart=unless-stopped '
|
|
1413
1431
|
f"{image}"
|
|
1414
1432
|
)
|
|
1415
1433
|
logging.info("Starting LPR worker (Port: 8082): %s", worker_cmd)
|
|
@@ -1468,6 +1486,7 @@ def inference_ws_server_execute(self: ActionInstance):
|
|
|
1468
1486
|
f'-e ENV="{os.environ.get("ENV", "prod")}" '
|
|
1469
1487
|
f'-e MATRICE_SECRET_ACCESS_KEY="{self.matrice_secret_access_key}" '
|
|
1470
1488
|
f'-e MATRICE_ACCESS_KEY_ID="{self.matrice_access_key_id}" '
|
|
1489
|
+
f' --restart=unless-stopped '
|
|
1471
1490
|
f"{image} "
|
|
1472
1491
|
f"./app "
|
|
1473
1492
|
f"{self.action_record_id} "
|
|
@@ -1529,6 +1548,7 @@ def fe_fs_streaming_execute(self: ActionInstance):
|
|
|
1529
1548
|
f'-e MATRICE_ACCESS_KEY_ID="{self.matrice_access_key_id}" '
|
|
1530
1549
|
f"-e PORT=3000 "
|
|
1531
1550
|
f'-e WS_HOST="{ws_url}" '
|
|
1551
|
+
f' --restart=unless-stopped '
|
|
1532
1552
|
f"{image}"
|
|
1533
1553
|
)
|
|
1534
1554
|
logging.info("Starting frontend streaming (Port: 3000) with WS_HOST=%s: %s", ws_url, worker_cmd)
|
|
@@ -1584,6 +1604,7 @@ def fe_analytics_service_execute(self: ActionInstance):
|
|
|
1584
1604
|
f'-e ACTION_ID="{self.action_record_id}" '
|
|
1585
1605
|
f"-e PORT=3001 "
|
|
1586
1606
|
f'-e PROJECT_ID="{project_id}" '
|
|
1607
|
+
f' --restart=unless-stopped '
|
|
1587
1608
|
f"{image}"
|
|
1588
1609
|
)
|
|
1589
1610
|
logging.info("Starting frontend analytics service (Port: 3001): %s", worker_cmd)
|
|
@@ -2193,7 +2214,50 @@ def inference_tracker_setup_execute(self: ActionInstance):
|
|
|
2193
2214
|
f'-e MATRICE_SECRET_ACCESS_KEY="{self.matrice_secret_access_key}" '
|
|
2194
2215
|
f'-e MATRICE_ACCESS_KEY_ID="{self.matrice_access_key_id}" '
|
|
2195
2216
|
f'-e ACTION_ID="{self.action_record_id}" '
|
|
2217
|
+
f' --restart=unless-stopped '
|
|
2218
|
+
f"{image}"
|
|
2219
|
+
)
|
|
2220
|
+
|
|
2221
|
+
self.start(worker_cmd, "inference_tracker_setup")
|
|
2222
|
+
|
|
2223
|
+
@log_errors(raise_exception=False)
|
|
2224
|
+
def video_storage_setup_execute(self: ActionInstance):
|
|
2225
|
+
|
|
2226
|
+
"""
|
|
2227
|
+
Creates and start Video Storage
|
|
2228
|
+
Video Stroage runs on port 8106 (localhost only with --net=host).
|
|
2229
|
+
"""
|
|
2230
|
+
|
|
2231
|
+
action_details = self.get_action_details()
|
|
2232
|
+
if not action_details:
|
|
2233
|
+
return
|
|
2234
|
+
|
|
2235
|
+
image = self.docker_container
|
|
2236
|
+
|
|
2237
|
+
self.setup_action_requirements(action_details)
|
|
2238
|
+
|
|
2239
|
+
if action_details["actionDetails"].get("containerId"):
|
|
2240
|
+
logging.info(
|
|
2241
|
+
"Using existing container ID for inference tracker: %s",
|
|
2242
|
+
action_details["actionDetails"]["containerId"],
|
|
2243
|
+
)
|
|
2244
|
+
self.docker_container = action_details["actionDetails"]["containerId"]
|
|
2245
|
+
cmd = "docker restart " + self.docker_container
|
|
2246
|
+
self.start(cmd, "video_storage_setup_execute")
|
|
2247
|
+
return
|
|
2248
|
+
|
|
2249
|
+
# This is the existing Docker run command
|
|
2250
|
+
worker_cmd = (
|
|
2251
|
+
f"docker run -d --pull=always --net=host "
|
|
2252
|
+
f"--cidfile ./{self.action_record_id}.cid "
|
|
2253
|
+
f"--name media_server "
|
|
2254
|
+
f"-v matrice_myvol:/matrice_data "
|
|
2255
|
+
f'-e ENV="{os.environ.get("ENV", "prod")}" '
|
|
2256
|
+
f'-e MATRICE_SECRET_ACCESS_KEY="{self.matrice_secret_access_key}" '
|
|
2257
|
+
f'-e MATRICE_ACCESS_KEY_ID="{self.matrice_access_key_id}" '
|
|
2258
|
+
f'-e ACTION_ID="{self.action_record_id}" '
|
|
2259
|
+
f'--restart=unless-stopped '
|
|
2196
2260
|
f"{image}"
|
|
2197
2261
|
)
|
|
2198
2262
|
|
|
2199
|
-
self.start(worker_cmd, "
|
|
2263
|
+
self.start(worker_cmd, "video_storage_setup_execute")
|