Skip to content

Commit

Permalink
add edge_name env var
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthemide committed Jun 7, 2023
1 parent f6417b4 commit 32af746
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 45 deletions.
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ hub_monitoring:
vio-edge-up:
docker-compose up -d --build

.PHONY: vio-edge-up-intel ## 🐳 Start all edge services on intel (model_serving, orchestrator, interface)
vio-edge-up-intel:
docker-compose -f docker-compose.intel.yml 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
Expand Down
3 changes: 0 additions & 3 deletions deployment/edge/ansible/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@
ping-edge:
ansible all -i inventory.ini -m ping

setup-edge:
ansible-playbook -v -i inventory.ini setup_edge.yml

deploy-vio-on-edge:
ansible-playbook -v -i inventory.ini deploy_vio_on_edge.yml
38 changes: 33 additions & 5 deletions deployment/edge/ansible/deploy_vio_on_edge.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
- name: "Deploy VIO on edge"
- name: "Deploy vio on edge and launch"
hosts: all
tasks:
- name: Start all edge services on intel (model_serving, orchestrator, interface)
make:
chdir: "{{ REMOTE_VIO_DIR }}"
target: vio-edge-up-intel
- name: Clone vio git repo
ansible.builtin.git:
repo: https://github.com/octo-technology/VIO.git
dest: "{{ REMOTE_VIO_DIR }}"
single_branch: yes
version: deploy_vio_on_edge
force: true

- name: Create a directory if it does not exist
ansible.builtin.file:
path: "{{ REMOTE_VIO_DIR }}/edge_orchestrator/config/secrets"
state: directory

- name: Copy config on the remote machine
ansible.builtin.copy:
src: "{{ LOCAL_VIO_DIR }}/edge_orchestrator/config/secrets"
dest: "{{ REMOTE_VIO_DIR }}/edge_orchestrator/config/"

- name: Copy model file on the remote machine
ansible.builtin.copy:
src: "{{ LOCAL_VIO_DIR }}/edge_model_serving/models/tflite"
dest: "{{ REMOTE_VIO_DIR }}/edge_model_serving/models/"

- name: Template docker compose
ansible.builtin.template:
src: "{{ LOCAL_VIO_DIR }}/deployment/edge/ansible/files/docker-compose.template.yml"
dest: "{{ REMOTE_VIO_DIR }}/docker-compose.yml"

- name: Start all edge services on intel (model_serving, orchestrator, interface)
make:
chdir: "{{ REMOTE_VIO_DIR }}"
target: vio-edge-up
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ services:
# - /dev/video2:/dev/video2
ports:
- 8000:8000
environment:
EDGE_NAME: "{{ EDGE_NAME }}"
API_CONFIG: upload-gcp
SERVING_MODEL_URL: http://edge_model_serving:8501
GOOGLE_APPLICATION_CREDENTIALS: /edge_orchestrator/config/secrets/credentials.json
GCP_BUCKET_NAME: tf-vio-bucket
ACTIVE_CONFIG_NAME: marker_classification_with_1_fake_camera

edge_interface:
container_name: edge_interface
Expand Down
6 changes: 6 additions & 0 deletions deployment/edge/ansible/inventory.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
[edge_1]
10.103.252.192 ansible_user=devkit ansible_password=devkit

[edge_1:vars]
EDGE_NAME="edge1"

[edge_2]
10.103.253.2 ansible_user=devkit ansible_password=devkit

[edge_2:vars]
EDGE_NAME="edge2"

[all:vars]
LOCAL_VIO_DIR={{ lookup('env', 'LOCAL_VIO_DIR') }}
REMOTE_VIO_DIR=/home/devkit/vio
26 changes: 0 additions & 26 deletions deployment/edge/ansible/setup_edge.yml

This file was deleted.

6 changes: 1 addition & 5 deletions edge_orchestrator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ RUN pip install .

COPY edge_orchestrator ./edge_orchestrator

ENV API_CONFIG upload-gcp
ENV SERVING_MODEL_URL http://edge_model_serving:8501
ENV GOOGLE_APPLICATION_CREDENTIALS /edge_orchestrator/config/secrets/credentials.json
ENV GCP_BUCKET_NAME tf-vio-bucket
ENV ACTIVE_CONFIG_NAME barcode_detection_with_usbcamera
ENV API_CONFIG docker

EXPOSE 8000
ENTRYPOINT ["python", "-m", "edge_orchestrator"]
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from edge_orchestrator.domain.models.item import get_item_rule
from edge_orchestrator.domain.models.item import Item
from edge_orchestrator.domain.models.model_infos import ModelInfos
from edge_orchestrator.domain.models.decision import Decision


class SupervisorState(Enum):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@
class GCPBinaryStorage(BinaryStorage):
def __init__(self):
self.storage_client = storage.Client()
self.prefix = os.environ.get('EDGE_NAME', '')
self.bucket = self.storage_client.get_bucket(os.getenv('GCP_BUCKET_NAME'))

def save_item_binaries(self, item: Item) -> None:
for camera_id, binary in item.binaries.items():
blob = self.bucket.blob(
f"{item.id}/{camera_id}.jpg"
os.path.join(self.prefix, item.id, f"{camera_id}.jpg")
)
if blob is None:
raise Exception("An image should be upload")
blob.upload_from_string(binary, content_type="image/jpg")

def get_item_binary(self, item_id: str, camera_id: str) -> bytes:
filename = f"{item_id}/{camera_id}.jpg"
filename = os.path.join(self.prefix, item_id, f"{camera_id}.jpg")
blob = self.bucket.get_blob(filename)
if blob is None:
return None
Expand Down

0 comments on commit 32af746

Please sign in to comment.