Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource file path from simulation #1410

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
6cbd941
#Read function and enhanced lifestyle
jkumwenda Jul 2, 2024
041ab47
Updated the resource file path and register function in simulation.py
jkumwenda Jul 4, 2024
9129f4e
Implemented resourcefilepath for Disease modules to get resource file…
jkumwenda Jul 4, 2024
3f07713
RTI and associated modules
thewati Jul 30, 2024
57870a3
Schisto and associated modules
thewati Jul 31, 2024
fc66ff1
analysis_malaria and associated files
thewati Aug 8, 2024
8815e89
analysis file of hiv and associated file, fixed test_schisto
thewati Aug 8, 2024
3dbe968
epi analyses and associated files, removed unused import in analysis rti
thewati Aug 9, 2024
414dbbb
diarhhhoea analyses and associated files, removed unused import in an…
thewati Aug 9, 2024
b813ac3
analyses_copd_prev and associated files
thewati Aug 14, 2024
73bac49
alri analyses and associated files, fixed test_enhanced_lifestyle.py
thewati Aug 15, 2024
e64735e
prostate_cancer_analyses_logging and associated files, fixed test_hea…
thewati Aug 16, 2024
64a0c7b
other_adult_cancers_analyses_logging and associated files, isort pros…
thewati Aug 19, 2024
6e6be58
analysis_measles.py measles.py test_measles.py fixed for resource fil…
jkumwenda Aug 20, 2024
166ad35
analysis_measles_deaths.py fixed for resource file path from simulati…
jkumwenda Aug 20, 2024
78ad0be
analysis_measles.py removed unused from pathlib import Path .
jkumwenda Aug 22, 2024
690a1f7
breast_cancer_analyses_logging.py calc_5y_survival_following_treatmen…
jkumwenda Aug 22, 2024
0c9dabc
breast_cancer_analyses_logging.py calc_5y_survival_following_treatmen…
jkumwenda Aug 22, 2024
ae6309b
breast_cancer_analyses_logging.py calc_5y_survival_following_treatmen…
jkumwenda Aug 22, 2024
0621041
bladder_cancer_analyses_single_run, calc_5y and associated files, con…
thewati Aug 23, 2024
16e026d
fix resourcefilepath for test_beddays and test_cons
thewati Aug 26, 2024
1cb1b88
fix test_demography and associated files, fixed fullmodel file
thewati Aug 26, 2024
e5335df
fix test utils, labour and newborn_outcomes
thewati Aug 27, 2024
0adaec0
fix test_postnatal, pregnancy_supervisor, htm_scaleup, rmv unused imp…
thewati Aug 28, 2024
b045536
fix test healthburden, control_order_of_events, maternal_health_helpe…
thewati Aug 29, 2024
0acf363
oesophageal cancer survival_following_treatment, analyses_depression_…
thewati Aug 29, 2024
7757a8f
cardiometabolicdisorders_plots(NR) and associated files, test symptom…
thewati Aug 30, 2024
354321f
tb (NR), stunting (NR) analyses and associated files
thewati Aug 30, 2024
f441dc0
fix tests epi and simplified_births
thewati Sep 2, 2024
ea878eb
all remaining NR anayses
thewati Sep 2, 2024
0af6c2e
fix tests contraception, module_dependencies, fullmodel and determini…
thewati Sep 3, 2024
56f26b6
fix tests logging_end_to_end, basic_sims, find_events, breast_cancer
thewati Sep 4, 2024
43b195b
fix tests healthsystem, analysis
thewati Sep 4, 2024
bfc8e32
Merge branch 'master' into jkumwenda/resource_file_path
thewati Sep 5, 2024
9559acf
fix failing tests after merging
thewati Sep 5, 2024
c660f69
Merge branch 'master' into jkumwenda/resource_file_path
thewati Sep 27, 2024
cdd90be
to be debugged
thewati Sep 27, 2024
99c1c7c
update simulation file
thewati Sep 30, 2024
7eb8e0a
Merge remote-tracking branch 'origin/jkumwenda/resource_file_path' in…
thewati Sep 30, 2024
5c9a9ad
update the simulation file
thewati Sep 30, 2024
4184764
fix errors in scenario and tes_sim
thewati Sep 30, 2024
ea16635
update to scenario and tlo_parameters
thewati Oct 2, 2024
98873e5
fix test_module_dependencies, health_system, simulation
thewati Oct 3, 2024
fc5f5c6
fix scripts
thewati Oct 3, 2024
d5ed651
fix hiv_tb_calibration file res access, and test to check resourcefil…
thewati Oct 4, 2024
2cd182d
remove unexpected resourcefilepath in simulation
thewati Oct 5, 2024
c8adb0c
Merge branch 'master' into jkumwenda/resource_file_path
mnjowe Oct 8, 2024
4e14f59
review resourcefilepath in sim and rmv spaces in scenario
thewati Oct 9, 2024
481ee3f
Rollback scenario.py
thewati Oct 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/tlo_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,11 @@ def write_parameters_file(
)
args = parser.parse_args()
simulation = Simulation(
start_date=Date(2010, 1, 1), seed=1234, log_config={"suppress_stdout": True}
start_date=Date(2010, 1, 1), seed=1234, log_config={"suppress_stdout": True},
resourcefilepath=args.resource_file_path
)
status_quo_parameters = get_parameters_for_status_quo()
simulation.register(*fullmodel.fullmodel(args.resource_file_path))
simulation.register(*fullmodel.fullmodel())
internal_link_formatter = _formatters[args.output_file_path.suffix]["internal_link"]
character_escaper = _formatters[args.output_file_path.suffix]["character_escaper"]
module_parameter_tables, module_structured_parameters = get_parameter_tables(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@
seed = random.randint(0, 50000)

# Establish the simulation object
sim = Simulation(start_date=start_date, seed=seed, log_config=log_config, show_progress_bar=True)
sim = Simulation(start_date=start_date, seed=seed, log_config=log_config,
show_progress_bar=True, resourcefilepath=resourcefilepath)

# run the simulation
sim.register(
demography.Demography(resourcefilepath=resourcefilepath),
enhanced_lifestyle.Lifestyle(resourcefilepath=resourcefilepath),
symptommanager.SymptomManager(resourcefilepath=resourcefilepath),
healthseekingbehaviour.HealthSeekingBehaviour(resourcefilepath=resourcefilepath),
healthburden.HealthBurden(resourcefilepath=resourcefilepath),
simplified_births.SimplifiedBirths(resourcefilepath=resourcefilepath),
healthsystem.HealthSystem(resourcefilepath=resourcefilepath,
service_availability=['*']),
alri.Alri(resourcefilepath=resourcefilepath),
demography.Demography(),
enhanced_lifestyle.Lifestyle(),
symptommanager.SymptomManager(),
healthseekingbehaviour.HealthSeekingBehaviour(),
healthburden.HealthBurden(),
simplified_births.SimplifiedBirths(),
healthsystem.HealthSystem(service_availability=['*']),
alri.Alri(),
alri.AlriPropertiesOfOtherModules()
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,19 @@
}

# Establish the simulation object
sim = Simulation(start_date=start_date, log_config=log_config, show_progress_bar=True)
sim = Simulation(start_date=start_date, log_config=log_config,
show_progress_bar=True, resourcefilepath=resourcefilepath)

# run the simulation
sim.register(
demography.Demography(resourcefilepath=resourcefilepath),
enhanced_lifestyle.Lifestyle(resourcefilepath=resourcefilepath),
symptommanager.SymptomManager(resourcefilepath=resourcefilepath),
healthseekingbehaviour.HealthSeekingBehaviour(resourcefilepath=resourcefilepath),
healthburden.HealthBurden(resourcefilepath=resourcefilepath),
simplified_births.SimplifiedBirths(resourcefilepath=resourcefilepath),
healthsystem.HealthSystem(resourcefilepath=resourcefilepath, disable=True),
alri.Alri(resourcefilepath=resourcefilepath),
demography.Demography(),
enhanced_lifestyle.Lifestyle(),
symptommanager.SymptomManager(),
healthseekingbehaviour.HealthSeekingBehaviour(),
healthburden.HealthBurden(),
simplified_births.SimplifiedBirths(),
healthsystem.HealthSystem(disable=True),
alri.Alri(),
alri.AlriPropertiesOfOtherModules()
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,18 @@
_disable_and_reject_all = False

# add file handler for the purpose of logging
sim = Simulation(start_date=start_date, log_config=log_config, show_progress_bar=True)
sim = Simulation(start_date=start_date, log_config=log_config,
show_progress_bar=True, resourcefilepath=resourcefilepath)

sim.register(
demography.Demography(resourcefilepath=resourcefilepath),
enhanced_lifestyle.Lifestyle(resourcefilepath=resourcefilepath),
simplified_births.SimplifiedBirths(resourcefilepath=resourcefilepath),
symptommanager.SymptomManager(resourcefilepath=resourcefilepath),
healthseekingbehaviour.HealthSeekingBehaviour(resourcefilepath=resourcefilepath,
force_any_symptom_to_lead_to_healthcareseeking=True),
healthburden.HealthBurden(resourcefilepath=resourcefilepath),
healthsystem.HealthSystem(resourcefilepath=resourcefilepath,
disable=_disable,
disable_and_reject_all=_disable_and_reject_all),

alri.Alri(resourcefilepath=resourcefilepath),
demography.Demography(),
enhanced_lifestyle.Lifestyle(),
simplified_births.SimplifiedBirths(),
symptommanager.SymptomManager(),
healthseekingbehaviour.HealthSeekingBehaviour(force_any_symptom_to_lead_to_healthcareseeking=True),
healthburden.HealthBurden(),
healthsystem.HealthSystem(disable=_disable, disable_and_reject_all=_disable_and_reject_all),
alri.Alri(),
alri.AlriPropertiesOfOtherModules()
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,19 @@ def get_sim(popsize):
"""Return a simulation (composed of only <5 years old) that has run for 0 days."""
resourcefilepath = Path('./resources')
start_date = Date(2010, 1, 1)
sim = Simulation(start_date=start_date, seed=0)
sim = Simulation(start_date=start_date, seed=0, resourcefilepath=resourcefilepath)

sim.register(
demography.Demography(resourcefilepath=resourcefilepath),
simplified_births.SimplifiedBirths(resourcefilepath=resourcefilepath),
enhanced_lifestyle.Lifestyle(resourcefilepath=resourcefilepath),
symptommanager.SymptomManager(resourcefilepath=resourcefilepath),
demography.Demography(),
simplified_births.SimplifiedBirths(),
enhanced_lifestyle.Lifestyle(),
symptommanager.SymptomManager(),
healthseekingbehaviour.HealthSeekingBehaviour(
resourcefilepath=resourcefilepath,
force_any_symptom_to_lead_to_healthcareseeking=True,
),
healthburden.HealthBurden(resourcefilepath=resourcefilepath),
healthsystem.HealthSystem(resourcefilepath=resourcefilepath,
cons_availability='all',
),
alri.Alri(resourcefilepath=resourcefilepath),
healthburden.HealthBurden(),
healthsystem.HealthSystem(cons_availability='all'),
alri.Alri(),
AlriPropertiesOfOtherModules(),
)
sim.modules['Demography'].parameters['max_age_initial'] = 5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,19 @@ def run_scenario(**kwargs):
}
}

sim = Simulation(start_date=start_date, log_config=log_config, show_progress_bar=True)
sim = Simulation(start_date=start_date, log_config=log_config,
show_progress_bar=True, resourcefilepath=resourcefilepath)

sim.register(
demography.Demography(resourcefilepath=resourcefilepath),
enhanced_lifestyle.Lifestyle(resourcefilepath=resourcefilepath),
simplified_births.SimplifiedBirths(resourcefilepath=resourcefilepath),
symptommanager.SymptomManager(resourcefilepath=resourcefilepath),
healthseekingbehaviour.HealthSeekingBehaviour(resourcefilepath=resourcefilepath,
demography.Demography(),
enhanced_lifestyle.Lifestyle(),
simplified_births.SimplifiedBirths(),
symptommanager.SymptomManager(),
healthseekingbehaviour.HealthSeekingBehaviour(
force_any_symptom_to_lead_to_healthcareseeking=True),
healthburden.HealthBurden(resourcefilepath=resourcefilepath),
healthsystem.HealthSystem(resourcefilepath=resourcefilepath,
disable=True,
cons_availability='all',
),
alri.Alri(resourcefilepath=resourcefilepath),
healthburden.HealthBurden(),
healthsystem.HealthSystem(disable=True, cons_availability='all'),
alri.Alri(),
alri.AlriPropertiesOfOtherModules()
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@
seed = random.randint(0, 50000)

# Establish the simulation object
sim = Simulation(start_date=start_date, seed=seed, log_config=log_config, show_progress_bar=True)
sim = Simulation(start_date=start_date, seed=seed, log_config=log_config,
show_progress_bar=True, resourcefilepath=resourcefilepath)

# run the simulation
sim.register(
demography.Demography(resourcefilepath=resourcefilepath),
enhanced_lifestyle.Lifestyle(resourcefilepath=resourcefilepath),
symptommanager.SymptomManager(resourcefilepath=resourcefilepath),
healthseekingbehaviour.HealthSeekingBehaviour(resourcefilepath=resourcefilepath),
healthburden.HealthBurden(resourcefilepath=resourcefilepath),
simplified_births.SimplifiedBirths(resourcefilepath=resourcefilepath),
healthsystem.HealthSystem(resourcefilepath=resourcefilepath,
service_availability=['*']),
alri.Alri(resourcefilepath=resourcefilepath),
demography.Demography(),
enhanced_lifestyle.Lifestyle(),
symptommanager.SymptomManager(),
healthseekingbehaviour.HealthSeekingBehaviour(),
healthburden.HealthBurden(),
simplified_births.SimplifiedBirths(),
healthsystem.HealthSystem(service_availability=['*']),
alri.Alri(),
alri.AlriPropertiesOfOtherModules()
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,21 @@
seed = random.randint(0, 50000)

# Establish the simulation object
sim = Simulation(start_date=start_date, seed=seed, log_config=log_config, show_progress_bar=True)
sim = Simulation(start_date=start_date, seed=seed, log_config=log_config,
show_progress_bar=True, resourcefilepath=resourcefilepath)

# run the simulation
sim.register(
demography.Demography(resourcefilepath=resourcefilepath),
enhanced_lifestyle.Lifestyle(resourcefilepath=resourcefilepath),
symptommanager.SymptomManager(resourcefilepath=resourcefilepath),
healthseekingbehaviour.HealthSeekingBehaviour(resourcefilepath=resourcefilepath),
healthburden.HealthBurden(resourcefilepath=resourcefilepath),
simplified_births.SimplifiedBirths(resourcefilepath=resourcefilepath),
healthsystem.HealthSystem(resourcefilepath=resourcefilepath,
service_availability=['*'],
mode_appt_constraints=0,
ignore_priority=True,
demography.Demography(),
enhanced_lifestyle.Lifestyle(),
symptommanager.SymptomManager(),
healthseekingbehaviour.HealthSeekingBehaviour(),
healthburden.HealthBurden(),
simplified_births.SimplifiedBirths(),
healthsystem.HealthSystem(service_availability=['*'], mode_appt_constraints=0, ignore_priority=True,
capabilities_coefficient=1.0,
disable=True),
alri.Alri(resourcefilepath=resourcefilepath),
alri.Alri(),
alri.AlriPropertiesOfOtherModules()
)

Expand Down
20 changes: 10 additions & 10 deletions src/scripts/Alri_analyses/other_scripts/create_new_logfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,23 @@
seed = random.randint(0, 50000)

# Establish the simulation object
sim = Simulation(start_date=start_date, seed=seed, log_config=log_config, show_progress_bar=True)
sim = Simulation(start_date=start_date, seed=seed, log_config=log_config,
show_progress_bar=True, resourcefilepath=resourcefilepath)

# run the simulation
sim.register(
demography.Demography(resourcefilepath=resourcefilepath),
enhanced_lifestyle.Lifestyle(resourcefilepath=resourcefilepath),
symptommanager.SymptomManager(resourcefilepath=resourcefilepath),
healthseekingbehaviour.HealthSeekingBehaviour(resourcefilepath=resourcefilepath),
healthburden.HealthBurden(resourcefilepath=resourcefilepath),
simplified_births.SimplifiedBirths(resourcefilepath=resourcefilepath),
healthsystem.HealthSystem(resourcefilepath=resourcefilepath,
service_availability=['*']),
demography.Demography(),
enhanced_lifestyle.Lifestyle(),
symptommanager.SymptomManager(),
healthseekingbehaviour.HealthSeekingBehaviour(),
healthburden.HealthBurden(),
simplified_births.SimplifiedBirths(),
healthsystem.HealthSystem(service_availability=['*']),
# mode_appt_constraints=0,
# ignore_priority=True,
# capabilities_coefficient=1.0,
# disable=True),
alri.Alri(resourcefilepath=resourcefilepath),
alri.Alri(),
alri.AlriPropertiesOfOtherModules()
)

Expand Down
33 changes: 16 additions & 17 deletions src/scripts/bladder_cancer_analyses/bladder_cancer_analyses.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,21 @@
def run_sim(service_availability):
# Establish the simulation object and set the seed
# seed is not set - each simulation run gets a random seed
sim = Simulation(start_date=start_date, log_config={"filename": "LogFile"})
sim = Simulation(start_date=start_date, log_config={"filename": "LogFile"}, resourcefilepath=resourcefilepath)
# Register the appropriate modules
sim.register(demography.Demography(resourcefilepath=resourcefilepath),
contraception.Contraception(resourcefilepath=resourcefilepath),
enhanced_lifestyle.Lifestyle(resourcefilepath=resourcefilepath),
healthsystem.HealthSystem(resourcefilepath=resourcefilepath,
service_availability=service_availability),
symptommanager.SymptomManager(resourcefilepath=resourcefilepath),
healthseekingbehaviour.HealthSeekingBehaviour(resourcefilepath=resourcefilepath),
healthburden.HealthBurden(resourcefilepath=resourcefilepath),
labour.Labour(resourcefilepath=resourcefilepath),
pregnancy_supervisor.PregnancySupervisor(resourcefilepath=resourcefilepath),
bladder_cancer.BladderCancer(resourcefilepath=resourcefilepath),
care_of_women_during_pregnancy.CareOfWomenDuringPregnancy(resourcefilepath=resourcefilepath),
newborn_outcomes.NewbornOutcomes(resourcefilepath=resourcefilepath),
postnatal_supervisor.PostnatalSupervisor(resourcefilepath=resourcefilepath)
sim.register(demography.Demography(),
contraception.Contraception(),
enhanced_lifestyle.Lifestyle(),
healthsystem.HealthSystem(service_availability=service_availability),
symptommanager.SymptomManager(),
healthseekingbehaviour.HealthSeekingBehaviour(),
healthburden.HealthBurden(),
labour.Labour(),
pregnancy_supervisor.PregnancySupervisor(),
bladder_cancer.BladderCancer(),
care_of_women_during_pregnancy.CareOfWomenDuringPregnancy(),
newborn_outcomes.NewbornOutcomes(),
postnatal_supervisor.PostnatalSupervisor()
)
# Run the simulation
sim.make_initial_population(n=popsize)
Expand Down Expand Up @@ -99,7 +98,7 @@ def get_cols_excl_none(allcols, stub):
dalys = dalys.sort_index()
# 4) DEATHS wrt age (total over whole simulation)
deaths = output['tlo.methods.demography']['death']
deaths['age_group'] = deaths['age'].map(demography.Demography(resourcefilepath=resourcefilepath).AGE_RANGE_LOOKUP)
deaths['age_group'] = deaths['age'].map(demography.Demography().AGE_RANGE_LOOKUP)
x = deaths.loc[deaths.cause == 'BladderCancer'].copy()
x['age_group'] = x['age_group'].astype(make_age_grp_types())
bladder_cancer_deaths = x.groupby(by=['age_group']).size()
Expand Down Expand Up @@ -162,7 +161,7 @@ def get_cols_excl_none(allcols, stub):
deaths = results_no_healthsystem['bladder_cancer_deaths']
deaths.index = deaths.index.astype(make_age_grp_types())
# # make a series with the right categories and zero so formats nicely in the grapsh:
agegrps = demography.Demography(resourcefilepath=resourcefilepath).AGE_RANGE_CATEGORIES
agegrps = demography.Demography().AGE_RANGE_CATEGORIES
totdeaths = pd.Series(index=agegrps, data=np.nan)
totdeaths.index = totdeaths.index.astype(make_age_grp_types())
totdeaths = totdeaths.combine_first(deaths).fillna(0.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@
contraception,
demography,
enhanced_lifestyle,
epi,
healthburden,
healthseekingbehaviour,
healthsystem,
hiv,
labour,
newborn_outcomes,
postnatal_supervisor,
pregnancy_supervisor,
symptommanager,
tb,
)

# import numpy as np
Expand Down Expand Up @@ -55,22 +58,26 @@
'tlo.methods.pregnancy_supervisor': logging.CRITICAL
}
}
sim = Simulation(start_date=start_date, seed=4, log_config=log_config)
sim = Simulation(start_date=start_date, seed=4, log_config=log_config, resourcefilepath=resourcefilepath)

# Register the appropriate modules
sim.register(demography.Demography(resourcefilepath=resourcefilepath),
care_of_women_during_pregnancy.CareOfWomenDuringPregnancy(resourcefilepath=resourcefilepath),
contraception.Contraception(resourcefilepath=resourcefilepath),
enhanced_lifestyle.Lifestyle(resourcefilepath=resourcefilepath),
healthsystem.HealthSystem(resourcefilepath=resourcefilepath),
symptommanager.SymptomManager(resourcefilepath=resourcefilepath),
healthseekingbehaviour.HealthSeekingBehaviour(resourcefilepath=resourcefilepath),
healthburden.HealthBurden(resourcefilepath=resourcefilepath),
labour.Labour(resourcefilepath=resourcefilepath),
newborn_outcomes.NewbornOutcomes(resourcefilepath=resourcefilepath),
pregnancy_supervisor.PregnancySupervisor(resourcefilepath=resourcefilepath),
postnatal_supervisor.PostnatalSupervisor(resourcefilepath=resourcefilepath),
bladder_cancer.BladderCancer(resourcefilepath=resourcefilepath)
sim.register(demography.Demography(),
care_of_women_during_pregnancy.CareOfWomenDuringPregnancy(),
contraception.Contraception(),
enhanced_lifestyle.Lifestyle(),
healthsystem.HealthSystem(),
symptommanager.SymptomManager(),
healthseekingbehaviour.HealthSeekingBehaviour(),
healthburden.HealthBurden(),
labour.Labour(),
newborn_outcomes.NewbornOutcomes(),
pregnancy_supervisor.PregnancySupervisor(),
postnatal_supervisor.PostnatalSupervisor(),
bladder_cancer.BladderCancer(),
hiv.Hiv(),
tb.Tb(),
epi.Epi()

)

# Run the simulation and flush the logger
Expand Down
Loading