Skip to content

Commit

Permalink
fix enums for data service
Browse files Browse the repository at this point in the history
  • Loading branch information
ntarocco authored and lrdossan committed Dec 14, 2023
1 parent d79ef93 commit 00ff1af
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 29 deletions.
13 changes: 12 additions & 1 deletion caimira/apps/calculator/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,23 @@ def configure_parser(parser) -> argparse.ArgumentParser:
return parser


def _init_logging(debug=False):
# Set the logging level for urllib3 and requests to WARNING
logging.getLogger("urllib3").setLevel(logging.WARNING)
logging.getLogger("requests").setLevel(logging.WARNING)

# set app root log level
logger = logging.getLogger()
root_log_level = logging.DEBUG if debug else logging.WARNING
logger.setLevel(root_log_level)


def main():
parser = configure_parser(argparse.ArgumentParser())
args = parser.parse_args()

debug = args.no_debug
logging.getLogger().setLevel(logging.DEBUG if debug else logging.WARNING)
_init_logging(debug)

theme_dir = args.theme
if theme_dir is not None:
Expand Down
5 changes: 3 additions & 2 deletions caimira/apps/calculator/report_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def manufacture_conditional_probability_data(
infection_probability: models._VectorisedFloat
):
data_registry: DataRegistry = exposure_model.data_registry

min_vl = data_registry.conditional_prob_inf_given_viral_load['min_vl']
max_vl = data_registry.conditional_prob_inf_given_viral_load['max_vl']
step = (max_vl - min_vl)/100
Expand Down Expand Up @@ -502,11 +502,12 @@ def prepare_context(
now = datetime.utcnow().astimezone()
time = now.strftime("%Y-%m-%d %H:%M:%S UTC")

data_registry_version = f"v{model.data_registry.version}" if model.data_registry.version else None
context = {
'model': model,
'form': form,
'creation_date': time,
'data_registry_version': model.data_registry.version,
'data_registry_version': data_registry_version,
}

scenario_sample_times = interesting_times(model)
Expand Down
26 changes: 21 additions & 5 deletions caimira/monte_carlo/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,40 @@


def evaluate_vl(value, data_registry: DataRegistry):
if value == ViralLoads.COVID_OVERALL:
# FIXME: temp fix until data service values is updated
# remove old Ref value
if "covid_overal_vl_data" in value:
value = ViralLoads.COVID_OVERALL.value
elif "symptomatic_vl_frequencies" in value:
value = ViralLoads.SYMPTOMATIC_FREQUENCIES.value

if value == ViralLoads.COVID_OVERALL.value:
return covid_overal_vl_data(data_registry)
elif value == ViralLoads.COVID_OVERALL:
elif value == ViralLoads.SYMPTOMATIC_FREQUENCIES.value:
return symptomatic_vl_frequencies
else:
raise ValueError(f"Invalid ViralLoads value {value}")


def evaluate_infectd(value, data_registry: DataRegistry):
if value == InfectiousDoses.DISTRIBUTION:
# FIXME: temp fix until data service values is updated
# remove old Ref value
if "infectious_dose_distribution" in value:
value = InfectiousDoses.DISTRIBUTION.value

if value == InfectiousDoses.DISTRIBUTION.value:
return infectious_dose_distribution(data_registry)
else:
raise ValueError(f"Invalid InfectiousDoses value {value}")


def evaluate_vtrr(value, data_registry: DataRegistry):
"""."""
if value == ViableToRNARatios.DISTRIBUTION:
# FIXME: temp fix until data service values is updated
# remove old Ref value
if "viable_to_RNA_ratio_distribution" in value:
value = ViableToRNARatios.DISTRIBUTION.value

if value == ViableToRNARatios.DISTRIBUTION.value:
return viable_to_RNA_ratio_distribution(data_registry)
else:
raise ValueError(f"Invalid ViableToRNARatios value {value}")
Expand Down
42 changes: 21 additions & 21 deletions caimira/store/data_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,51 +210,51 @@ class DataRegistry:
}
virus_distributions = {
"SARS_CoV_2": {
"viral_load_in_sputum": ViralLoads.COVID_OVERALL,
"infectious_dose": InfectiousDoses.DISTRIBUTION,
"viable_to_RNA_ratio": ViableToRNARatios.DISTRIBUTION,
"viral_load_in_sputum": ViralLoads.COVID_OVERALL.value,
"infectious_dose": InfectiousDoses.DISTRIBUTION.value,
"viable_to_RNA_ratio": ViableToRNARatios.DISTRIBUTION.value,
"transmissibility_factor": 1,
"infectiousness_days": 14,
},
"SARS_CoV_2_ALPHA": {
"viral_load_in_sputum": ViralLoads.COVID_OVERALL,
"infectious_dose": InfectiousDoses.DISTRIBUTION,
"viable_to_RNA_ratio": ViableToRNARatios.DISTRIBUTION,
"viral_load_in_sputum": ViralLoads.COVID_OVERALL.value,
"infectious_dose": InfectiousDoses.DISTRIBUTION.value,
"viable_to_RNA_ratio": ViableToRNARatios.DISTRIBUTION.value,
"transmissibility_factor": 0.78,
"infectiousness_days": 14,
},
"SARS_CoV_2_BETA": {
"viral_load_in_sputum": ViralLoads.COVID_OVERALL,
"infectious_dose": InfectiousDoses.DISTRIBUTION,
"viable_to_RNA_ratio": ViableToRNARatios.DISTRIBUTION,
"viral_load_in_sputum": ViralLoads.COVID_OVERALL.value,
"infectious_dose": InfectiousDoses.DISTRIBUTION.value,
"viable_to_RNA_ratio": ViableToRNARatios.DISTRIBUTION.value,
"transmissibility_factor": 0.8,
"infectiousness_days": 14,
},
"SARS_CoV_2_GAMMA": {
"viral_load_in_sputum": ViralLoads.COVID_OVERALL,
"infectious_dose": InfectiousDoses.DISTRIBUTION,
"viable_to_RNA_ratio": ViableToRNARatios.DISTRIBUTION,
"viral_load_in_sputum": ViralLoads.COVID_OVERALL.value,
"infectious_dose": InfectiousDoses.DISTRIBUTION.value,
"viable_to_RNA_ratio": ViableToRNARatios.DISTRIBUTION.value,
"transmissibility_factor": 0.72,
"infectiousness_days": 14,
},
"SARS_CoV_2_DELTA": {
"viral_load_in_sputum": ViralLoads.COVID_OVERALL,
"infectious_dose": InfectiousDoses.DISTRIBUTION,
"viable_to_RNA_ratio": ViableToRNARatios.DISTRIBUTION,
"viral_load_in_sputum": ViralLoads.COVID_OVERALL.value,
"infectious_dose": InfectiousDoses.DISTRIBUTION.value,
"viable_to_RNA_ratio": ViableToRNARatios.DISTRIBUTION.value,
"transmissibility_factor": 0.51,
"infectiousness_days": 14,
},
"SARS_CoV_2_OMICRON": {
"viral_load_in_sputum": ViralLoads.COVID_OVERALL,
"infectious_dose": InfectiousDoses.DISTRIBUTION,
"viable_to_RNA_ratio": ViableToRNARatios.DISTRIBUTION,
"viral_load_in_sputum": ViralLoads.COVID_OVERALL.value,
"infectious_dose": InfectiousDoses.DISTRIBUTION.value,
"viable_to_RNA_ratio": ViableToRNARatios.DISTRIBUTION.value,
"transmissibility_factor": 0.2,
"infectiousness_days": 14,
},
"SARS_CoV_2_Other": {
"viral_load_in_sputum": ViralLoads.COVID_OVERALL,
"infectious_dose": InfectiousDoses.DISTRIBUTION,
"viable_to_RNA_ratio": ViableToRNARatios.DISTRIBUTION,
"viral_load_in_sputum": ViralLoads.COVID_OVERALL.value,
"infectious_dose": InfectiousDoses.DISTRIBUTION.value,
"viable_to_RNA_ratio": ViableToRNARatios.DISTRIBUTION.value,
"transmissibility_factor": 0.1,
"infectiousness_days": 14,
},
Expand Down

0 comments on commit 00ff1af

Please sign in to comment.