Snt25 659 incidence - #126
Open
EstebanMontandon wants to merge 4 commits into
Open
EstebanMontandon wants to merge 4 commits into
EstebanMontandon wants to merge 4 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates
snt_dhis2_incidence's computation script (snt_dhis2_incidence.ipynb+snt_dhis2_incidence.r) off its bespoke setup helpers onto the sharedinit_snt_workspace()/load_snt_config()/load_dataset_file()pattern, and fixes two latent bugs surfaced along the way.load_utils()/setup_paths()/create_intermediate_data_dir()/install_and_load()/set_env_openhexa()/import_config_json()/config_generic()/config_incidence()/set_fixed_cols()withinit_snt_workspace()+load_snt_config()(fromcode/snt_utils.r) and equivalent inline config assignments. Output paths (INTERMEDIATE_DATA_PATH,DATA_PATH) are unchanged in practice.read_csv(CARESEEKING_FILE_PATH, ...)is now wrapped intryCatch— a corrupted/malformed user-provided file now falls back to DHS data instead of stopping the pipeline. Also simplified the two-flagIMPORTED_CARESEEKING_FROM_FILE/IMPORTED_CARESEEKING_FROM_DHStracking down to one flag, since "not from file" now unambiguously means "from DHS."join_careseeking_data()silently continued on bad input. When neitherADM1_IDnorADM2_IDis present, it nowstop()s with a clear message instead of logging an"error"severity and falling through to a confusing downstream crash.check_fixed_cols_in_routine(),check_dhis2_indicators_cols_in_routine(),check_pres_col()(renamed fromcheck_PRES_col),load_population_data(),select_routine_dataset_and_filename(), andprepare_disaggregated_indicators()'s call site now take/return explicit values instead of reading or writing globals implicitly.build_monthly_cases()/build_yearly_incidence()were unused (the notebook has always used inline equivalent logic) and had already drifted from it.coherence_checkes_yearly_incidence()→coherence_check_yearly_incidence().Follow-up (not fixed in this PR)
snt_dhis2_incidence.rstill has ~18 functions that set globals via<<-instead of returning a value (prepare_disaggregated_indicators(),select_population_column(),load_dhs_careseeking_data(),load_reporting_rate_data(),check_reporting_rate_data(),enforce_numeric_cols(),handle_zeros_in_reporting_rate(), and thecoherence_check_*()family), whichsnt_dhis2_incidence.ipynbthen reads back out of the global environment.We should try to avoid functions that set global variables the notebook reads back later in an obscure way , at the end this tends to hide side effects behind what looks like a simple call, and makes debugging harder since the cause of a bug can be several cells away from where it surfaces (missing references to variables secretly created). We should also aim for generic, reusable functions instead of wrapping notebook cell computations.