diff --git a/MLOps/app/python_schedule/data/crowd_prediction.dvc b/MLOps/app/python_schedule/data/crowd_prediction.dvc index d546ada..d6a4ca3 100644 --- a/MLOps/app/python_schedule/data/crowd_prediction.dvc +++ b/MLOps/app/python_schedule/data/crowd_prediction.dvc @@ -1,6 +1,6 @@ outs: -- md5: 0be6d0fb525854e0eb50f8b6b5b36ee9.dir - size: 51945 - nfiles: 5 +- md5: b6aa6e2c1879672a76771b3767445a62.dir + size: 261447 + nfiles: 25 hash: md5 path: crowd_prediction diff --git a/MLOps/app/services/predict_cong_service.py b/MLOps/app/services/predict_cong_service.py index b887869..9b3e007 100644 --- a/MLOps/app/services/predict_cong_service.py +++ b/MLOps/app/services/predict_cong_service.py @@ -112,12 +112,16 @@ def predict_and_save_all_locations(): print("No predictions were made.") return + # PRED_PATH가 설정되지 않았을 경우에 대한 예외 처리 + if not PRED_PATH: + print("❌ PRED_PATH environment variable is not set. Cannot save files.") + return + + # 저장 경로가 존재하는지 확인하고, 없으면 생성합니다. + os.makedirs(PRED_PATH, exist_ok=True) + # 타임스탬프 (현재 시간 + 1시간) timestamp = (datetime.now() + timedelta(hours=1)).strftime("%Y%m%d%H") - output_dir = PRED_PATH if PRED_PATH and os.path.isdir(PRED_PATH) else os.path.dirname(__file__) - - # 저장된 파일 경로들을 저장할 리스트 - saved_files = [] for name, predictions_list in all_predictions.items(): if not predictions_list: @@ -135,13 +139,10 @@ def predict_and_save_all_locations(): file_suffix = MODEL_FILE_SUFFIX.get(name) output_filename = f"congestion_predictions_{timestamp}_{file_suffix}.csv" - output_path = os.path.join(output_dir, output_filename) + output_path = os.path.join(PRED_PATH, output_filename) final_df.to_csv(output_path, index=False, encoding='utf-8-sig') print(f"✅ Predictions for '{name}' saved to: {output_path}") - saved_files.append(output_path) - - return saved_files if __name__ == "__main__": print("Congestion prediction service started.") diff --git a/MLOps/docker-compose.yml b/MLOps/docker-compose.yml index b118dd1..9c16686 100644 --- a/MLOps/docker-compose.yml +++ b/MLOps/docker-compose.yml @@ -31,7 +31,6 @@ services: environment: - TZ=Asia/Seoul - PYTHONUNBUFFERED=1 - - PRED_PATH=/app/app/services/python_schedule/data/crowd_prediction volumes: - ./app:/app/app - /home/ubuntu/MLOps/data:/app/data