Refresh after features updated
This commit is contained in:
@ -7,6 +7,7 @@ from datetime import datetime, timedelta
|
|||||||
import os
|
import os
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import requests
|
||||||
|
|
||||||
import pyarrow as pa
|
import pyarrow as pa
|
||||||
import pyarrow.parquet as pq
|
import pyarrow.parquet as pq
|
||||||
@ -17,8 +18,21 @@ from features.user_history import generate_and_upload_user_history
|
|||||||
|
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
|
def call_refresh_api(api):
|
||||||
|
try:
|
||||||
|
response = requests.get(api, timeout=10)
|
||||||
|
if response.status_code == 200:
|
||||||
|
print("scoring service refreshed")
|
||||||
|
else:
|
||||||
|
print(f"failed to refresh scoring service: {response.status_code}")
|
||||||
|
except requests.exceptions.Timeout:
|
||||||
|
print(f"The request timed out after {timeout} seconds")
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
print(f"An error occurred while refreshing scoring service: {e}")
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
score_service = os.getenv("SCORING_SERVICE_URL")
|
||||||
num_days_history = os.getenv('NUM_DAYS_HISTORY')
|
num_days_history = os.getenv('NUM_DAYS_HISTORY')
|
||||||
gcs_bucket_name = os.getenv('GCS_BUCKET')
|
gcs_bucket_name = os.getenv('GCS_BUCKET')
|
||||||
|
|
||||||
@ -29,6 +43,9 @@ def main():
|
|||||||
extract_and_upload_raw_data(execution_date, num_days_history, gcs_bucket_name)
|
extract_and_upload_raw_data(execution_date, num_days_history, gcs_bucket_name)
|
||||||
generate_and_upload_user_history(execution_date, gcs_bucket_name)
|
generate_and_upload_user_history(execution_date, gcs_bucket_name)
|
||||||
|
|
||||||
|
if score_service:
|
||||||
|
call_refresh_api(score_service)
|
||||||
|
|
||||||
print("done")
|
print("done")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user