Resolve cross-engine artifact waiting bug

If waiting for artifacts after test creation, the public engine would appear to still be waiting for artifacts infinitely. This resolves that by identifying public engine sources and considering that as being ready
This commit is contained in:
andrew committed 2023-08-05 21:02:28 -04:00
1 parent baf2fac2bf
commit 4c2e669fa2
2 files changed
+87 -40

No files matched your search

+21 -40
View File
@@ -1,45 +1,26 @@
import django.apps # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
import requests, sys, threading, time # #
import OpenBench.utils # OpenBench is a chess engine testing framework authored by Andrew Grant. #
# <https://github.com/AndyGrant/OpenBench> <andrew@grantnet.us> #
# #
# OpenBench is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# OpenBench is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
from OpenBench.watcher import ArtifactWatcher
from django.core.management.commands.runserver import Command as BaseRunserverCommand from django.core.management.commands.runserver import Command as BaseRunserverCommand
class ArtifactWatcher(threading.Thread):
def check_for_artifacts(self, data):
return OpenBench.utils.fetch_artifact_url(*data)
def update_test(self, test):
# Check for Artifacts for Dev
if not (dev_has_all := test.dev.source.endswith('artifacts')):
dev_headers = OpenBench.utils.read_git_credentials(test.dev_engine)
data = [test.dev.source, test.dev_engine, dev_headers, test.dev.sha]
test.dev.source, dev_has_all = self.check_for_artifacts(data)
test.dev.save()
# Check for Artifacts for Base
if not (base_has_all := test.base.source.endswith('artifacts')):
base_headers = OpenBench.utils.read_git_credentials(test.base_engine)
data = [test.base.source, test.base_engine, base_headers, test.base.sha]
test.base.source, base_has_all = self.check_for_artifacts(data)
test.base.save()
# If both finished, flag the test as no longer awaiting
if dev_has_all and base_has_all:
test.awaiting = False
test.save()
def run(self):
while True:
for test in OpenBench.utils.get_awaiting_tests():
try: self.update_test(test)
except:
import traceback, sys
traceback.print_exc()
sys.stdout.flush()
time.sleep(15)
class Command(BaseRunserverCommand): class Command(BaseRunserverCommand):
def inner_run(self, *args, **options): def inner_run(self, *args, **options):
@@ -51,4 +32,4 @@ class Command(BaseRunserverCommand):
self.watcher = ArtifactWatcher().start() self.watcher = ArtifactWatcher().start()
def pre_quit(self): def pre_quit(self):
self.watcher.kill() self.watcher.kill()
+66
View File
@@ -0,0 +1,66 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# OpenBench is a chess engine testing framework authored by Andrew Grant. #
# <https://github.com/AndyGrant/OpenBench> <andrew@grantnet.us> #
# #
# OpenBench is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# OpenBench is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
import requests
import sys
import threading
import time
import traceback
import OpenBench.utils
class ArtifactWatcher(threading.Thread):
def update_test(self, test):
# Public engines end their source with .zip. Private engines end
# their source with /artifacts, iff the artifacts have been found
dev_has = test.dev.source.endswith('artifacts')
dev_has = test.dev.source.endswith('.zip') or dev_has
base_has = test.base.source.endswith('artifacts')
base_has = test.base.source.endswith('.zip') or base_has
if not dev_has: # Check for new Artifacts for Dev
dev_headers = OpenBench.utils.read_git_credentials(test.dev_engine)
data = [test.dev.source, test.dev_engine, dev_headers, test.dev.sha]
test.dev.source, dev_has = OpenBench.utils.fetch_artifact_url(*data)
test.dev.save()
if not base_has: # Check for new Artifacts for Base
base_headers = OpenBench.utils.read_git_credentials(test.base_engine)
data = [test.base.source, test.base_engine, base_headers, test.base.sha]
test.base.source, base_has = OpenBench.utils.fetch_artifact_url(*data)
test.base.save()
# If both finished, flag the test as no longer awaiting
if dev_has and base_has:
test.awaiting = False
test.save()
def run(self):
while True:
for test in OpenBench.utils.get_awaiting_tests():
try: self.update_test(test)
except:
traceback.print_exc()
sys.stdout.flush()
time.sleep(15)