matrice-compute 0.1.15__py3-none-any.whl → 0.1.17__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.
@@ -75,7 +75,10 @@ class ActionInstance:
75
75
  "facial_recognition_setup": facial_recognition_setup_execute,
76
76
  "fe_fs_streaming": fe_fs_streaming_execute,
77
77
  "inference_ws_server": inference_ws_server_execute,
78
- "lpr_setup": lpr_setup_execute
78
+ "lpr_setup": lpr_setup_execute,
79
+ "fe_analytics_service": fe_analytics_service_execute,
80
+ "lpr_setup": lpr_setup_execute,
81
+ "tracker_server": inference_tracker_setup_execute
79
82
  }
80
83
  if self.action_type not in self.actions_map:
81
84
  raise ValueError(f"Unknown action type: {self.action_type}")
@@ -471,11 +474,12 @@ class ActionInstance:
471
474
  # Try to get model codebase URLs from action_details first
472
475
  model_codebase_url = job_params.get("model_codebase_url")
473
476
  model_requirements_url = job_params.get("model_requirements_url")
477
+ dockerId = job_params.get("_idDocker")
474
478
 
475
479
  # Fallback to API calls if not provided in action_details
476
480
  if not model_codebase_url:
477
481
  model_codebase_url, error, message = self.scaling.get_model_codebase(
478
- model_family
482
+ dockerId
479
483
  )
480
484
  if error:
481
485
  logging.warning(f"Failed to get model codebase URL: {message}")
@@ -486,7 +490,7 @@ class ActionInstance:
486
490
  model_codebase_requirements_url = model_requirements_url
487
491
  else:
488
492
  model_codebase_requirements_url, error, message = (
489
- self.scaling.get_model_codebase_requirements(model_family)
493
+ self.scaling.get_model_codebase_requirements(dockerId)
490
494
  )
491
495
  if error:
492
496
  logging.warning(
@@ -1034,6 +1038,8 @@ def augmentation_server_creation_execute(
1034
1038
  def database_setup_execute(self: ActionInstance):
1035
1039
  """
1036
1040
  Creates and setup the database for facial recognition server.
1041
+ MongoDB runs on port 27020:27017 (localhost only with --net=host).
1042
+ Qdrant runs on port 6334 (localhost only with --net=host).
1037
1043
  """
1038
1044
  action_details = self.get_action_details()
1039
1045
  if not action_details:
@@ -1044,11 +1050,11 @@ def database_setup_execute(self: ActionInstance):
1044
1050
 
1045
1051
  project_id = action_details["_idProject"]
1046
1052
 
1047
- # Run docker compose up
1048
-
1053
+ # MongoDB container with --net=host (Port: 27020:27017)
1049
1054
  cmd = (
1050
- f"docker run --pull=always -p 27020:27017 "
1055
+ f"docker run --pull=always --net=host "
1051
1056
  f"--name mongodbdatabase "
1057
+ f"-v matrice_myvol:/matrice_data "
1052
1058
  f"-e ACTION_RECORD_ID={self.action_record_id} "
1053
1059
  f"-e MATRICE_ACCESS_KEY_ID={self.matrice_access_key_id} "
1054
1060
  f"-e MATRICE_SECRET_ACCESS_KEY={self.matrice_secret_access_key} "
@@ -1056,15 +1062,16 @@ def database_setup_execute(self: ActionInstance):
1056
1062
  f'-e ENV="{os.environ.get("ENV", "prod")}" '
1057
1063
  f"{image} "
1058
1064
  )
1059
- print("Docker command", cmd)
1065
+ logging.info("Starting MongoDB container (Port: 27020:27017): %s", cmd)
1060
1066
 
1067
+ # Qdrant container with --net=host (Port: 6334)
1061
1068
  qdrant_cmd = (
1062
- f"docker run --pull=always "
1069
+ f"docker run --pull=always --net=host "
1063
1070
  f"--name qdrant "
1064
- f"-p 6333:6333 "
1065
- f"-p 6334:6334 "
1071
+ f"-v matrice_myvol:/matrice_data "
1066
1072
  f"{'qdrant/qdrant:latest'} "
1067
1073
  )
1074
+ logging.info("Starting Qdrant container (Port: 6334): %s", qdrant_cmd)
1068
1075
 
1069
1076
  # Docker Command run
1070
1077
  self.start(cmd, "database_setup")
@@ -1075,7 +1082,8 @@ def database_setup_execute(self: ActionInstance):
1075
1082
  @log_errors(raise_exception=False)
1076
1083
  def facial_recognition_setup_execute(self: ActionInstance):
1077
1084
  """
1078
- Creates and setup the database for facial recognition server.
1085
+ Creates and setup the facial recognition worker server.
1086
+ Facial recognition worker runs on port 8081 (localhost only with --net=host).
1079
1087
  """
1080
1088
  action_details = self.get_action_details()
1081
1089
 
@@ -1085,18 +1093,18 @@ def facial_recognition_setup_execute(self: ActionInstance):
1085
1093
 
1086
1094
  self.setup_action_requirements(action_details)
1087
1095
 
1088
- # Add worker container run command
1096
+ # Facial recognition worker container with --net=host (Port: 8081)
1089
1097
  worker_cmd = (
1090
- f"docker run -d --pull=always "
1098
+ f"docker run -d --pull=always --net=host "
1091
1099
  f"--name worker "
1092
- f"-p 8081:8081 "
1100
+ f"-v matrice_myvol:/matrice_data "
1093
1101
  f'-e ENV="{os.environ.get("ENV", "prod")}" '
1094
1102
  f'-e MATRICE_SECRET_ACCESS_KEY="{self.matrice_secret_access_key}" '
1095
1103
  f'-e MATRICE_ACCESS_KEY_ID="{self.matrice_access_key_id}" '
1096
1104
  f'-e ACTION_ID="{self.action_record_id}" '
1097
1105
  f"{image}"
1098
1106
  )
1099
- print("Worker docker run command:", worker_cmd)
1107
+ logging.info("Starting facial recognition worker (Port: 8081): %s", worker_cmd)
1100
1108
 
1101
1109
  # Docker Command run
1102
1110
  self.start(worker_cmd, "facial_recognition_setup")
@@ -1104,30 +1112,30 @@ def facial_recognition_setup_execute(self: ActionInstance):
1104
1112
  @log_errors(raise_exception=False)
1105
1113
  def lpr_setup_execute(self: ActionInstance):
1106
1114
  """
1107
- Creates and setup the database for license plate server.
1115
+ Creates and setup the license plate recognition server.
1116
+ LPR worker runs on port 8082 (localhost only with --net=host).
1108
1117
  """
1109
1118
  action_details = self.get_action_details()
1110
1119
 
1111
1120
  if not action_details:
1112
1121
  return
1113
1122
  image = self.docker_container
1114
- external_port = self.scaling.get_open_port()
1115
1123
 
1116
1124
  self.setup_action_requirements(action_details)
1117
1125
 
1118
- # Add worker container run command
1126
+ # LPR worker container with --net=host (Port: 8082)
1119
1127
  worker_cmd = (
1120
1128
  f"docker run -d --net=host --pull=always "
1121
1129
  f"--name lpr-worker "
1122
- f"-p {external_port}:8082 "
1130
+ f"-v matrice_myvol:/matrice_data "
1123
1131
  f'-e ENV="{os.environ.get("ENV", "prod")}" '
1124
1132
  f'-e MATRICE_SECRET_ACCESS_KEY="{self.matrice_secret_access_key}" '
1125
1133
  f'-e MATRICE_ACCESS_KEY_ID="{self.matrice_access_key_id}" '
1126
1134
  f'-e ACTION_ID="{self.action_record_id}" '
1127
- f'-e PORT={external_port} '
1135
+ f'-e PORT=8082 '
1128
1136
  f"{image}"
1129
1137
  )
1130
- print("Worker docker run command:", worker_cmd)
1138
+ logging.info("Starting LPR worker (Port: 8082): %s", worker_cmd)
1131
1139
 
1132
1140
  # Docker Command run
1133
1141
  self.start(worker_cmd, "lpr_setup")
@@ -1183,9 +1191,11 @@ def fe_fs_streaming_execute(self: ActionInstance):
1183
1191
  worker_cmd = (
1184
1192
  f"docker run -d --pull=always --net=host "
1185
1193
  f"--name fe_streaming "
1194
+ f"-v matrice_myvol:/matrice_data "
1186
1195
  f'-e ENV="{os.environ.get("ENV", "prod")}" '
1187
1196
  f'-e MATRICE_SECRET_ACCESS_KEY="{self.matrice_secret_access_key}" '
1188
1197
  f'-e MATRICE_ACCESS_KEY_ID="{self.matrice_access_key_id}" '
1198
+ f"-e PORT=3000 "
1189
1199
  f"{image}"
1190
1200
  )
1191
1201
  logging.info("Starting frontend streaming (Port: 3000): %s", worker_cmd)
@@ -1194,6 +1204,40 @@ def fe_fs_streaming_execute(self: ActionInstance):
1194
1204
  self.start(worker_cmd, "fe_fs_streaming")
1195
1205
 
1196
1206
 
1207
+ @log_errors(raise_exception=False)
1208
+ def fe_analytics_service_execute(self: ActionInstance):
1209
+ """
1210
+ Creates and setup the frontend analytics service.
1211
+ Frontend analytics service runs on port 3001 (localhost only with --net=host).
1212
+ """
1213
+ action_details = self.get_action_details()
1214
+
1215
+ if not action_details:
1216
+ return
1217
+ image = action_details["actionDetails"].get("docker")
1218
+
1219
+ self.setup_action_requirements(action_details)
1220
+
1221
+ project_id = action_details["_idProject"]
1222
+
1223
+ # Frontend analytics service with --net=host (Port: 3001)
1224
+ worker_cmd = (
1225
+ f"docker run -d --pull=always --net=host "
1226
+ f"--name fe-analytics "
1227
+ f'-e NEXT_PUBLIC_DEPLOYMENT_ENV="{os.environ.get("ENV", "prod")}" '
1228
+ f'-e MATRICE_SECRET_ACCESS_KEY="{self.matrice_secret_access_key}" '
1229
+ f'-e MATRICE_ACCESS_KEY_ID="{self.matrice_access_key_id}" '
1230
+ f'-e ACTION_ID="{self.action_record_id}" '
1231
+ f"-e PORT=3001 "
1232
+ f'-e PROJECT_ID="{project_id}" '
1233
+ f"{image}"
1234
+ )
1235
+ logging.info("Starting frontend analytics service (Port: 3001): %s", worker_cmd)
1236
+
1237
+ # Docker Command run
1238
+ self.start(worker_cmd, "fe_analytics_service")
1239
+
1240
+
1197
1241
  @log_errors(raise_exception=False)
1198
1242
  def synthetic_dataset_generation_execute(self: ActionInstance):
1199
1243
  """Execute synthetic dataset generation task."""
@@ -1462,7 +1506,10 @@ def streaming_gateway_execute(self: ActionInstance):
1462
1506
 
1463
1507
  @log_errors(raise_exception=False)
1464
1508
  def kafka_setup_execute(self: ActionInstance):
1465
- """Execute kafka server task."""
1509
+ """
1510
+ Execute kafka server task.
1511
+ Kafka runs on port 9092 (SASL_PLAINTEXT) and 9093 (CONTROLLER) - localhost only with --net=host.
1512
+ """
1466
1513
  action_details = self.get_action_details()
1467
1514
  if not action_details:
1468
1515
  return
@@ -1470,7 +1517,6 @@ def kafka_setup_execute(self: ActionInstance):
1470
1517
  host_ip = (
1471
1518
  urllib.request.urlopen("https://ident.me", timeout=10).read().decode("utf8")
1472
1519
  )
1473
- container_port = 9092
1474
1520
  # Setup credentials
1475
1521
  self.setup_action_requirements(action_details)
1476
1522
 
@@ -1538,7 +1584,7 @@ def kafka_setup_execute(self: ActionInstance):
1538
1584
  [f"-e {key}={shlex.quote(str(value))}" for key, value in env_vars.items()]
1539
1585
  )
1540
1586
 
1541
- # Build the docker command directly to match user's pattern
1587
+ # Build the docker command with --net=host
1542
1588
  pypi_index = f"https://{'test.' if env != 'prod' else ''}pypi.org/simple/"
1543
1589
 
1544
1590
  if env == 'dev':
@@ -1547,8 +1593,9 @@ def kafka_setup_execute(self: ActionInstance):
1547
1593
  else:
1548
1594
  pkgs = f"matrice_common matrice"
1549
1595
 
1596
+ # Kafka container with --net=host (Ports: 9092, 9093)
1550
1597
  cmd = (
1551
- f"docker run -p {host_port}:{container_port} "
1598
+ f"docker run --net=host "
1552
1599
  f"{env_args} "
1553
1600
  f"--shm-size=30G --pull=always "
1554
1601
  f'aiforeveryone/matrice-kafka:latest /bin/bash -c "'
@@ -1561,5 +1608,36 @@ def kafka_setup_execute(self: ActionInstance):
1561
1608
  f'venv/bin/python3 main.py {self.action_record_id} {host_port}"'
1562
1609
  )
1563
1610
 
1564
- logging.info("cmd is: %s", cmd)
1611
+ logging.info("Starting Kafka container (Ports: 9092, 9093): %s", cmd)
1565
1612
  self.start(cmd, "kafka_setup")
1613
+
1614
+
1615
+ @log_errors(raise_exception=False)
1616
+ def inference_tracker_setup_execute(self: ActionInstance):
1617
+
1618
+ """
1619
+ Creates and start inference tracker.
1620
+ Inference tracker runs on port 8110 (localhost only with --net=host).
1621
+ """
1622
+
1623
+ action_details = self.get_action_details()
1624
+ if not action_details:
1625
+ return
1626
+
1627
+ image = self.docker_container
1628
+
1629
+ self.setup_action_requirements(action_details)
1630
+
1631
+ # This is the existing Docker run command
1632
+ worker_cmd = (
1633
+ f"docker run -d --pull=always --net=host "
1634
+ f"--name inference-tracker-worker "
1635
+ f"-v matrice_myvol:/matrice_data "
1636
+ f'-e ENV="{os.environ.get("ENV", "prod")}" '
1637
+ f'-e MATRICE_SECRET_ACCESS_KEY="{self.matrice_secret_access_key}" '
1638
+ f'-e MATRICE_ACCESS_KEY_ID="{self.matrice_access_key_id}" '
1639
+ f'-e ACTION_ID="{self.action_record_id}" '
1640
+ f"{image}"
1641
+ )
1642
+
1643
+ self.start(worker_cmd, "inference_tracker_setup")
@@ -674,16 +674,16 @@ class Scaling:
674
674
  )
675
675
 
676
676
  @log_errors(log_error=True)
677
- def get_model_codebase_requirements(self, model_family_id):
677
+ def get_model_codebase_requirements(self, dockerId):
678
678
  """Get model codebase requirements.
679
679
 
680
680
  Args:
681
- model_family_id: ID of the model family
681
+ dockerId: ID of the docker
682
682
 
683
683
  Returns:
684
684
  Tuple of (data, error, message) from API response
685
685
  """
686
- path = f"/v1/model_store/get_user_requirements_download_path/{model_family_id}"
686
+ path = f"/v1/model_store/get_user_requirements_download_path/{dockerId}"
687
687
  resp = self.rpc.get(path=path)
688
688
  return self.handle_response(
689
689
  resp,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: matrice_compute
3
- Version: 0.1.15
3
+ Version: 0.1.17
4
4
  Summary: Common server utilities for Matrice.ai services
5
5
  Author-email: "Matrice.ai" <dipendra@matrice.ai>
6
6
  License-Expression: MIT
@@ -1,5 +1,5 @@
1
1
  matrice_compute/__init__.py,sha256=ZzQcFsT005VCgq9VZUh565f4upOooEb_FwZ6RgweNZs,597
2
- matrice_compute/action_instance.py,sha256=_EYTNmUDnKKMmiRX2WCjP_MC2o5kA1RYAvHVKhadnvk,59774
2
+ matrice_compute/action_instance.py,sha256=19HzEE91PFrsFBC40TzvJWt2Zu1LtEghPNMFrLbcLzQ,62938
3
3
  matrice_compute/actions_manager.py,sha256=5U-xM6tl_Z6x96bi-c7AJM9ru80LqTN8f5Oce8dAu_A,7780
4
4
  matrice_compute/actions_scaledown_manager.py,sha256=pJ0nduNwHWZ10GnqJNx0Ok7cVWabQ_M8E2Vb9pH3A_k,2002
5
5
  matrice_compute/instance_manager.py,sha256=8USyX09ZxLvnVNIrjRogbyUeMCfgWnasuRqYkkVF4tQ,10146
@@ -7,11 +7,11 @@ matrice_compute/instance_utils.py,sha256=cANKRUlUzfecnzVEMC6Gkg9K7GZajH9ojNPiChd
7
7
  matrice_compute/prechecks.py,sha256=W9YmNF3RcLhOf4U8WBlExvFqDw1aGWSNTlJtA73lbDQ,17196
8
8
  matrice_compute/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  matrice_compute/resources_tracker.py,sha256=n57IJmT5GjNEX8yQL7nbKv57bjvESYM-vRQcQ0DgQXQ,19256
10
- matrice_compute/scaling.py,sha256=3F8SWvy9wWczpJ6dbY5RrXWw5ByZlIzAPJklir3KIFI,35359
10
+ matrice_compute/scaling.py,sha256=fAoXsDmMgtNjX-5gXB3KvaWeAi78rDDyRsG1GUmwykg,35332
11
11
  matrice_compute/shutdown_manager.py,sha256=0MYV_AqygqR9NEntYf7atUC-PbWXyNkm1f-8c2aizgA,13234
12
12
  matrice_compute/task_utils.py,sha256=3qIutiQdYPyGRxH9ZwLbqdg8sZcnp6jp08pszWCRFl0,2820
13
- matrice_compute-0.1.15.dist-info/licenses/LICENSE.txt,sha256=_uQUZpgO0mRYL5-fPoEvLSbNnLPv6OmbeEDCHXhK6Qc,1066
14
- matrice_compute-0.1.15.dist-info/METADATA,sha256=kHaPM9mLcbUZF0k3QxCRQ1jn1zuasO2l73S8yPlfPf0,1038
15
- matrice_compute-0.1.15.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
- matrice_compute-0.1.15.dist-info/top_level.txt,sha256=63Plr3L1GzBUWZO5JZaFkiv8IcB10xUPU-9w3i6ptvE,16
17
- matrice_compute-0.1.15.dist-info/RECORD,,
13
+ matrice_compute-0.1.17.dist-info/licenses/LICENSE.txt,sha256=_uQUZpgO0mRYL5-fPoEvLSbNnLPv6OmbeEDCHXhK6Qc,1066
14
+ matrice_compute-0.1.17.dist-info/METADATA,sha256=wxyy9OKisJdVgeMQZI9ttKVowySj9ChPm6K4hp39F38,1038
15
+ matrice_compute-0.1.17.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
+ matrice_compute-0.1.17.dist-info/top_level.txt,sha256=63Plr3L1GzBUWZO5JZaFkiv8IcB10xUPU-9w3i6ptvE,16
17
+ matrice_compute-0.1.17.dist-info/RECORD,,