From 604218c6f46bdf8135bdba2413547f6f93312a27 Mon Sep 17 00:00:00 2001 From: Gil Tinde <31830765+giltinde@users.noreply.github.com> Date: Wed, 3 Jul 2024 10:48:48 +0200 Subject: [PATCH 1/2] fix: use content in examples --- crop_health_api/example_code/python/predictions__binary.py | 6 +++++- .../example_code/python/predictions__multi-HLT.py | 6 +++++- .../example_code/python/predictions__single-HLT.py | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/crop_health_api/example_code/python/predictions__binary.py b/crop_health_api/example_code/python/predictions__binary.py index a06b66e..08fb1ef 100644 --- a/crop_health_api/example_code/python/predictions__binary.py +++ b/crop_health_api/example_code/python/predictions__binary.py @@ -1,11 +1,15 @@ from httpx import Client +# Open the image file as a binary file +with open("cocoa.jpg", "rb") as image_file: + image_bytes = image_file.read() + with Client() as client: # Get the binary model prediction for image cocoa.jpg # passed as a binary file in the request body response_binary = client.post( url="$api_url" + "/predictions/binary", - data=open("cocoa.jpg", "rb").read(), + content=image_bytes, ) data_binary = response_binary.json() diff --git a/crop_health_api/example_code/python/predictions__multi-HLT.py b/crop_health_api/example_code/python/predictions__multi-HLT.py index 65c62dd..1b38281 100644 --- a/crop_health_api/example_code/python/predictions__multi-HLT.py +++ b/crop_health_api/example_code/python/predictions__multi-HLT.py @@ -1,11 +1,15 @@ from httpx import Client +# Open the image file as a binary file +with open("cocoa.jpg", "rb") as image_file: + image_bytes = image_file.read() + with Client() as client: # Get the multi-HLT model prediction for image cocoa.jpg # passed as a binary file in the request body response_multi_HLT = client.post( url="$api_url" + "/predictions/multi-HLT", - data=open("cocoa.jpg", "rb").read(), + content=image_bytes, ) data_multi_HLT = response_multi_HLT.json() diff --git a/crop_health_api/example_code/python/predictions__single-HLT.py b/crop_health_api/example_code/python/predictions__single-HLT.py index 85e2db0..a191396 100644 --- a/crop_health_api/example_code/python/predictions__single-HLT.py +++ b/crop_health_api/example_code/python/predictions__single-HLT.py @@ -1,11 +1,15 @@ from httpx import Client +# Open the image file as a binary file +with open("cocoa.jpg", "rb") as image_file: + image_bytes = image_file.read() + with Client() as client: # Get the single-HLT model prediction for image cocoa.jpg # passed as a binary file in the request body response_single_HLT = client.post( url="$api_url" + "/predictions/single-HLT", - data=open("cocoa.jpg", "rb").read(), + content=image_bytes, ) data_single_HLT = response_single_HLT.json() From 243814311a3809054a8f281a17c9c1187a644104 Mon Sep 17 00:00:00 2001 From: Gil Tinde <31830765+giltinde@users.noreply.github.com> Date: Wed, 3 Jul 2024 10:49:41 +0200 Subject: [PATCH 2/2] version bump --- deployment/kubernetes/crop-health-api.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/deployment/kubernetes/crop-health-api.yaml b/deployment/kubernetes/crop-health-api.yaml index d1bf0e2..675462f 100644 --- a/deployment/kubernetes/crop-health-api.yaml +++ b/deployment/kubernetes/crop-health-api.yaml @@ -19,14 +19,14 @@ spec: spec: containers: - name: crop-health-fastapi - image: ghcr.io/openearthplatforminitiative/crop-health-api-fastapi:0.1.8 + image: ghcr.io/openearthplatforminitiative/crop-health-api-fastapi:0.1.9 ports: - containerPort: 5000 env: - name: API_ROOT_PATH value: "/crop-health" - name: VERSION - value: 0.1.8 + value: 0.1.9 - name: API_DOMAIN valueFrom: configMapKeyRef: @@ -34,7 +34,7 @@ spec: key: api_domain - name: crop-health-torchserve - image: ghcr.io/openearthplatforminitiative/crop-health-api-torchserve:0.1.8 + image: ghcr.io/openearthplatforminitiative/crop-health-api-torchserve:0.1.9 ports: - containerPort: 8080 # Inference API - containerPort: 8081 # Management API @@ -43,7 +43,7 @@ spec: - name: API_ROOT_PATH value: "/crop-health" - name: VERSION - value: 0.1.8 + value: 0.1.9 - name: API_DOMAIN valueFrom: configMapKeyRef: