From d4170361d616b1022dc553e90c971ed109c7ecbc Mon Sep 17 00:00:00 2001 From: William May Date: Fri, 20 Sep 2024 13:29:49 +0100 Subject: [PATCH] Working out which Pathfinders validation constants are likely to persist between rounds and which are likely to be round-specific and moving around accordingly --- .../table_extraction/config/pf_r1_config.py | 2 +- .../{schema_validation => }/consts.py | 63 ------------------- .../cross_table_validation/ct_validate_r1.py | 2 +- .../validation/pathfinders/r1_consts.py | 61 ++++++++++++++++++ .../pathfinders/schema_validation/checks.py | 2 +- 5 files changed, 64 insertions(+), 66 deletions(-) rename data_store/validation/pathfinders/{schema_validation => }/consts.py (57%) create mode 100644 data_store/validation/pathfinders/r1_consts.py diff --git a/data_store/table_extraction/config/pf_r1_config.py b/data_store/table_extraction/config/pf_r1_config.py index 61060505f..22286e100 100644 --- a/data_store/table_extraction/config/pf_r1_config.py +++ b/data_store/table_extraction/config/pf_r1_config.py @@ -3,6 +3,7 @@ the data. """ +from data_store.validation.pathfinders.r1_consts import PFEnums from data_store.validation.pathfinders.schema_validation import checks from data_store.validation.pathfinders.schema_validation.columns import ( datetime_column, @@ -10,7 +11,6 @@ int_column, string_column, ) -from data_store.validation.pathfinders.schema_validation.consts import PFEnums PF_TABLE_CONFIG: dict[str, dict[str, dict]] = { "Reporting period": { diff --git a/data_store/validation/pathfinders/schema_validation/consts.py b/data_store/validation/pathfinders/consts.py similarity index 57% rename from data_store/validation/pathfinders/schema_validation/consts.py rename to data_store/validation/pathfinders/consts.py index 0139a8391..937fb638c 100644 --- a/data_store/validation/pathfinders/schema_validation/consts.py +++ b/data_store/validation/pathfinders/consts.py @@ -10,69 +10,6 @@ class PFRegex: ) -class PFEnums: - """ - Lists of allowed values used for validation of dropdown fields in Pathfinders reporting template. - """ - - ACTUAL_FORECAST = ["Actual", "Forecast", "Cancelled"] - INTERVENTION_THEMES = [ - "Employment & Education", - "Enhancing subregional and regional connectivity", - "Improving the quality of life of residents", - "Strengthening the visitor and local service economy", - "Unlocking and enabling industrial, commercial, and residential development", - "Unlocking and enabling industrial and commercial development", - ] - RAGS = ["Green", "Amber/Green", "Amber", "Amber/Red", "Red"] - REPORTING_PERIOD = [ - "Q4 2023/24: Jan 2024 - Mar 2024", - "Q1 2024/25: Apr 2024 - Jun 2024", - "Q2 2024/25: Jul 2024 - Sep 2024", - "Q3 2024/25: Oct 2024 - Dec 2024", - "Q4 2024/25: Jan 2025 - Mar 2025", - "Q1 2025/26: Apr 2025 - Jun 2025", - "Q2 2025/26: Jul 2025 - Sep 2025", - "Q3 2025/26: Oct 2025 - Dec 2025", - "Q4 2025/26: Jan 2026 - Mar 2026", - ] - RISK_CATEGORIES = [ - "Arm’s length body risks", - "Commercial or procurement risks", - "Delivery Partner", - "Financial flexibility", - "Financial risks", - "Governance risks", - "Legal, regulatory or compliance risks", - "Local government risks", - "Operational process or control risks", - "People risks", - "Planning Permission / other consents", - "Political sensitivity", - "Procurement / contracting", - "Programme or project delivery risks", - "Reputational Risk", - "Resilience risks", - "Resource & Expertise", - "Security risks", - "Slippage", - "Strategy risks", - "Subsidy Control", - "System or IT infrastructure risks", - "Other", - ] - RISK_SCORES = ["1 - Very Low", "2 - Low", "3 - Medium", "4 - High", "5 - Very High"] - SPEND_TYPE = [ - "How much of your forecast is contractually committed?", - "How much of your forecast is not contractually committed?", - "Freedom and flexibilities spend", - "Total DLUHC spend (inc. F&F)", - "Secured match funding spend", - "Unsecured match funding", - "Total match", - ] - - class PFErrors: """ Error messages for Pathfinders reporting template validation. diff --git a/data_store/validation/pathfinders/cross_table_validation/ct_validate_r1.py b/data_store/validation/pathfinders/cross_table_validation/ct_validate_r1.py index 3dada5eb4..7fe0e7baf 100644 --- a/data_store/validation/pathfinders/cross_table_validation/ct_validate_r1.py +++ b/data_store/validation/pathfinders/cross_table_validation/ct_validate_r1.py @@ -14,8 +14,8 @@ from data_store.messaging import Message from data_store.transformation.pathfinders.consts import PF_REPORTING_PERIOD_TO_DATES_PFCS +from data_store.validation.pathfinders.consts import PFErrors from data_store.validation.pathfinders.cross_table_validation import common -from data_store.validation.pathfinders.schema_validation.consts import PFErrors def cross_table_validate(extracted_table_dfs: dict[str, pd.DataFrame]) -> list[Message]: diff --git a/data_store/validation/pathfinders/r1_consts.py b/data_store/validation/pathfinders/r1_consts.py new file mode 100644 index 000000000..ac5616607 --- /dev/null +++ b/data_store/validation/pathfinders/r1_consts.py @@ -0,0 +1,61 @@ +class PFEnums: + """ + Lists of allowed values used for validation of dropdown fields in Pathfinders R1 reporting template. + """ + + ACTUAL_FORECAST = ["Actual", "Forecast", "Cancelled"] + INTERVENTION_THEMES = [ + "Employment & Education", + "Enhancing subregional and regional connectivity", + "Improving the quality of life of residents", + "Strengthening the visitor and local service economy", + "Unlocking and enabling industrial, commercial, and residential development", + "Unlocking and enabling industrial and commercial development", + ] + RAGS = ["Green", "Amber/Green", "Amber", "Amber/Red", "Red"] + REPORTING_PERIOD = [ + "Q4 2023/24: Jan 2024 - Mar 2024", + "Q1 2024/25: Apr 2024 - Jun 2024", + "Q2 2024/25: Jul 2024 - Sep 2024", + "Q3 2024/25: Oct 2024 - Dec 2024", + "Q4 2024/25: Jan 2025 - Mar 2025", + "Q1 2025/26: Apr 2025 - Jun 2025", + "Q2 2025/26: Jul 2025 - Sep 2025", + "Q3 2025/26: Oct 2025 - Dec 2025", + "Q4 2025/26: Jan 2026 - Mar 2026", + ] + RISK_CATEGORIES = [ + "Arm’s length body risks", + "Commercial or procurement risks", + "Delivery Partner", + "Financial flexibility", + "Financial risks", + "Governance risks", + "Legal, regulatory or compliance risks", + "Local government risks", + "Operational process or control risks", + "People risks", + "Planning Permission / other consents", + "Political sensitivity", + "Procurement / contracting", + "Programme or project delivery risks", + "Reputational Risk", + "Resilience risks", + "Resource & Expertise", + "Security risks", + "Slippage", + "Strategy risks", + "Subsidy Control", + "System or IT infrastructure risks", + "Other", + ] + RISK_SCORES = ["1 - Very Low", "2 - Low", "3 - Medium", "4 - High", "5 - Very High"] + SPEND_TYPE = [ + "How much of your forecast is contractually committed?", + "How much of your forecast is not contractually committed?", + "Freedom and flexibilities spend", + "Total DLUHC spend (inc. F&F)", + "Secured match funding spend", + "Unsecured match funding", + "Total match", + ] diff --git a/data_store/validation/pathfinders/schema_validation/checks.py b/data_store/validation/pathfinders/schema_validation/checks.py index 2aa29ab42..ee01e5739 100644 --- a/data_store/validation/pathfinders/schema_validation/checks.py +++ b/data_store/validation/pathfinders/schema_validation/checks.py @@ -26,7 +26,7 @@ import pandera as pa from data_store.transformation.utils import POSTCODE_REGEX -from data_store.validation.pathfinders.schema_validation.consts import PFErrors, PFRegex +from data_store.validation.pathfinders.consts import PFErrors, PFRegex def _should_fail_check_because_element_is_nan(element) -> Literal[True] | None: