|
53 | 53 | # force_calculation of [births_data, deaths_data, dalys_data, tx_data], |
54 | 54 | # if True, enables to force recalculation of the corresponding data |
55 | 55 | force_calculation = [False, False, False, False] # [True, True, True] # |
56 | | -regenare_pickles_bool = False # True # |
57 | 56 | ######################################################################################################################## |
58 | 57 | assert all(interv in intervs_all for interv in intervs_of_interest), ("Some interventions in intervs_of_interest are not" |
59 | 58 | "in intervs_all") |
@@ -596,11 +595,37 @@ def run_behind_the_scene_analysis_wasting( |
596 | 595 | } |
597 | 596 | for interv in intervs_ofinterest |
598 | 597 | } |
599 | | - if regenare_pickles_bool: |
| 598 | + |
| 599 | + info_pickles_file_path = outputspath / "outcomes_data/pickles_regenerated.pkl" |
| 600 | + regenerate_pickles_bool = False |
| 601 | + if info_pickles_file_path.exists(): |
| 602 | + print("loading pickles_regenerated_df from file ...") |
| 603 | + with info_pickles_file_path.open("rb") as f: |
| 604 | + pickles_regenerated_df = pickle.load(f) |
| 605 | + else: |
| 606 | + pickles_regenerated_df = pd.DataFrame(columns=["interv", "timestamp"]) |
| 607 | + print(f"pickles_regenerated_df from loading:\n{pickles_regenerated_df}") |
| 608 | + # check all are already regenerated, if any is not regenerate them all and add the timestamps to the df |
| 609 | + for interv, timestamp in interv_timestamps_dict.items(): |
| 610 | + print(f"\n{interv=}, {timestamp=}") |
| 611 | + if not ( |
| 612 | + (pickles_regenerated_df["interv"] == interv) & (pickles_regenerated_df["timestamp"] == timestamp) |
| 613 | + ).any(): |
| 614 | + regenerate_pickles_bool = True |
| 615 | + pickles_regenerated_df = pd.concat([ |
| 616 | + pickles_regenerated_df, |
| 617 | + pd.DataFrame({"interv": [interv], "timestamp": [timestamp]}) |
| 618 | + ], ignore_index=True) |
| 619 | + print(f"pickles_regenerated_df:\n{pickles_regenerated_df}") |
| 620 | + print(f"{regenerate_pickles_bool=}") |
| 621 | + |
| 622 | + if regenerate_pickles_bool: |
| 623 | + print("saving pickles_regenerated_df to file ...") |
| 624 | + with info_pickles_file_path.open("wb") as f: |
| 625 | + pickle.dump(pickles_regenerated_df, f) |
600 | 626 | print("\nRegenerating pickles with debug logs ...") |
601 | 627 | util_fncs.regenerate_pickles_with_debug_logs(iterv_folders_dict) |
602 | 628 |
|
603 | | - |
604 | 629 | pd.set_option('display.max_columns', None) # Show all columns |
605 | 630 | pd.set_option('display.max_rows', None) # Show all rows |
606 | 631 | pd.set_option('display.max_colwidth', None) # Show full content of each row |
|
0 commit comments