diff --git a/selfdrive/test/process_replay/model_replay.py b/selfdrive/test/process_replay/model_replay.py index 9d102fb5891557..123383477246d2 100755 --- a/selfdrive/test/process_replay/model_replay.py +++ b/selfdrive/test/process_replay/model_replay.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 = [] diff --git a/tools/lib/github_utils.py b/tools/lib/github_utils.py index dd1c3e20d08100..4dc22b9524f7aa 100644 --- a/tools/lib/github_utils.py +++ b/tools/lib/github_utils.py @@ -84,18 +84,20 @@ def get_pr_number(self, pr_branch): 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):