|
47 | 47 | False, |
48 | 48 | 'Whether to score on self-tuning ruleset or externally tuned ruleset') |
49 | 49 | flags.DEFINE_string( |
50 | | - 'save_results_to_filename', |
51 | | - None, |
52 | | - 'Filename to save the processed results that are fed into the performance profile functions.') |
| 50 | + 'save_results_to_filename', |
| 51 | + None, |
| 52 | + 'Filename to save the processed results that are fed into the performance profile functions.' |
| 53 | +) |
53 | 54 | flags.DEFINE_boolean( |
54 | | - 'load_results_from_filename', |
55 | | - None, |
56 | | - 'Filename to load processed results from that are fed into performance profile functions') |
| 55 | + 'load_results_from_filename', |
| 56 | + None, |
| 57 | + 'Filename to load processed results from that are fed into performance profile functions' |
| 58 | +) |
57 | 59 | FLAGS = flags.FLAGS |
58 | 60 |
|
59 | 61 |
|
@@ -131,25 +133,33 @@ def main(_): |
131 | 133 | results = {} |
132 | 134 | os.makedirs(FLAGS.output_dir, exist_ok=True) |
133 | 135 |
|
134 | | - # Optionally read results to filename |
| 136 | + # Optionally read results to filename |
135 | 137 | if FLAGS.load_results_from_filename: |
136 | | - with open(os.path.join(FLAGS.output_dir, FLAGS.load_results_from_filename), 'rb') as f: |
| 138 | + with open( |
| 139 | + os.path.join(FLAGS.output_dir, FLAGS.load_results_from_filename), |
| 140 | + 'rb') as f: |
137 | 141 | results = pickle.load(f) |
138 | 142 | else: |
139 | 143 | for team in os.listdir(FLAGS.submission_directory): |
140 | | - for submission in os.listdir(os.path.join(FLAGS.submission_directory, team)): |
141 | | - print(submission) |
142 | | - experiment_path = os.path.join(FLAGS.submission_directory, team, submission) |
143 | | - df = scoring_utils.get_experiment_df(experiment_path) |
144 | | - results[submission] = df |
145 | | - summary_df = get_submission_summary(df) |
146 | | - with open(os.path.join(FLAGS.output_dir, f'{submission}_summary.csv'), |
147 | | - 'w') as fout: |
148 | | - summary_df.to_csv(fout) |
| 144 | + for submission in os.listdir( |
| 145 | + os.path.join(FLAGS.submission_directory, team)): |
| 146 | + print(submission) |
| 147 | + experiment_path = os.path.join(FLAGS.submission_directory, |
| 148 | + team, |
| 149 | + submission) |
| 150 | + df = scoring_utils.get_experiment_df(experiment_path) |
| 151 | + results[submission] = df |
| 152 | + summary_df = get_submission_summary(df) |
| 153 | + with open( |
| 154 | + os.path.join(FLAGS.output_dir, f'{submission}_summary.csv'), |
| 155 | + 'w') as fout: |
| 156 | + summary_df.to_csv(fout) |
149 | 157 |
|
150 | 158 | # Optionally save results to filename |
151 | 159 | if FLAGS.save_results_to_filename: |
152 | | - with open(os.path.join(FLAGS.output_dir, FLAGS.save_results_to_filename), 'wb') as f: |
| 160 | + with open( |
| 161 | + os.path.join(FLAGS.output_dir, FLAGS.save_results_to_filename), |
| 162 | + 'wb') as f: |
153 | 163 | pickle.dump(results, f) |
154 | 164 |
|
155 | 165 | if not FLAGS.strict: |
|
0 commit comments