Hold onto results when the server was unreachable. Add config for report rate. Drop report rate to 10
This commit is contained in:
1 parent
e87a67c41e
commit
9369ff367b
1 file changed
+19
-12
+19
-12
@@ -6,8 +6,8 @@ import shutil, subprocess, requests, zipfile, os, math, json
|
|||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
HTTP_TIMEOUT = 30 # Timeout in seconds for web requests
|
HTTP_TIMEOUT = 30 # Timeout in seconds for web requests
|
||||||
GAMES_PER_TASK = 250 # Games to complete for each workload
|
GAMES_PER_TASK = 250 # Total games to complete for each workload
|
||||||
|
REPORT_RATE = 10 # Games per upload. Must divide GAMES_PER_TASK
|
||||||
|
|
||||||
# Run from any location ...
|
# Run from any location ...
|
||||||
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
||||||
@@ -291,7 +291,10 @@ def reportResults(data, wins, losses, draws, crashes, timeloss):
|
|||||||
'resultid' : data['result']['id'],
|
'resultid' : data['result']['id'],
|
||||||
'testid' : data['test']['id']}
|
'testid' : data['test']['id']}
|
||||||
return requests.post('{0}/submitResults/'.format(SERVER), data=postdata, timeout=HTTP_TIMEOUT).text
|
return requests.post('{0}/submitResults/'.format(SERVER), data=postdata, timeout=HTTP_TIMEOUT).text
|
||||||
except: print ('<Warning> Unable to reach server')
|
except:
|
||||||
|
print ('<Warning> Unable to reach server')
|
||||||
|
return "Unable"
|
||||||
|
|
||||||
|
|
||||||
def completeWorkload(data):
|
def completeWorkload(data):
|
||||||
|
|
||||||
@@ -370,23 +373,27 @@ def completeWorkload(data):
|
|||||||
if 'on time' in line:
|
if 'on time' in line:
|
||||||
timeloss += 1
|
timeloss += 1
|
||||||
|
|
||||||
# Batch result updates
|
# Report back results in batches
|
||||||
if (sum(score) - sum(sent)) % 25 == 0 and score != sent:
|
if line.startswith('Score of') and (sum(score) - sum(sent)) % REPORT_RATE == 0:
|
||||||
|
|
||||||
|
# Compute scoreline differences
|
||||||
wins = score[0] - sent[0]
|
wins = score[0] - sent[0]
|
||||||
losses = score[1] - sent[1]
|
losses = score[1] - sent[1]
|
||||||
draws = score[2] - sent[2]
|
draws = score[2] - sent[2]
|
||||||
if reportResults(data, wins, losses, draws, crashes, timeloss) == 'Stop':
|
|
||||||
|
# Send results to server
|
||||||
|
status = reportResults(data, wins, losses, draws, crashes, timeloss)
|
||||||
|
|
||||||
|
# Task ended, deleted, ..., exit back for new task
|
||||||
|
if status == "Stop":
|
||||||
killProcess(process)
|
killProcess(process)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
# Only reset tracking when the server was reached
|
||||||
|
if status != "Unable":
|
||||||
crashes = timeloss = 0
|
crashes = timeloss = 0
|
||||||
sent = score[::]
|
sent = score[::]
|
||||||
|
|
||||||
# One final result send before we exit just in case
|
|
||||||
wins = score[0] - sent[0]
|
|
||||||
losses = score[1] - sent[1]
|
|
||||||
draws = score[2] - sent[2]
|
|
||||||
reportResults(data, wins, losses, draws, crashes, timeloss)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
# Machine ID numbers are tracked by the server, and saved locally
|
# Machine ID numbers are tracked by the server, and saved locally
|
||||||
|
|||||||
Reference in new issue
Block a user