Skip to content

Commit

Permalink
Log more to the workflow log
Browse files Browse the repository at this point in the history
  • Loading branch information
dflook committed Oct 2, 2024
1 parent 4895ace commit c9a8e5e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions corpus_test/generate_results.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import argparse
import datetime
import gzip
import os
import sys
Expand Down Expand Up @@ -97,16 +98,16 @@ def corpus_test(corpus_path, results_path, sha, regenerate_results):
results_file_path = os.path.join(results_path, 'results_' + python_version + '_' + sha + '.csv')

if os.path.isfile(results_file_path):
logging.info('Results file already exists: %s', results_file_path)
print('Results file already exists: %s', results_file_path)
if regenerate_results:
os.remove(results_file_path)

total_entries = len(corpus_entries)
logging.info('Testing python-minifier on %d entries' % total_entries)
print('Testing python-minifier on %d entries' % total_entries)
tested_entries = 0

start_time = time.time()
next_checkpoint = time.time() + 60
next_checkpoint = time.time() - 60

with ResultWriter(results_file_path) as result_writer:
logging.info('%d results already present' % len(result_writer))
Expand All @@ -127,12 +128,12 @@ def corpus_test(corpus_path, results_path, sha, regenerate_results):
percent = len(result_writer) / total_entries * 100
time_per_entry = (time.time() - start_time) / tested_entries
entries_remaining = len(corpus_entries) - len(result_writer)
time_remaining = int(entries_remaining * time_per_entry)
logging.info('Tested %d/%d entries (%d%%) %s seconds remaining' % (len(result_writer), total_entries, percent, time_remaining))
time_remaining = datetime.timedelta(seconds=int(entries_remaining * time_per_entry))
print('Tested %d/%d entries (%d%%) %s remaining' % (len(result_writer), total_entries, percent, time_remaining))
sys.stdout.flush()
next_checkpoint = time.time() + 60

logging.info('Finished')
print('Finished')

def bool_parse(value):
return value == 'true'
Expand Down

0 comments on commit c9a8e5e

Please sign in to comment.