ci: keep old comment on model replay report (#33759)

keep old
pull/33760/head
Maxime Desroches 7 months ago committed by GitHub
parent d7c0906d0b
commit f11e5492f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 7
      selfdrive/test/process_replay/model_replay.py
  2. 22
      tools/lib/github_utils.py

@ -86,7 +86,8 @@ def comment_replay_report(proposed, master, full_logs):
GITHUB.upload_files(DATA_BUCKET, [(x[0], tmp + '/' + x[0]) for x in files])
log_name = get_log_fn(TEST_ROUTE, get_commit())
commit = get_commit()
log_name = get_log_fn(TEST_ROUTE, commit)
save_log(log_name, full_logs)
GITHUB.upload_file(DATA_BUCKET, os.path.basename(log_name), log_name)
@ -94,8 +95,8 @@ def comment_replay_report(proposed, master, full_logs):
link = GITHUB.get_bucket_link(DATA_BUCKET)
diff_plots = create_table("Model Replay Differences", diff_files, link, open_table=True)
all_plots = create_table("All Model Replay Plots", files, link)
comment = f"new ref: {link}/{log_name}" + diff_plots + all_plots
GITHUB.comment_on_pr(comment, "commaci-public", PR_BRANCH)
comment = f"ref for commit {commit}: {link}/{log_name}" + diff_plots + all_plots
GITHUB.comment_on_pr(comment, PR_BRANCH)
def trim_logs_to_max_frames(logs, max_frames, frs_types, include_all_types):
all_msgs = []

@ -84,18 +84,20 @@ class GithubUtils:
def get_bucket_link(self, bucket):
return f'https://raw.githubusercontent.com/{self.OWNER}/{self.DATA_REPO}/refs/heads/{bucket}'
def comment_on_pr(self, comment, commenter, pr_branch):
def comment_on_pr(self, comment, pr_branch, commenter="", overwrite=False):
pr_number = self.get_pr_number(pr_branch)
data = f'{{"body": "{comment}"}}'
github_path = f'issues/{pr_number}/comments'
r = self.api_call(github_path)
comments = [x['id'] for x in r.json() if x['user']['login'] == commenter]
if comments:
github_path = f'issues/comments/{comments[0]}'
self.api_call(github_path, data=data, method=HTTPMethod.PATCH)
else:
github_path=f'issues/{pr_number}/comments'
self.api_call(github_path, data=data, method=HTTPMethod.POST)
if overwrite:
github_path = f'issues/{pr_number}/comments'
r = self.api_call(github_path)
comments = [x['id'] for x in r.json() if x['user']['login'] == commenter]
if comments:
github_path = f'issues/comments/{comments[0]}'
self.api_call(github_path, data=data, method=HTTPMethod.PATCH)
return
github_path=f'issues/{pr_number}/comments'
self.api_call(github_path, data=data, method=HTTPMethod.POST)
# upload files to github and comment them on the pr
def comment_images_on_pr(self, title, commenter, pr_branch, bucket, images):

Loading…
Cancel
Save