From e8e47d6db9863104896ef439fbf4434e164fe882 Mon Sep 17 00:00:00 2001 From: ispirtraian Date: Thu, 18 Apr 2024 12:44:12 +0000 Subject: [PATCH] fix: decode only if necessary --- app/src/serving/serving_app.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/app/src/serving/serving_app.py b/app/src/serving/serving_app.py index 86fc15e..627e5ea 100644 --- a/app/src/serving/serving_app.py +++ b/app/src/serving/serving_app.py @@ -117,18 +117,17 @@ def appmon_callback(self): try: with open(task_content_path, 'rb') as file: input = file.read() + # convert if necessary + if model_type == 'text': + input_str = input.decode('utf-8') + try: + #check if list + input = json.loads(input_str) + except json.JSONDecodeError: + input = input_str except Exception as exc: self.P("Content file read error: {}".format(exc)) if input is not None: - # convert if necessary - if model_type == 'text': - input_str = input.decode('utf-8') - try: - #check if list - input = json.loads(input_str) - except json.JSONDecodeError: - input = input_str - result = self._predict( model_type, input,