Andrea Maldonado commited on
Commit
043eb4c
·
1 Parent(s): c585662

Restores file mentioned in documentation

Browse files
Files changed (1) hide show
  1. execute_grid_experiments.py +44 -0
execute_grid_experiments.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import multiprocessing
2
+ import os
3
+ import sys
4
+
5
+ from datetime import datetime as dt
6
+ from gedi.utils.io_helpers import sort_files
7
+ from tqdm import tqdm
8
+
9
+ #TODO: Pass i properly
10
+ def multi_experiment_wrapper(config_file, i=0):
11
+ print(f"=========================STARTING EXPERIMENT #{i+1}=======================")
12
+ print(f"INFO: Executing with {config_file}")
13
+ os.system(f"python -W ignore main.py -a {config_file}")
14
+ print(f"=========================FINISHED EXPERIMENT #{i+1}=======================")
15
+
16
+ if __name__ == '__main__':
17
+ EXPERIMENTS_FOLDER = sys.argv[1]
18
+ """
19
+ Following args run the following experiments:
20
+ - config_files/algorithm/grid_1obj
21
+ - config_files/algorithm/grid_experiments
22
+ - config_files/algorithm/test
23
+ """
24
+ start = dt.now()
25
+
26
+ experiment_list = list(tqdm(sort_files(os.listdir(EXPERIMENTS_FOLDER))))
27
+ experiment_list = [os.path.join(EXPERIMENTS_FOLDER, config_file) for config_file in experiment_list]
28
+ #experiment_list = experiment_list[:10]
29
+
30
+ print(f"========================STARTING MULTIPLE EXPERIMENTS=========================")
31
+ print(f"INFO: {EXPERIMENTS_FOLDER} contains config files for {len(experiment_list)}.")
32
+ try:
33
+ num_cores = multiprocessing.cpu_count() if len(
34
+ experiment_list) >= multiprocessing.cpu_count() else len(experiment_list)
35
+ with multiprocessing.Pool(num_cores) as p:
36
+ try:
37
+ print(f"INFO: Multi Experiments starting at {start.strftime('%H:%M:%S')} using {num_cores} cores for {len(experiment_list)} experiments...")
38
+ result = p.map(multi_experiment_wrapper, experiment_list)
39
+ except Exception as e:
40
+ print(e)
41
+ except Exception as e:
42
+ print("pare", e)
43
+
44
+ #for i, config_file in enumerate(experiment_list[:2]):