From 439a3faed6b3c4736c0f623d83ad18db56a44c72 Mon Sep 17 00:00:00 2001 From: marcsello Date: Tue, 27 Jul 2021 17:44:14 +0200 Subject: [PATCH] Removed hard-coded urls --- cnn_classification_service/magic_doer.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cnn_classification_service/magic_doer.py b/cnn_classification_service/magic_doer.py index 2f225b5..3dea995 100644 --- a/cnn_classification_service/magic_doer.py +++ b/cnn_classification_service/magic_doer.py @@ -4,12 +4,15 @@ import logging import tempfile import requests import time +from urllib.parse import urljoin from classifier_cache import ClassifierCache class MagicDoer: - classifier_cache = ClassifierCache() + classifier_cache = ClassifierCache( + os.environ.get("MODEL_INFO_URL", "http://model-service/model/cnn/$default") + ) @classmethod def run_everything(cls, parameters: dict) -> dict: @@ -19,9 +22,11 @@ class MagicDoer: try: # Download Sample + storage_service_url = os.environ.get("STORAGE_SERVICE_URL", "http://storage-service/") + object_path = urljoin(storage_service_url, f"object/{tag}") - logging.info(f"Downloading sample: {tag}") - r = requests.get(f"http://storage-service/object/{tag}") + logging.info(f"Downloading sample: {tag} from {object_path}") + r = requests.get(object_path) with open(sample_file_handle, 'wb') as f: f.write(r.content)