Allow multiple artifacts in a single Job
This commit is contained in:
1 parent
2c90f7a4a7
commit
a6c3922d45
2 files changed
+10
-28
No files matched your search
@@ -7,33 +7,18 @@ from django.core.management.commands.runserver import Command as BaseRunserverCo
|
||||
class ArtifactWatcher(threading.Thread):
|
||||
|
||||
def check_for_artifacts(self, data):
|
||||
|
||||
# Success, if we had all artifacts. Otherwise consider re-running the Workflow
|
||||
retval, has_all = OpenBench.utils.fetch_artifact_url(*data, return_data=True)
|
||||
if has_all: return retval, True
|
||||
|
||||
# Otherwise, we may have returned the Jobs + Artifacts
|
||||
jobs, artifacts = retval
|
||||
|
||||
# Catch expired artifacts, or a Github API bug and run the Workflow
|
||||
if all(job['conclusion'] == 'success' for job in jobs):
|
||||
run_id = jobs[0]['run_id']
|
||||
url = OpenBench.utils.path_join(data[0], 'actions', 'runs', str(run_id), 'rerun')
|
||||
requests.post(url=url, headers=data[2]).json()
|
||||
|
||||
# We did not have all artifacts needed, return the original source
|
||||
return data[0], False
|
||||
return OpenBench.utils.fetch_artifact_url(*data)
|
||||
|
||||
def update_test(self, test):
|
||||
|
||||
# Check for Artifacts for Dev, and re-run if needed
|
||||
# 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, and re-run if needed
|
||||
# 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]
|
||||
|
||||
+7
-10
@@ -244,6 +244,8 @@ def collect_github_info(request, errors, field):
|
||||
assert private or 'sha' in data['commit']['tree']
|
||||
|
||||
except: # Unable to find for whatever reason
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
errors.append('%s could not be found' % (branch))
|
||||
return (None, None)
|
||||
|
||||
@@ -266,7 +268,7 @@ def collect_github_info(request, errors, field):
|
||||
url, has_all = fetch_artifact_url(base, engine, headers, data['sha'])
|
||||
return (url, branch, data['sha'], bench), has_all
|
||||
|
||||
def fetch_artifact_url(base, engine, headers, sha, return_data=False):
|
||||
def fetch_artifact_url(base, engine, headers, sha):
|
||||
|
||||
try:
|
||||
# Fetch the run id for the openbench workflow for this comment
|
||||
@@ -282,17 +284,12 @@ def fetch_artifact_url(base, engine, headers, sha, return_data=False):
|
||||
url = path_join(base, 'actions', 'runs', str(run_id), 'artifacts')
|
||||
artifacts = requests.get(url=url, headers=headers).json()['artifacts']
|
||||
|
||||
# All jobs finished, with an associated, non-expired Artifact
|
||||
error = any(job['conclusion'] != 'success' for job in jobs)
|
||||
error = error or any(artifact['expired'] for artifact in artifacts)
|
||||
error = error or len(jobs) != len(artifacts)
|
||||
|
||||
# Toss back the data if we care about it
|
||||
if error and return_data:
|
||||
return ((jobs, artifacts), False)
|
||||
# All jobs finished, with at least one non-expired Artifact
|
||||
assert not any(job['conclusion'] != 'success' for job in jobs)
|
||||
assert not any(artifact['expired'] for artifact in artifacts)
|
||||
assert len(artifacts) >= len(jobs)
|
||||
|
||||
# Only set the url if we have everything we need
|
||||
assert not error
|
||||
return (url, True)
|
||||
|
||||
except Exception as error:
|
||||
|
||||
Reference in new issue
Block a user