From ec0a927d3c5c99de292552bb25ff4283a13f1a2c Mon Sep 17 00:00:00 2001 From: Thibaut Date: Fri, 19 Apr 2024 14:12:30 +0200 Subject: [PATCH] Editing makefile to add hub/edge separation when build // Adding labelboxAPI key to post api method --- Makefile | 14 +++++++++++--- docker-compose.yml | 7 +++++++ .../hub_labelizer/application/trigger_routes.py | 3 ++- .../infrastructure/labelizer/labelbox_labelizer.py | 6 ++++-- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index b63cd366..c69ddc4b 100644 --- a/Makefile +++ b/Makefile @@ -38,14 +38,22 @@ hub_labelizer: hub_monitoring_db: docker-compose up -d --build hub_monitoring_db -.PHONY: vio-edge-up ## 🐳 Start all services (db, model_serving, orchestrator, interface) and local hub monitoring +.PHONY: vio-hub-up ## 🐳 Start all hub services (monitoring, monitoring_db, labelizer) +vio-hub-up: + docker-compose --profile hub up -d --build + +.PHONY: vio-edge-up ## 🐳 Start all edge services (db, model_serving, orchestrator, interface) vio-edge-up: + docker-compose --profile edge up -d --build + +.PHONY: vio-up ## 🐳 Start all edge services (db, model_serving, orchestrator, interface) and hubs (monitoring, monitoring_db, labelizer) +vio-up: docker-compose up -d --build .PHONY: vio-edge-up-raspberrypi ## 🐳 Start all edge services on RaspberryPI (db, model_serving, orchestrator, interface) vio-edge-up-raspberrypi: docker-compose -f docker-compose.raspberrypi.yml up -d --build -.PHONY: vio-edge-down ## ❌ Stop all services (model_serving, edge_orchestrator, ui) -vio-edge-down: +.PHONY: vio-down ## ❌ Stop all services (model_serving, edge_orchestrator, ui) +vio-down: docker-compose down diff --git a/docker-compose.yml b/docker-compose.yml index b11bd499..379e6983 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,7 @@ services: container_name: edge_db ports: - 27017:27017 + profiles: [edge] edge_model_serving: container_name: edge_model_serving @@ -16,6 +17,7 @@ services: - TF_CPP_MIN_VLOG_LEVEL=0 ports: - 8501:8501 + profiles: [edge] # volumes: # - ./edge_model_serving/models:/models @@ -35,6 +37,7 @@ services: SERVING_MODEL_URL: http://edge_model_serving:8501 MONGO_DB_URI: mongodb://edge_db:27017/ POSTGRES_DB_URI: postgresql://vio:vio@hub_monitoring_db:5432/vio + profiles: [edge] hub_labelizer: container_name: hub_labelizer @@ -48,6 +51,7 @@ services: environment: API_CONFIG: docker EDGE_ORCHESTRATOR_URL: http://edge_orchestrator:8000 + profiles: [hub] edge_interface: container_name: edge_interface @@ -56,6 +60,7 @@ services: dockerfile: Dockerfile ports: - 8080:80 + profiles: [edge] hub_monitoring: container_name: hub_monitoring @@ -67,6 +72,7 @@ services: volumes: - ./hub_monitoring/grafana/dashboards:/var/lib/grafana/dashboards - ./hub_monitoring/grafana/provisioning:/etc/grafana/provisioning + profiles: [hub] hub_monitoring_db: container_name: hub_monitoring_db @@ -81,6 +87,7 @@ services: volumes: - vio-postgresql-data:/var/lib/postgresql/data - ./hub_monitoring/docker/init-db.sh:/docker-entrypoint-initdb.d/init-db.sh + profiles: [hub] volumes: vio-postgresql-data: diff --git a/hub_labelizer/hub_labelizer/application/trigger_routes.py b/hub_labelizer/hub_labelizer/application/trigger_routes.py index bce63e02..8b6518e4 100644 --- a/hub_labelizer/hub_labelizer/application/trigger_routes.py +++ b/hub_labelizer/hub_labelizer/application/trigger_routes.py @@ -11,10 +11,11 @@ async def drop_to_labelizer_job( project_id: str = None, dataset_id: str = None, config_name: str = None, + api_key: str = None, labelizer: Labelizer = Depends(get_labelizer), background_tasks: BackgroundTasks = None, ): filters = {} background_tasks.add_task( - labelizer.apost_images, project_id, dataset_id, config_name, filters + labelizer.apost_images, project_id, dataset_id, config_name, api_key, filters ) diff --git a/hub_labelizer/hub_labelizer/infrastructure/labelizer/labelbox_labelizer.py b/hub_labelizer/hub_labelizer/infrastructure/labelizer/labelbox_labelizer.py index 0aca32f1..ea82029c 100644 --- a/hub_labelizer/hub_labelizer/infrastructure/labelizer/labelbox_labelizer.py +++ b/hub_labelizer/hub_labelizer/infrastructure/labelizer/labelbox_labelizer.py @@ -101,11 +101,13 @@ def load_dataset(self, dataset_id: str): self.dataset = self.client.get_dataset(dataset_id) async def apost_images( - self, project_id: str, dataset_id: str, config_name: str, filters: dict + self, project_id: str, dataset_id: str, config_name: str, api_key: str, filters: dict ): + if not api_key: + self.client = lb.Client(api_key=os.getenv("LABELBOX_API_KEY")) + self.load_dataset(dataset_id) url_orchestrator = os.getenv("EDGE_ORCHESTRATOR_URL") - print(url_orchestrator) binaries_annotations = await aget_binaries_annotations_path( url_orchestrator, config_name )