driazati commented on code in PR #11909:
URL: https://github.com/apache/tvm/pull/11909#discussion_r907550352
##########
tests/scripts/github_docs_comment.py:
##########
@@ -77,9 +104,21 @@ def get_pr_and_build_numbers(target_url):
logging.info(f"Skipping this action for user {author}")
sys.exit(0)
- try:
- github.post(url, {"body": body})
- except error.HTTPError as e:
- logging.exception(f"Failed to add docs comment {docs_url}: {e}")
+ # Get all PR comments
+ pr_comments = get_pr_comments(github, url)
+
+ # Iterate over the PR comments and patch any previous comment.
+ if len(pr_comments) != 0:
Review Comment:
This code should probably search for the comment, then afterwards decide if
it was found or not, something like
```
comment = None
search for comment
if comment is None:
create
else:
update
```
##########
tests/scripts/github_docs_comment.py:
##########
@@ -38,6 +49,22 @@ def get_pr_and_build_numbers(target_url):
return {"pr_number": pr_number, "build_number": build_number}
+def patch_comment(github, comment_url, body, docs_url):
+ try:
+ github.patch(comment_url, {"body": body})
+ except error.HTTPError as e:
+ logging.exception(f"Failed to patch docs comment {docs_url}: {e}")
+ exit(1)
+
+
+def post_comment(github, url, body, docs_url):
+ try:
+ github.post(url, {"body": body})
+ except error.HTTPError as e:
+ logging.exception(f"Failed to add docs comment {docs_url}: {e}")
+ exit(1)
Review Comment:
what does the error handling add? it seems like it would log the same info
as the exception itself being thrown
```suggestion
github.post(url, {"body": body})
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]