From 67b9e6749acbd8fd02c1c18a12d5f1ab64e34e22 Mon Sep 17 00:00:00 2001 From: Avi Asulin Date: Mon, 20 Nov 2023 15:38:43 +0200 Subject: [PATCH 1/4] [Stocks] increase serving readinessTimeoutSeconds time out --- stocks-prediction/04_model_serving.ipynb | 1 + 1 file changed, 1 insertion(+) diff --git a/stocks-prediction/04_model_serving.ipynb b/stocks-prediction/04_model_serving.ipynb index cce6ca41..dfe4549e 100644 --- a/stocks-prediction/04_model_serving.ipynb +++ b/stocks-prediction/04_model_serving.ipynb @@ -298,6 +298,7 @@ } ], "source": [ + "fn.spec.readinessTimeoutSeconds = 60 * 20 # 20 minutes\n", "address = fn.deploy()" ] }, From 4207a8a4df3e0988efa8e96d7dc7d8158779459e Mon Sep 17 00:00:00 2001 From: Avi Asulin Date: Tue, 21 Nov 2023 17:59:20 +0200 Subject: [PATCH 2/4] [Stocks] increase serving readinessTimeoutSeconds time out --- stocks-prediction/04_model_serving.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stocks-prediction/04_model_serving.ipynb b/stocks-prediction/04_model_serving.ipynb index dfe4549e..0ac142f1 100644 --- a/stocks-prediction/04_model_serving.ipynb +++ b/stocks-prediction/04_model_serving.ipynb @@ -298,7 +298,7 @@ } ], "source": [ - "fn.spec.readinessTimeoutSeconds = 60 * 20 # 20 minutes\n", + "fn.spec.readiness_timeout = 60 * 20 # 20 minutes\n", "address = fn.deploy()" ] }, From 140c6d862a475dda48a3cd0a8dadcd79b6220b01 Mon Sep 17 00:00:00 2001 From: Avi Asulin Date: Wed, 22 Nov 2023 15:10:20 +0200 Subject: [PATCH 3/4] [Stocks] skip log results in case of CE --- stocks-prediction/src/serving_stocks.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/stocks-prediction/src/serving_stocks.py b/stocks-prediction/src/serving_stocks.py index f4f72feb..1c99de6b 100644 --- a/stocks-prediction/src/serving_stocks.py +++ b/stocks-prediction/src/serving_stocks.py @@ -29,6 +29,16 @@ warnings.filterwarnings("ignore") +def log_results(df: pd.DataFrame): + # writing to tsdb + if "V3IO_USERNAME" in os.environ: + framesd = os.getenv("V3IO_FRAMESD",'framesd:8081') + client = v3f.Client(framesd, container=os.getenv('V3IO_CONTAINER', 'projects')) + kv_table_path = '/stocks-'+ os.environ['V3IO_USERNAME'] + '/artifacts/stocks_prediction' + client.write('kv', kv_table_path, dfs=df, index_cols=['datetime','tickers']) + print(f'writing prediction to kv at projects{kv_table_path} ...') + + def preprocess(event): vector_name = event['vector_name'] start_time = datetime.datetime.now()-datetime.timedelta(event['start_time']) @@ -85,14 +95,8 @@ def postprocess(event): df['true'] = event['outputs']['labels'] df['prediction'] = (df['prediction']*event['outputs']['price_std']) + event['outputs']['price_mean'] df['true'] = (df['true']*event['outputs']['price_std']) + event['outputs']['price_mean'] - df2 = df.copy() df['datetime'] = df['datetime'].apply(lambda x: x.strftime('%Y-%m-%d %H:%M:%S')) - # writing to tsdb - framesd = os.getenv("V3IO_FRAMESD",'framesd:8081') - client = v3f.Client(framesd, container=os.getenv('V3IO_CONTAINER', 'projects')) - kv_table_path = '/stocks-'+ os.environ['V3IO_USERNAME'] + '/artifacts/stocks_prediction' - client.write('kv', kv_table_path, dfs=df, index_cols=['datetime','tickers']) - print(f'writing prediction to kv at projects{kv_table_path} ...') + log_results(df) return [df.values.tolist(),list(df.columns)] class StocksModel(PyTorchModelServer): From 0a3c1de320e965bd42a2224308f06e85e0efb482 Mon Sep 17 00:00:00 2001 From: Avi Asulin Date: Wed, 22 Nov 2023 15:25:05 +0200 Subject: [PATCH 4/4] [Stocks] skip log results in case of CE --- stocks-prediction/src/serving_stocks.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/stocks-prediction/src/serving_stocks.py b/stocks-prediction/src/serving_stocks.py index 1c99de6b..ef7d09ed 100644 --- a/stocks-prediction/src/serving_stocks.py +++ b/stocks-prediction/src/serving_stocks.py @@ -27,8 +27,6 @@ import os import time -warnings.filterwarnings("ignore") - def log_results(df: pd.DataFrame): # writing to tsdb if "V3IO_USERNAME" in os.environ: