Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simulation speed as option to the replay script. #115

Merged
merged 1 commit into from
Mar 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading