Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
priyakasimbeg committed Jul 2, 2024
1 parent 90c4652 commit be6560e
Showing 1 changed file with 28 additions and 18 deletions.
46 changes: 28 additions & 18 deletions scoring/score_submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@
False,
'Whether to score on self-tuning ruleset or externally tuned ruleset')
flags.DEFINE_string(
'save_results_to_filename',
None,
'Filename to save the processed results that are fed into the performance profile functions.')
'save_results_to_filename',
None,
'Filename to save the processed results that are fed into the performance profile functions.'
)
flags.DEFINE_boolean(
'load_results_from_filename',
None,
'Filename to load processed results from that are fed into performance profile functions')
'load_results_from_filename',
None,
'Filename to load processed results from that are fed into performance profile functions'
)
FLAGS = flags.FLAGS


Expand Down Expand Up @@ -131,25 +133,33 @@ def main(_):
results = {}
os.makedirs(FLAGS.output_dir, exist_ok=True)

# Optionally read results to filename
# Optionally read results to filename
if FLAGS.load_results_from_filename:
with open(os.path.join(FLAGS.output_dir, FLAGS.load_results_from_filename), 'rb') as f:
with open(
os.path.join(FLAGS.output_dir, FLAGS.load_results_from_filename),
'rb') as f:
results = pickle.load(f)
else:
for team in os.listdir(FLAGS.submission_directory):
for submission in os.listdir(os.path.join(FLAGS.submission_directory, team)):
print(submission)
experiment_path = os.path.join(FLAGS.submission_directory, team, submission)
df = scoring_utils.get_experiment_df(experiment_path)
results[submission] = df
summary_df = get_submission_summary(df)
with open(os.path.join(FLAGS.output_dir, f'{submission}_summary.csv'),
'w') as fout:
summary_df.to_csv(fout)
for submission in os.listdir(
os.path.join(FLAGS.submission_directory, team)):
print(submission)
experiment_path = os.path.join(FLAGS.submission_directory,
team,
submission)
df = scoring_utils.get_experiment_df(experiment_path)
results[submission] = df
summary_df = get_submission_summary(df)
with open(
os.path.join(FLAGS.output_dir, f'{submission}_summary.csv'),
'w') as fout:
summary_df.to_csv(fout)

# Optionally save results to filename
if FLAGS.save_results_to_filename:
with open(os.path.join(FLAGS.output_dir, FLAGS.save_results_to_filename), 'wb') as f:
with open(
os.path.join(FLAGS.output_dir, FLAGS.save_results_to_filename),
'wb') as f:
pickle.dump(results, f)

if not FLAGS.strict:
Expand Down

0 comments on commit be6560e

Please sign in to comment.