From 267bb13f5548053f49a44c7b7fb7c57e6e749bf1 Mon Sep 17 00:00:00 2001 From: dianajlailaty Date: Thu, 25 Nov 2021 09:25:49 +0100 Subject: [PATCH] fixing FileNotFound error --- forecasting_gluonts/docker_image/run_gluonts.sh | 3 +-- forecasting_gluonts/gluonts_forecaster.py | 4 ++++ forecasting_gluonts/gluonts_listener.py | 8 ++++++++ forecasting_prophet/docker_image/run_prophet.sh | 4 ++-- forecasting_prophet/prophet_listener.py | 9 +++++++-- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/forecasting_gluonts/docker_image/run_gluonts.sh b/forecasting_gluonts/docker_image/run_gluonts.sh index f2be2058..ddb2a4ca 100644 --- a/forecasting_gluonts/docker_image/run_gluonts.sh +++ b/forecasting_gluonts/docker_image/run_gluonts.sh @@ -2,8 +2,7 @@ sudo docker rmi -f $(sudo docker images) # Build the image from dockerfile and clone the latest version of my code -sudo docker build . -t gitlab.ow2.org:4567/melodic/morphemic-preprocessor/gluonmachines:morphemic-rc1.5 - +docker build -t gitlab.ow2.org:4567/melodic/morphemic-preprocessor/gluonmachines:morphemic-rc1.5 -f ./forecasting_gluonts/docker_image/Dockerfile . # Test the image #sudo docker run -it --env-file variables.env gitlab.ow2.org:4567/melodic/morphemic-preprocessor/gluonmachines:morphemic-rc1.5 diff --git a/forecasting_gluonts/gluonts_forecaster.py b/forecasting_gluonts/gluonts_forecaster.py index 600e0349..52bc3e05 100644 --- a/forecasting_gluonts/gluonts_forecaster.py +++ b/forecasting_gluonts/gluonts_forecaster.py @@ -39,7 +39,11 @@ directory_path = "/morphemic_project/" def train(metric): + data_file_path = os.path.join(os.environ.get("DATA_PATH", "./"), f'{os.environ.get("APP_NAME", "demo")}.csv') + #while (not os.path.isfile(data_file_path)): + #sleep(30) + #logging.debug("Waiting for dataset to be loaded") dataset = pd.read_csv(data_file_path) gluonts_dataset = pd.DataFrame(columns=['ds', 'y']) diff --git a/forecasting_gluonts/gluonts_listener.py b/forecasting_gluonts/gluonts_listener.py index adfa37aa..cb6f3c42 100644 --- a/forecasting_gluonts/gluonts_listener.py +++ b/forecasting_gluonts/gluonts_listener.py @@ -40,6 +40,10 @@ def worker(self,body,metric): epoch_start= body["epoch_start"] predictionTimes[metric] = epoch_start + while (not os.path.isfile(directory_path+'models/gluonts_'+metric+".pkl")): + sleep(30) + logging.debug("Waiting for the trained model for metric: " + metric) + while(True): #if flags[metric] == 0: #epoch_start = predictionTimes[metric] @@ -134,6 +138,10 @@ class Gluonts(morphemic.handler.ModelHandler,messaging.listener.MorphemicListene def on_metrics_to_predict(self, body): dataset_preprocessor = CSVData(APP_NAME) dataset_preprocessor.prepare_csv() + data_file_path = os.path.join(os.environ.get("DATA_PATH", "./"), f'{os.environ.get("APP_NAME", "demo")}.csv') + while (not os.path.isfile(data_file_path)): + sleep(30) + logging.debug("Waiting for dataset to be loaded") logging.debug("DATASET DOWNLOADED") for r in body: diff --git a/forecasting_prophet/docker_image/run_prophet.sh b/forecasting_prophet/docker_image/run_prophet.sh index 26314ffd..fd152d14 100644 --- a/forecasting_prophet/docker_image/run_prophet.sh +++ b/forecasting_prophet/docker_image/run_prophet.sh @@ -2,7 +2,8 @@ sudo docker rmi -f $(sudo docker images) # Build the image from dockerfile and clone the latest version of my code -sudo docker build . -t gitlab.ow2.org:4567/melodic/morphemic-preprocessor/prophet:morphemic-rc1.5 +docker build -t gitlab.ow2.org:4567/melodic/morphemic-preprocessor/prophet:morphemic-rc1.5 -f ./forecasting_prophet/docker_image/Dockerfile . + # Test the image #sudo docker run -it --env-file variables.env gitlab.ow2.org:4567/melodic/morphemic-preprocessor/prophet:morphemic-rc1.5 @@ -12,4 +13,3 @@ sudo docker login gitlab.ow2.org:4567 sudo docker push gitlab.ow2.org:4567/melodic/morphemic-preprocessor/prophet:morphemic-rc1.5 - diff --git a/forecasting_prophet/prophet_listener.py b/forecasting_prophet/prophet_listener.py index 3bb822b8..d4aa0443 100644 --- a/forecasting_prophet/prophet_listener.py +++ b/forecasting_prophet/prophet_listener.py @@ -45,8 +45,9 @@ def worker(self,body,metric): predictionTimes[metric] = epoch_start messages=list() f=0 - if os.path.isfile(directory_path+'models/prophet_'+metric+".pkl"): - logging.debug("Loading the trained model for metric: " + metric) + while (not os.path.isfile(directory_path+'models/prophet_'+metric+".pkl")): + sleep(30) + logging.debug("Waiting for the trained model for metric: " + metric) while(True): #if flags[metric] == 0: @@ -136,6 +137,10 @@ class Prophet(morphemic.handler.ModelHandler,messaging.listener.MorphemicListene #getting data from datasetmaker dataset_preprocessor = CSVData(APP_NAME) dataset_preprocessor.prepare_csv() + data_file_path = os.path.join(os.environ.get("DATA_PATH", "./"), f'{os.environ.get("APP_NAME", "demo")}.csv') + while (not os.path.isfile(data_file_path)): + sleep(30) + logging.debug("Waiting for dataset to be loaded") logging.debug("DATASET DOWNLOADED") for r in body: -- GitLab