From dedb2de6718fb5472921d42f2bb86c03f2f1a5ab Mon Sep 17 00:00:00 2001 From: Vincent Date: Tue, 13 Aug 2024 18:13:07 +0200 Subject: [PATCH] Register and schedule email_actions_to_units flow --- datascience/.env.template | 6 ++++++ datascience/config.py | 11 +++++++++++ datascience/src/pipeline/flows_config.py | 16 ++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/datascience/.env.template b/datascience/.env.template index 7fc4c71f2f..95d7a7d2f2 100644 --- a/datascience/.env.template +++ b/datascience/.env.template @@ -71,3 +71,9 @@ PREFECT_SERVER_URL= # data.gouv.fr DATAGOUV_API_KEY= + +# Test modes +IS_INTEGRATION= +TEST_MODE= +PNO_TEST_MODE= +WEEKLY_CONTROL_REPORT_EMAIL_TEST_MODE= \ No newline at end of file diff --git a/datascience/config.py b/datascience/config.py index 8c1e1541c1..3bfd1534ad 100644 --- a/datascience/config.py +++ b/datascience/config.py @@ -68,6 +68,17 @@ "y", ) +# Must be set to true to send prior notifications to the FMC, and +# not to real addressees (control units) +WEEKLY_CONTROL_REPORT_EMAIL_TEST_MODE = os.getenv( + "WEEKLY_CONTROL_REPORT_EMAIL_TEST_MODE", "False" +).lower() in ( + "true", + "t", + "yes", + "y", +) + # Flow execution configuration DOCKER_IMAGE = "docker.pkg.github.com/mtes-mct/monitorfish/monitorfish-pipeline" MONITORFISH_VERSION = os.getenv("MONITORFISH_VERSION") diff --git a/datascience/src/pipeline/flows_config.py b/datascience/src/pipeline/flows_config.py index c2c5e48fc9..d33827b06a 100644 --- a/datascience/src/pipeline/flows_config.py +++ b/datascience/src/pipeline/flows_config.py @@ -19,6 +19,7 @@ PNO_TEST_MODE, ROOT_DIRECTORY, TEST_MODE, + WEEKLY_CONTROL_REPORT_EMAIL_TEST_MODE, ) from src.pipeline.flows import ( admin_areas, @@ -32,6 +33,7 @@ current_segments, distribute_pnos, districts, + email_actions_to_units, enrich_logbook, enrich_positions, facade_areas, @@ -88,6 +90,19 @@ ), ] ) +email_actions_to_units.flow.schedule = Schedule( + clocks=[ + clocks.CronClock( + "0 5 * * 1", + parameter_defaults={ + "start_days_ago": 7, + "end_days_ago": 1, + "test_mode": WEEKLY_CONTROL_REPORT_EMAIL_TEST_MODE, + "is_integration": IS_INTEGRATION, + }, + ), + ] +) enrich_logbook.flow.schedule = Schedule( clocks=[ clocks.CronClock( @@ -299,6 +314,7 @@ current_segments.flow, distribute_pnos.flow, districts.flow, + email_actions_to_units.flow, enrich_logbook.flow, enrich_positions.flow, logbook.flow,