Skip to content

Commit

Permalink
Add simulation speed as option to the replay script. (#115)
Browse files Browse the repository at this point in the history
Also do a minor fix to always prepend single digit minutes/seconds with
0s.
  • Loading branch information
meisterT authored Mar 29, 2024
1 parent 336d60c commit f130761
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions provision-contest/replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
parser.add_argument('--insecure', help='do not verify SSL certificate', action='store_true')
parser.add_argument('-r', '--no_remap_teams', help='do not remap team ID\'s to team ID\'s of contest from API.', action='store_true')
parser.add_argument('-i', '--internal_data_source', help='The API uses an internal API source.', action='store_true')
parser.add_argument('-f', '--simulation_speed', help='Speed up replay speed by this factor.')

args = parser.parse_args()

Expand Down Expand Up @@ -100,6 +101,8 @@
logging.info('Contest will be started at '
+ time.strftime('%X %x %Z', time.localtime(contest_start)) + '.')
simulation_speed = orig_contest_duration/contest_duration
if args.simulation_speed:
simulation_speed = float(args.simulation_speed)
logging.info(f'Simulation speed: {simulation_speed}')

if args.internal_data_source:
Expand All @@ -119,12 +122,15 @@
if not submission['id']:
continue
times = submission['contest_time'].split(':')
orig_submission_time = int(times[0])*3600 + int(times[1])*60 + float(times[2])
hours = int(times[0])
minutes = int(times[1])
seconds = float(times[2])
orig_submission_time = hours*3600 + minutes*60 + seconds
new_submission_time = orig_submission_time/simulation_speed
time_from_start = time.time() - contest_start
time_diff = new_submission_time - time_from_start
if time_diff > 0:
logging.info(f'Waiting for simulated contest time of {times[0]}:{times[1]}:{times[2]}.')
logging.info(f'Waiting for simulated contest time of {hours}:{minutes:02}:{seconds:06.3f}.')
spinner = Halo(spinner='dots', text=f'Sleeping for ~{str(round(time_diff,2))}s')
spinner.start()
while time_diff > 1:
Expand Down

0 comments on commit f130761

Please sign in to comment.