face_detection: add push_to_dev, fix action command and GraphQL mutation query
diff --git a/apps/face_detection/BUILD b/apps/face_detection/BUILD
index 364b682..d1ed253 100644
--- a/apps/face_detection/BUILD
+++ b/apps/face_detection/BUILD
@@ -1,8 +1,10 @@
+load("@rules_pkg//:pkg.bzl", "pkg_tar")
+
# TODO(lekva): figure out how to build py_binary with pip dependencies and
# migrate off of shell script running docker build
sh_binary(
- name = "container",
- srcs = ["container.sh"],
+ name = "push_to_dev",
+ srcs = ["push_to_dev.sh"],
data = glob(["*.py"]) + [
"Dockerfile",
"haarcascade_frontalface_default.xml",
@@ -11,3 +13,10 @@
"@bazel_tools//tools/bash/runfiles",
],
)
+
+pkg_tar(
+ name = "chart",
+ srcs = glob(["chart/**"]),
+ extension = "tar.gz",
+ strip_prefix = "./chart",
+)
diff --git a/apps/face_detection/chart/templates/pcloud/Actions.yaml b/apps/face_detection/chart/templates/pcloud/Actions.yaml
index 0b00bb1..94dbf46 100644
--- a/apps/face_detection/chart/templates/pcloud/Actions.yaml
+++ b/apps/face_detection/chart/templates/pcloud/Actions.yaml
@@ -10,6 +10,6 @@
- name: detect-faces
image: {{ .Values.image.name }}:{{ .Values.image.tag }}
imagePullPolicy: Always
- command: ["/face_detector"]
+ command: ["python3", "main.py"]
args: [{-{ .PCloudApiAddr }-}, {-{ .ObjectStoreAddr }-}, {-{ .Id }-}]
restartPolicy: Never
diff --git a/apps/face_detection/main.py b/apps/face_detection/main.py
index 94b2d96..1d92491 100644
--- a/apps/face_detection/main.py
+++ b/apps/face_detection/main.py
@@ -26,7 +26,7 @@
def upload_face_segments(gql_endpoint, id, faces):
segments = [format_img_segment(id, f) for f in faces]
- data = {"query": "mutation {{ addImageSegment(input: [{segments}]) {{ imagesegment {{ id }} }} }}".format(
+ data = {"query": "mutation {{ addImageSegment(input: [{segments}]) {{ imageSegment {{ id }} }} }}".format(
segments=", ".join(segments))}
# encoded_data = urllib.parse.urlencode(data).encode('UTF-8')
req = urllib.request.Request(gql_endpoint, method="POST")
diff --git a/apps/face_detection/container.sh b/apps/face_detection/push_to_dev.sh
similarity index 93%
rename from apps/face_detection/container.sh
rename to apps/face_detection/push_to_dev.sh
index 3797332..48342f9 100755
--- a/apps/face_detection/container.sh
+++ b/apps/face_detection/push_to_dev.sh
@@ -24,8 +24,11 @@
# --- end runfiles.bash initialization ---
DOCKERFILE="$(rlocation __main__/apps/face_detection/Dockerfile)"
+IMAGE="localhost:30500/giolekva/face-detector"
docker build \
- --tag=localhost:30500/giolekva/face-detector \
+ --tag=$IMAGE \
--file=$DOCKERFILE \
"$(dirname "$DOCKERFILE")"
+
+docker push $IMAGE