Upload the PGNs and save them. Last step for that
This commit is contained in:
1 parent
c4e27d393f
commit
5f97fd9e6a
4 files changed
+52
-14
No files matched your search
+25
-13
@@ -262,13 +262,13 @@ class ServerReporter:
|
|||||||
## differing payloads. Payloads must always include the machine id, and secret token
|
## differing payloads. Payloads must always include the machine id, and secret token
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def report(config, endpoint, payload):
|
def report(config, endpoint, payload, files=None):
|
||||||
|
|
||||||
payload['machine_id'] = config.machine_id
|
payload['machine_id'] = config.machine_id
|
||||||
payload['secret'] = config.secret_token
|
payload['secret'] = config.secret_token
|
||||||
|
|
||||||
target = url_join(config.server, endpoint)
|
target = url_join(config.server, endpoint)
|
||||||
response = requests.post(target, data=payload, timeout=TIMEOUT_HTTP)
|
response = requests.post(target, data=payload, files=files, timeout=TIMEOUT_HTTP)
|
||||||
|
|
||||||
# Check for a json repsone, to look for Client Version Errors
|
# Check for a json repsone, to look for Client Version Errors
|
||||||
try: as_json = response.json()
|
try: as_json = response.json()
|
||||||
@@ -392,6 +392,24 @@ class ServerReporter:
|
|||||||
|
|
||||||
return ServerReporter.report(config, 'clientHeartbeat', payload)
|
return ServerReporter.report(config, 'clientHeartbeat', payload)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def report_pgn(config, compressed_pgn_text):
|
||||||
|
|
||||||
|
payload = {
|
||||||
|
'test_id' : config.workload['test']['id'],
|
||||||
|
'result_id' : config.workload['result']['id'],
|
||||||
|
'book_index' : config.workload['test']['book_index'],
|
||||||
|
'Content-Type' : 'application/octet-stream',
|
||||||
|
}
|
||||||
|
|
||||||
|
files = {
|
||||||
|
'file' : ('games.pgn', compressed_pgn_text)
|
||||||
|
}
|
||||||
|
|
||||||
|
print (type(compressed_pgn_text))
|
||||||
|
|
||||||
|
return ServerReporter.report(config, 'clientSubmitPGN', payload, files)
|
||||||
|
|
||||||
class Cutechess:
|
class Cutechess:
|
||||||
|
|
||||||
## Handles building the very long string of arguments that need to be passed
|
## Handles building the very long string of arguments that need to be passed
|
||||||
@@ -1094,17 +1112,11 @@ def complete_workload(config):
|
|||||||
Cutechess.kill_everything(dev_name, base_name)
|
Cutechess.kill_everything(dev_name, base_name)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if config.workload['test']['upload_pgns'] == 'FALSE':
|
# Upload the PGN if requested
|
||||||
return
|
if config.workload['test']['upload_pgns'] != 'FALSE':
|
||||||
|
compact = config.workload['test']['upload_pgns'] == 'COMPACT'
|
||||||
compact = config.workload['test']['upload_pgns'] == 'COMPACT'
|
pgn_files = [Cutechess.pgn_name(config, timestamp, x) for x in range(cutechess_cnt)]
|
||||||
pgn_files = [Cutechess.pgn_name(config, timestamp, x) for x in range(cutechess_cnt)]
|
ServerReporter.report_pgn(config, compress_list_of_pgns(pgn_files, compact))
|
||||||
compressed = compress_list_of_pgns(pgn_files, compact)
|
|
||||||
|
|
||||||
with open('compressed.pgn.bz2', 'wb') as fout:
|
|
||||||
fout.write(compressed)
|
|
||||||
|
|
||||||
sys.exit()
|
|
||||||
|
|
||||||
def download_opening_book(config):
|
def download_opening_book(config):
|
||||||
|
|
||||||
|
|||||||
+10
-1
@@ -197,4 +197,13 @@ class Network(Model):
|
|||||||
return '[{}] {} ({})'.format(self.engine, self.name, self.sha256)
|
return '[{}] {} ({})'.format(self.engine, self.name, self.sha256)
|
||||||
|
|
||||||
class PGN(Model):
|
class PGN(Model):
|
||||||
pass
|
|
||||||
|
test_id = IntegerField(default=0)
|
||||||
|
result_id = IntegerField(default=0)
|
||||||
|
book_index = IntegerField(default=0)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.filename()
|
||||||
|
|
||||||
|
def filename(self):
|
||||||
|
return '%s.%s.%s.pgn.bz2' % (self.test_id, self.result_id, self.book_index)
|
||||||
@@ -79,6 +79,7 @@ urlpatterns = [
|
|||||||
django.urls.path(r'clientSubmitError/', OpenBench.views.client_submit_error),
|
django.urls.path(r'clientSubmitError/', OpenBench.views.client_submit_error),
|
||||||
django.urls.path(r'clientSubmitResults/', OpenBench.views.client_submit_results),
|
django.urls.path(r'clientSubmitResults/', OpenBench.views.client_submit_results),
|
||||||
django.urls.path(r'clientHeartbeat/', OpenBench.views.client_heartbeat),
|
django.urls.path(r'clientHeartbeat/', OpenBench.views.client_heartbeat),
|
||||||
|
django.urls.path(r'clientSubmitPGN/', OpenBench.views.client_submit_pgn),
|
||||||
|
|
||||||
# Nice endpoints, which can be hit from the website or with credentials cleanly
|
# Nice endpoints, which can be hit from the website or with credentials cleanly
|
||||||
django.urls.path(r'api/config/', OpenBench.views.api_configs),
|
django.urls.path(r'api/config/', OpenBench.views.api_configs),
|
||||||
|
|||||||
@@ -758,6 +758,22 @@ def client_heartbeat(request, machine):
|
|||||||
test = Test.objects.get(id=int(request.POST['test_id']))
|
test = Test.objects.get(id=int(request.POST['test_id']))
|
||||||
return JsonResponse([{}, { 'stop' : True }][test.finished])
|
return JsonResponse([{}, { 'stop' : True }][test.finished])
|
||||||
|
|
||||||
|
@csrf_exempt
|
||||||
|
@verify_worker
|
||||||
|
def client_submit_pgn(request, machine):
|
||||||
|
|
||||||
|
# Format: test.result.book-index.pgn.bz2
|
||||||
|
pgn = PGN()
|
||||||
|
pgn.test_id = int(request.POST['test_id'] )
|
||||||
|
pgn.result_id = int(request.POST['result_id'] )
|
||||||
|
pgn.book_index = int(request.POST['book_index'])
|
||||||
|
pgn.save()
|
||||||
|
|
||||||
|
# Save the .pgn.bz2 to /Media/
|
||||||
|
FileSystemStorage().save(pgn.filename(), ContentFile(request.FILES['file'].read()))
|
||||||
|
|
||||||
|
return JsonResponse({})
|
||||||
|
|
||||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
# #
|
# #
|
||||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
|
|||||||
Reference in new issue
Block a user