-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpurge_data.py
32 lines (23 loc) · 919 Bytes
/
purge_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""
Deletes all data generated by a model run
Does not delete the .txt and .png files generated by compile_changes.py and plot_changes.py folders
"""
import os
def purge_data(model_name = None):
""" Clears all simulation data in the given model's directory """
if model_name == None:
purge_data("contact_spatial")
purge_data("scanlon_kalahari")
purge_data("tricritical")
purge_data("null_static")
purge_data("null_stochastic")
return
model_path = os.path.join("models", model_name)
folder_path = os.path.join(os.path.dirname(__file__), model_path)
file_names = os.listdir(folder_path)
for file_name in file_names:
if file_name.endswith(".pkl") or file_name.endswith(".txt"):
os.remove(os.path.join(folder_path, file_name))
print(f"Removed {file_name}", end=', ')
if __name__ == '__main__':
purge_data()