Skip to content

Commit

Permalink
서빙에 영향을 주지 않는 로깅은 비동기로 처리하도록 변경 #85
Browse files Browse the repository at this point in the history
  • Loading branch information
twndus committed Apr 7, 2024
1 parent 29269ae commit 134e15f
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions airflow/dags/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import threading # threading 라이브러리 추가

from db_operations import fetch_user_history, update_model_recommendations, cb_inference, blending_results
from _recbole_inference import Inference #sasrec_inference
from _recbole_inference import Inference

@bentoml.service(
resources={"cpu": "6"},
Expand Down Expand Up @@ -35,25 +35,15 @@ def recommend(self, user_id: str):
cb_data = cb_inference(cb_data)

data = blending_results(hybrid_data, cb_data)

update_model_recommendations(
data,
collection_name='model_recommendation_history_total',
input_type='recipe_id',
meta={'model_version': '0.0.1'},
)

# # hybrid save
# update_model_recommendations(
# hybrid_data,
# collection_name='model_recommendation_history_hybrid',
# )
# # cb save
# update_model_recommendations(
# cb_data,
# collection_name='model_recommendation_history_cb',
# input_type='recipe_id'
# )
#
# 비동기로 DB에 결과 기록
threading.Thread(target=self.save_data_async, args=(hybrid_data, 'model_recommendation_history_hybrid',)).start()
threading.Thread(target=self.save_data_async, args=(cb_data, 'model_recommendation_history_cb', 'recipe_id',)).start()

Expand Down

0 comments on commit 134e15f

Please sign in to comment.