You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/08/04 21:36:15 UTC

[GitHub] [tvm] driazati opened a new pull request, #12310: [ci][tvmbot] Fix authorization filtering

driazati opened a new pull request, #12310:
URL: https://github.com/apache/tvm/pull/12310

   There was a level of unwrapping missing in the check causing it to
   always fail


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] areusch commented on a diff in pull request #12310: [ci][tvmbot] Fix authorization filtering

Posted by GitBox <gi...@apache.org>.
areusch commented on code in PR #12310:
URL: https://github.com/apache/tvm/pull/12310#discussion_r940661376


##########
tests/scripts/github_tvmbot.py:
##########
@@ -524,37 +525,53 @@ def rerun_jenkins_ci(self) -> None:
             post(url, auth=("tvm-bot", TVM_BOT_JENKINS_TOKEN))
 
     def rerun_github_actions(self) -> None:
-        job_ids = []
+        workflow_ids = []
         for item in self.head_commit()["statusCheckRollup"]["contexts"]["nodes"]:
-            if "checkSuite" in item:
-                job_ids.append(item["databaseId"])
+            if "checkSuite" in item and item["conclusion"] == "FAILURE":
+                workflow_id = item["checkSuite"]["workflowRun"]["databaseId"]
+                workflow_ids.append(workflow_id)
 
-        logging.info(f"Rerunning GitHub Actions jobs with IDs: {job_ids}")
+        workflow_ids = list(set(workflow_ids))
+        logging.info(f"Rerunning GitHub Actions workflows with IDs: {workflow_ids}")
         actions_github = GitHubRepo(
             user=self.github.user, repo=self.github.repo, token=GH_ACTIONS_TOKEN
         )
-        for job_id in job_ids:
+        for workflow_id in workflow_ids:
             if self.dry_run:
+                logging.info(f"Dry run, not restarting workflow {workflow_id}")
+            else:
                 try:
-                    actions_github.post(f"actions/jobs/{job_id}/rerun", data={})
+                    actions_github.post(f"actions/runs/{workflow_id}/rerun-failed-jobs", data={})
                 except RuntimeError as e:
+                    logging.exception(e)
                     # Ignore errors about jobs that are part of the same workflow to avoid
                     # having to figure out which jobs are in which workflows ahead of time
                     if "The workflow run containing this job is already running" in str(e):
                         pass
                     else:
                         raise e
-            else:
-                logging.info(f"Dry run, not restarting {job_id}")
 
-    def comment_failure(self, msg: str, exception: Exception):
-        if not self.dry_run:
-            exception_msg = traceback.format_exc()
-            comment = f"{msg} in {args.run_url}\n\n<details>\n\n```\n{exception_msg}\n```\n\n"
+    def comment_failure(self, msg: str, exceptions: Exception):
+        if not isinstance(exceptions, list):

Review Comment:
   isn't this always true, based on the annotated type?



##########
tests/scripts/github_tvmbot.py:
##########
@@ -566,30 +583,35 @@ def check_author(pr, triggering_comment, args):
     return False
 
 
-def check_collaborator(pr, triggering_comment, args):
-    logging.info("Checking collaborators")
-    # Get the list of collaborators for the repo filtered by the comment
-    # author
+def search_users(name, triggering_comment, testing_json, search_fn):
+    logging.info(f"Checking {name}")
     commment_author = triggering_comment["user"]["login"]
-    if args.testing_collaborators_json:
-        collaborators = json.loads(args.testing_collaborators_json)
+    if testing_json:
+        matching_users = json.loads(testing_json)
     else:
-        collaborators = pr.search_collaborator(commment_author)
-    logging.info(f"Found collaborators: {collaborators}")
+        matching_users = search_fn(commment_author)

Review Comment:
   should this just be a param?



##########
tests/scripts/github_tvmbot.py:
##########
@@ -524,37 +525,53 @@ def rerun_jenkins_ci(self) -> None:
             post(url, auth=("tvm-bot", TVM_BOT_JENKINS_TOKEN))
 
     def rerun_github_actions(self) -> None:
-        job_ids = []
+        workflow_ids = []
         for item in self.head_commit()["statusCheckRollup"]["contexts"]["nodes"]:
-            if "checkSuite" in item:
-                job_ids.append(item["databaseId"])
+            if "checkSuite" in item and item["conclusion"] == "FAILURE":
+                workflow_id = item["checkSuite"]["workflowRun"]["databaseId"]
+                workflow_ids.append(workflow_id)
 
-        logging.info(f"Rerunning GitHub Actions jobs with IDs: {job_ids}")
+        workflow_ids = list(set(workflow_ids))
+        logging.info(f"Rerunning GitHub Actions workflows with IDs: {workflow_ids}")
         actions_github = GitHubRepo(
             user=self.github.user, repo=self.github.repo, token=GH_ACTIONS_TOKEN
         )
-        for job_id in job_ids:
+        for workflow_id in workflow_ids:
             if self.dry_run:
+                logging.info(f"Dry run, not restarting workflow {workflow_id}")
+            else:
                 try:
-                    actions_github.post(f"actions/jobs/{job_id}/rerun", data={})
+                    actions_github.post(f"actions/runs/{workflow_id}/rerun-failed-jobs", data={})
                 except RuntimeError as e:
+                    logging.exception(e)
                     # Ignore errors about jobs that are part of the same workflow to avoid
                     # having to figure out which jobs are in which workflows ahead of time
                     if "The workflow run containing this job is already running" in str(e):
                         pass
                     else:
                         raise e
-            else:
-                logging.info(f"Dry run, not restarting {job_id}")
 
-    def comment_failure(self, msg: str, exception: Exception):
-        if not self.dry_run:
-            exception_msg = traceback.format_exc()
-            comment = f"{msg} in {args.run_url}\n\n<details>\n\n```\n{exception_msg}\n```\n\n"
+    def comment_failure(self, msg: str, exceptions: Exception):
+        if not isinstance(exceptions, list):
+            exceptions = [exceptions]
+
+        logging.info(f"Failed, commenting {exceptions}")
+
+        # Extract all the traceback strings
+        for item in exceptions:
+            try:
+                raise item
+            except Exception:
+                item.exception_msg = traceback.format_exc()

Review Comment:
   i think you can just `traceback.format_exc(item)`



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] driazati commented on a diff in pull request #12310: [ci][tvmbot] Fix authorization filtering

Posted by GitBox <gi...@apache.org>.
driazati commented on code in PR #12310:
URL: https://github.com/apache/tvm/pull/12310#discussion_r940709883


##########
tests/scripts/github_tvmbot.py:
##########
@@ -566,30 +583,35 @@ def check_author(pr, triggering_comment, args):
     return False
 
 
-def check_collaborator(pr, triggering_comment, args):
-    logging.info("Checking collaborators")
-    # Get the list of collaborators for the repo filtered by the comment
-    # author
+def search_users(name, triggering_comment, testing_json, search_fn):
+    logging.info(f"Checking {name}")
     commment_author = triggering_comment["user"]["login"]
-    if args.testing_collaborators_json:
-        collaborators = json.loads(args.testing_collaborators_json)
+    if testing_json:
+        matching_users = json.loads(testing_json)
     else:
-        collaborators = pr.search_collaborator(commment_author)
-    logging.info(f"Found collaborators: {collaborators}")
+        matching_users = search_fn(commment_author)

Review Comment:
   the pattern of checking the testing json vs using the actual search is the same between both which is why I merged them so nothing slips by and makes a network request in the tests or something



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] github-actions[bot] commented on pull request #12310: [ci][tvmbot] Fix authorization filtering

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #12310:
URL: https://github.com/apache/tvm/pull/12310#issuecomment-1205907818

   <!---docs-bot-comment-->
   
   Built docs for commit 4654e0e33b286682f4d347786dae2ba6856d5d44 can be found [here](https://pr-docs.tlcpack.ai/PR-12310/4/docs/index.html).


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] areusch merged pull request #12310: [ci][tvmbot] Fix authorization filtering

Posted by GitBox <gi...@apache.org>.
areusch merged PR #12310:
URL: https://github.com/apache/tvm/pull/12310


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] driazati commented on a diff in pull request #12310: [ci][tvmbot] Fix authorization filtering

Posted by GitBox <gi...@apache.org>.
driazati commented on code in PR #12310:
URL: https://github.com/apache/tvm/pull/12310#discussion_r940711718


##########
tests/scripts/github_tvmbot.py:
##########
@@ -524,37 +525,53 @@ def rerun_jenkins_ci(self) -> None:
             post(url, auth=("tvm-bot", TVM_BOT_JENKINS_TOKEN))
 
     def rerun_github_actions(self) -> None:
-        job_ids = []
+        workflow_ids = []
         for item in self.head_commit()["statusCheckRollup"]["contexts"]["nodes"]:
-            if "checkSuite" in item:
-                job_ids.append(item["databaseId"])
+            if "checkSuite" in item and item["conclusion"] == "FAILURE":
+                workflow_id = item["checkSuite"]["workflowRun"]["databaseId"]
+                workflow_ids.append(workflow_id)
 
-        logging.info(f"Rerunning GitHub Actions jobs with IDs: {job_ids}")
+        workflow_ids = list(set(workflow_ids))
+        logging.info(f"Rerunning GitHub Actions workflows with IDs: {workflow_ids}")
         actions_github = GitHubRepo(
             user=self.github.user, repo=self.github.repo, token=GH_ACTIONS_TOKEN
         )
-        for job_id in job_ids:
+        for workflow_id in workflow_ids:
             if self.dry_run:
+                logging.info(f"Dry run, not restarting workflow {workflow_id}")
+            else:
                 try:
-                    actions_github.post(f"actions/jobs/{job_id}/rerun", data={})
+                    actions_github.post(f"actions/runs/{workflow_id}/rerun-failed-jobs", data={})
                 except RuntimeError as e:
+                    logging.exception(e)
                     # Ignore errors about jobs that are part of the same workflow to avoid
                     # having to figure out which jobs are in which workflows ahead of time
                     if "The workflow run containing this job is already running" in str(e):
                         pass
                     else:
                         raise e
-            else:
-                logging.info(f"Dry run, not restarting {job_id}")
 
-    def comment_failure(self, msg: str, exception: Exception):
-        if not self.dry_run:
-            exception_msg = traceback.format_exc()
-            comment = f"{msg} in {args.run_url}\n\n<details>\n\n```\n{exception_msg}\n```\n\n"
+    def comment_failure(self, msg: str, exceptions: Exception):
+        if not isinstance(exceptions, list):
+            exceptions = [exceptions]
+
+        logging.info(f"Failed, commenting {exceptions}")
+
+        # Extract all the traceback strings
+        for item in exceptions:
+            try:
+                raise item
+            except Exception:
+                item.exception_msg = traceback.format_exc()

Review Comment:
   that doesn't work, afaik `format_exc` operates on the last thrown exception only and all of the other methods seem to have a similar limitation: https://docs.python.org/3/library/traceback.html#traceback.format_exc
   
   



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] driazati commented on a diff in pull request #12310: [ci][tvmbot] Fix authorization filtering

Posted by GitBox <gi...@apache.org>.
driazati commented on code in PR #12310:
URL: https://github.com/apache/tvm/pull/12310#discussion_r940712066


##########
tests/scripts/github_tvmbot.py:
##########
@@ -524,37 +525,53 @@ def rerun_jenkins_ci(self) -> None:
             post(url, auth=("tvm-bot", TVM_BOT_JENKINS_TOKEN))
 
     def rerun_github_actions(self) -> None:
-        job_ids = []
+        workflow_ids = []
         for item in self.head_commit()["statusCheckRollup"]["contexts"]["nodes"]:
-            if "checkSuite" in item:
-                job_ids.append(item["databaseId"])
+            if "checkSuite" in item and item["conclusion"] == "FAILURE":
+                workflow_id = item["checkSuite"]["workflowRun"]["databaseId"]
+                workflow_ids.append(workflow_id)
 
-        logging.info(f"Rerunning GitHub Actions jobs with IDs: {job_ids}")
+        workflow_ids = list(set(workflow_ids))
+        logging.info(f"Rerunning GitHub Actions workflows with IDs: {workflow_ids}")
         actions_github = GitHubRepo(
             user=self.github.user, repo=self.github.repo, token=GH_ACTIONS_TOKEN
         )
-        for job_id in job_ids:
+        for workflow_id in workflow_ids:
             if self.dry_run:
+                logging.info(f"Dry run, not restarting workflow {workflow_id}")
+            else:
                 try:
-                    actions_github.post(f"actions/jobs/{job_id}/rerun", data={})
+                    actions_github.post(f"actions/runs/{workflow_id}/rerun-failed-jobs", data={})
                 except RuntimeError as e:
+                    logging.exception(e)
                     # Ignore errors about jobs that are part of the same workflow to avoid
                     # having to figure out which jobs are in which workflows ahead of time
                     if "The workflow run containing this job is already running" in str(e):
                         pass
                     else:
                         raise e
-            else:
-                logging.info(f"Dry run, not restarting {job_id}")
 
-    def comment_failure(self, msg: str, exception: Exception):
-        if not self.dry_run:
-            exception_msg = traceback.format_exc()
-            comment = f"{msg} in {args.run_url}\n\n<details>\n\n```\n{exception_msg}\n```\n\n"
+    def comment_failure(self, msg: str, exceptions: Exception):
+        if not isinstance(exceptions, list):

Review Comment:
   ah forgot to update it to a `Union`



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org