From c92f346b08b29aba00571616a50047d9524717cf Mon Sep 17 00:00:00 2001 From: AGibson <4319494+annajgibson@users.noreply.github.com> Date: Mon, 10 Nov 2025 14:38:59 +0000 Subject: [PATCH 1/2] Amend GX test for people data load column ordering; add error handling for main apply script --- ...housing_nec_migration_apply_gx_dq_tests.py | 12 ++++- ...nec_migration_people_data_load_gx_suite.py | 44 +++++++++---------- 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/scripts/jobs/housing/housing_nec_migration_apply_gx_dq_tests.py b/scripts/jobs/housing/housing_nec_migration_apply_gx_dq_tests.py index bb1a49bcb..f3e9a504c 100644 --- a/scripts/jobs/housing/housing_nec_migration_apply_gx_dq_tests.py +++ b/scripts/jobs/housing/housing_nec_migration_apply_gx_dq_tests.py @@ -133,9 +133,17 @@ def main(): table_results_df["unexpected_id_list"] = pd.Series(dtype="object") for i, row in query_df.iterrows(): - table_results_df.loc[i, "unexpected_id_list"] = str( + try: list(df[id_field].iloc[row["result.unexpected_index_list"]]) - ) + except Exception as e: + print( + f"Problem found with {table}: {e}, skipping making unexpected_id_list." + ) + continue + else: + table_results_df.loc[i, "unexpected_id_list"] = str( + list(df[id_field].iloc[row["result.unexpected_index_list"]]) + ) # drop columns not needed in metatdata cols_to_drop_meta = [ diff --git a/scripts/jobs/housing/housing_nec_migration_people_data_load_gx_suite.py b/scripts/jobs/housing/housing_nec_migration_people_data_load_gx_suite.py index accc989ea..7b0d0fd90 100644 --- a/scripts/jobs/housing/housing_nec_migration_people_data_load_gx_suite.py +++ b/scripts/jobs/housing/housing_nec_migration_people_data_load_gx_suite.py @@ -41,35 +41,35 @@ class ExpectTitleToBeInSet(gxe.ExpectColumnValuesToBeInSet): class ExpectPeopleColumnsToMatchOrderedList(gxe.ExpectTableColumnsToMatchOrderedList): column_list = [ - "LPAR_TIN_HRV_TIR_CODE", - "LPAR_TIN_STAT_SUCCESSOR_IND", - "LPAR_TIN_START_DATE", - "LPAR_TIN_MAIN_TENANT_IND", - "LPAR_TIN_END_DATE", - "LPAR_TCY_IND", + "LPAR_HOP_START_DATE", + "LPAR_PER_SURNAME", "LPAR_TCY_ALT_REF", - "LPAR_PHONE", + "LPAR_PER_FORENAME", + "LPAR_HOP_HPSR_CODE", "LPAR_PER_TITLE", - "LPAR_PER_SURNAME", - "LPAR_PER_OTHER_NAME", - "LPAR_PER_NI_NO", "LPAR_PER_INITIALS", - "LPAR_PER_HOU_OAP_IND", - "LPAR_PER_HOU_HRV_HMS_CODE", - "LPAR_PER_HOU_EMPLOYER", + "LPAR_PER_DATE_OF_BIRTH", "LPAR_PER_HOU_DISABLED_IND", - "LPAR_PER_FRV_HGO_CODE", - "LPAR_PER_FRV_FNL_CODE", + "LPAR_PER_HOU_OAP_IND", "LPAR_PER_FRV_FGE_CODE", - "LPAR_PER_FRV_FEO_CODE", - "LPAR_PER_FORENAME", - "LPAR_PER_DATE_OF_BIRTH", - "LPAR_PER_ALT_REF", - "LPAR_HOP_START_DATE", "LPAR_HOP_HRV_REL_CODE", - "LPAR_HOP_HPSR_CODE", - "LPAR_HOP_HPER_CODE", + "LPAR_PER_HOU_EMPLOYER", + "LPAR_PER_HOU_HRV_HMS_CODE", + "LPAR_PHONE", "LPAR_HOP_END_DATE", + "LPAR_HOP_HPER_CODE", + "LPAR_TCY_IND", + "LPAR_TIN_MAIN_TENANT_IND", + "LPAR_TIN_START_DATE", + "LPAR_TIN_END_DATE", + "PAR_TIN_HRV_TIR_CODE", + "LPAR_TIN_STAT_SUCCESSOR_IND", + "LPAR_PER_ALT_REF", + "LPAR_PER_FRV_FEO_CODE", + "LPAR_PER_NI_NO", + "LPAR_PER_FRV_HGO_CODE", + "LPAR_PER_FRV_FNL_CODE", + "LPAR_PER_OTHER_NAME", ] description: str = "Expect people load columns to match ordered list exactly" From 2f80da346080393eaae40b0ef0d285b77afdd991 Mon Sep 17 00:00:00 2001 From: AGibson <4319494+annajgibson@users.noreply.github.com> Date: Mon, 10 Nov 2025 14:45:15 +0000 Subject: [PATCH 2/2] replace print with logger --- .../jobs/housing/housing_nec_migration_apply_gx_dq_tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/jobs/housing/housing_nec_migration_apply_gx_dq_tests.py b/scripts/jobs/housing/housing_nec_migration_apply_gx_dq_tests.py index f3e9a504c..03eb53f97 100644 --- a/scripts/jobs/housing/housing_nec_migration_apply_gx_dq_tests.py +++ b/scripts/jobs/housing/housing_nec_migration_apply_gx_dq_tests.py @@ -73,7 +73,7 @@ def main(): try: df = pd.read_sql_query(sql_query, conn) except Exception as e: - print(f"Problem found with {table}: {e}, skipping table.") + logger.info(f"Problem found with {table}: {e}, skipping table.") continue # set up batch @@ -136,7 +136,7 @@ def main(): try: list(df[id_field].iloc[row["result.unexpected_index_list"]]) except Exception as e: - print( + logger.info( f"Problem found with {table}: {e}, skipping making unexpected_id_list." ) continue