diff --git a/DAG-insert-elk-sirene.py b/DAG-insert-elk-sirene.py index 887c927c..44ba6114 100755 --- a/DAG-insert-elk-sirene.py +++ b/DAG-insert-elk-sirene.py @@ -110,9 +110,9 @@ # on_failure_callback=send_notification_failure_tchap, max_active_runs=1, ) as dag: - # get_colors = PythonOperator( - # task_id="get_colors", provide_context=True, python_callable=get_colors - # ) + get_colors = PythonOperator( + task_id="get_colors", provide_context=True, python_callable=get_colors + ) clean_previous_folder = CleanFolderOperator( task_id="clean_previous_folder", @@ -362,7 +362,7 @@ # python_callable=send_notification_success_tchap, # ) - # clean_previous_folder.set_upstream(get_colors) + clean_previous_folder.set_upstream(get_colors) create_sqlite_database.set_upstream(clean_previous_folder) create_unite_legale_table.set_upstream(create_sqlite_database) diff --git a/task_functions/get_colors.py b/task_functions/get_colors.py index 224a1f95..d58476c5 100644 --- a/task_functions/get_colors.py +++ b/task_functions/get_colors.py @@ -6,14 +6,17 @@ def get_colors(**kwargs): - try: - with urlopen(COLOR_URL, timeout=5) as url: - data = json.loads(url.read().decode()) - next_color = data["NEXT_COLOR"] - current_color = data["CURRENT_COLOR"] - logging.info(f"******************** Color file URL: {COLOR_URL}") - logging.info(f"******************** Next color from file: {next_color}") - kwargs["ti"].xcom_push(key="next_color", value=next_color) - kwargs["ti"].xcom_push(key="current_color", value=current_color) - except BaseException as error: - raise Exception(f"******************** Ouuups Error: {error}") + kwargs["ti"].xcom_push(key="next_color", value="20231122") + kwargs["ti"].xcom_push(key="current_color", value="green") + + # try: + # with urlopen(COLOR_URL, timeout=5) as url: + # data = json.loads(url.read().decode()) + # next_color = data["NEXT_COLOR"] + # current_color = data["CURRENT_COLOR"] + # logging.info(f"******************** Color file URL: {COLOR_URL}") + # logging.info(f"******************** Next color from file: {next_color}") + # kwargs["ti"].xcom_push(key="next_color", value=next_color) + # kwargs["ti"].xcom_push(key="current_color", value=current_color) + # except BaseException as error: + # raise Exception(f"******************** Ouuups Error: {error}") diff --git a/task_functions/update_color_file.py b/task_functions/update_color_file.py index 04c3cf97..c3a74534 100644 --- a/task_functions/update_color_file.py +++ b/task_functions/update_color_file.py @@ -12,6 +12,8 @@ def update_color_file(**kwargs): + return + next_color = kwargs["ti"].xcom_pull(key="next_color", task_ids="get_colors") current_color = kwargs["ti"].xcom_pull(key="current_color", task_ids="get_colors") colors = {"CURRENT_COLOR": next_color, "NEXT_COLOR": current_color}