From f6e0b7b25ea7a60de136397d4938aff31906ec01 Mon Sep 17 00:00:00 2001 From: marcsello Date: Fri, 2 Oct 2020 03:49:37 +0200 Subject: [PATCH] Updated model svc api --- src/preprocessor/soundpreprocessor.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/preprocessor/soundpreprocessor.py b/src/preprocessor/soundpreprocessor.py index 6ff4bac..87949ee 100644 --- a/src/preprocessor/soundpreprocessor.py +++ b/src/preprocessor/soundpreprocessor.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import requests +from urllib.parse import urljoin from pyAudioAnalysis.audioTrainTest import load_model, load_model_knn, classifier_wrapper from utils import config from .abcpreprocessor import AbcPreProcessor @@ -40,14 +41,16 @@ class SoundPreProcessor(AbcPreProcessor): else: model_id_to_get = '$default' - r = requests.get(f"{config.API_URL}/model/svm/{model_id_to_get}/details") + model_root_url = urljoin(config.API_URL, f"/model/svm/{model_id_to_get}") + + r = requests.get(model_root_url) r.raise_for_status() self._model_details = r.json() logging.debug("Downloading model...") BirbnetesIoTPlatformStatusDriver.enqueue_pattern('green', [1]) - r = requests.get(f"{config.API_URL}/model/svm/{self._model_details['id']}") + r = requests.get(urljoin(model_root_url, self._model_details['files']['model'])) r.raise_for_status() with open(temp_model_handle, 'wb') as f: # bruhtastic @@ -55,7 +58,7 @@ class SoundPreProcessor(AbcPreProcessor): logging.debug("Downloading MEANS...") BirbnetesIoTPlatformStatusDriver.enqueue_pattern('green', [1]) - r = requests.get(f"{config.API_URL}/model/svm/{self._model_details['id']}?means") + r = requests.get(urljoin(model_root_url, self._model_details['files']['means'])) r.raise_for_status() with open(self._temp_means_name, 'wb') as f: