Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ runs:
environment-file: tests/conda/build-environment.yaml
auto-activate-base: false
miniforge-version: latest
python-version: 3.9
python-version: "3.10"
condarc-file: tests/conda/condarc
- uses: conda-incubator/setup-miniconda@fc2d68f6413eb2d87b895e92f8584b5b94a10167 # v3.3.0
if: steps.conda1.outcome == 'failure'
Expand All @@ -27,7 +27,7 @@ runs:
auto-activate-base: false
miniforge-version: latest
use-only-tar-bz2: true
python-version: 3.9
python-version: "3.10"
condarc-file: tests/conda/condarc
- name: Conda info
shell: pwsh
Expand Down
5 changes: 2 additions & 3 deletions ci/jenkins/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import textwrap
from dataclasses import dataclass
from pathlib import Path
from typing import List, Optional

import jinja2
from data import data
Expand All @@ -41,7 +40,7 @@ class Change:

@dataclass
class ChangeData:
diff: Optional[str]
diff: str | None
content: str
destination: Path
source: Path
Expand All @@ -53,7 +52,7 @@ def lines_without_generated_tag(content):
]


def change_type(lines: List[str]) -> Change:
def change_type(lines: list[str]) -> Change:
"""
Return True if 'line' only edits an image tag or if 'line' is not a changed
line in a diff
Expand Down
3 changes: 1 addition & 2 deletions ci/scripts/github/github_cc_reviewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import re
import sys
from pathlib import Path
from typing import List
from urllib import error

# Hackery to enable importing of utils from ci/scripts/jenkins
Expand All @@ -33,7 +32,7 @@
from git_utils import GitHubRepo, git, parse_remote


def find_reviewers(body: str) -> List[str]:
def find_reviewers(body: str) -> list[str]:
print(f"Parsing body:\n{body}")
matches = re.findall(r"(cc( @[-A-Za-z0-9]+)+)", body, flags=re.MULTILINE)
matches = [full for full, last in matches]
Expand Down
12 changes: 6 additions & 6 deletions ci/scripts/github/github_commenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import re
import sys
from pathlib import Path
from typing import Any, Dict, List, Optional, Tuple
from typing import Any

# Hackery to enable importing of utils from ci/scripts/jenkins
REPO_ROOT = Path(__file__).resolve().parent.parent.parent.parent
Expand All @@ -36,13 +36,13 @@
class BotCommentBuilder:
ALLOWLIST_USERS = {"driazati", "gigiblender", "areusch"}

def __init__(self, github: GitHubRepo, data: Dict[str, Any]):
def __init__(self, github: GitHubRepo, data: dict[str, Any]):
self.github = github
self.pr_number = data["number"]
self.comment_data = data["comments"]["nodes"]
self.author = data["author"]["login"]

def find_bot_comment(self) -> Optional[Dict[str, Any]]:
def find_bot_comment(self) -> dict[str, Any] | None:
"""
Return the existing bot comment or None if it does not exist
"""
Expand All @@ -57,7 +57,7 @@ def find_bot_comment(self) -> Optional[Dict[str, Any]]:
logging.info("No existing comment found")
return None

def find_existing_body(self) -> Dict[str, str]:
def find_existing_body(self) -> dict[str, str]:
"""
Find existing dynamic bullet point items
"""
Expand All @@ -84,7 +84,7 @@ def find_existing_body(self) -> Dict[str, str]:
logging.info(f"Found body items: {items}")
return items

def _post_comment(self, body_items: Dict[str, str]):
def _post_comment(self, body_items: dict[str, str]):
comment = BOT_COMMENT_START + "\n\n" + WELCOME_TEXT + "\n\n"
for key, content in body_items.items():
line = self.start_key(key) + "\n * " + content.strip() + self.end_key(key)
Expand Down Expand Up @@ -118,7 +118,7 @@ def start_key(self, key: str) -> str:
def end_key(self, key: str) -> str:
return f"<!--bot-comment-{key}-end-->"

def post_items(self, items: List[Tuple[str, str]]):
def post_items(self, items: list[tuple[str, str]]):
"""
Update or post bullet points in the PR based on 'items' which is a
list of (key, text) pairs
Expand Down
6 changes: 3 additions & 3 deletions ci/scripts/github/github_docs_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
# specific language governing permissions and limitations
# under the License.

from typing import Any, Dict
from typing import Any


def build_docs_url(base_url_docs, pr_number, build_number):
return f"{base_url_docs}/PR-{pr_number!s}/{build_number!s}/docs/index.html"


def find_target_url(pr_head: Dict[str, Any]):
def find_target_url(pr_head: dict[str, Any]):
for status in pr_head["statusCheckRollup"]["contexts"]["nodes"]:
if status.get("context", "") == "tvm-ci/pr-head":
return status["targetUrl"]
Expand All @@ -39,7 +39,7 @@ def get_pr_and_build_numbers(target_url):
return {"pr_number": pr_number, "build_number": build_number}


def get_doc_url(pr: Dict[str, Any], base_docs_url: str = "https://pr-docs.tlcpack.ai") -> str:
def get_doc_url(pr: dict[str, Any], base_docs_url: str = "https://pr-docs.tlcpack.ai") -> str:
pr_head = pr["commits"]["nodes"][0]["commit"]
target_url = find_target_url(pr_head)
pr_and_build = get_pr_and_build_numbers(target_url)
Expand Down
10 changes: 5 additions & 5 deletions ci/scripts/github/github_skipped_tests_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import os
import subprocess
from pathlib import Path
from typing import Any, Dict, Optional
from typing import Any
from xml.etree import ElementTree


Expand Down Expand Up @@ -154,7 +154,7 @@ def build_comment(
return text


def find_target_url(pr_head: Dict[str, Any]):
def find_target_url(pr_head: dict[str, Any]):
for status in pr_head["statusCheckRollup"]["contexts"]["nodes"]:
if status.get("context", "") == "tvm-ci/pr-head":
return status["targetUrl"]
Expand All @@ -163,14 +163,14 @@ def find_target_url(pr_head: Dict[str, Any]):


def get_skipped_tests_comment(
pr: Dict[str, Any],
pr: dict[str, Any],
github,
s3_prefix: str = "tvm-jenkins-artifacts-prod",
jenkins_prefix: str = "ci.tlcpack.ai",
pr_test_report_dir: str = "pr-reports",
main_test_report_dir: str = "main-reports",
common_commit_sha: Optional[str] = None,
common_main_build: Optional[Dict[str, Any]] = None,
common_commit_sha: str | None = None,
common_main_build: dict[str, Any] | None = None,
additional_tests_to_check_file: str = "required_tests_to_run.json",
) -> str:
pr_head = pr["commits"]["nodes"][0]["commit"]
Expand Down
16 changes: 8 additions & 8 deletions ci/scripts/github/github_tag_teams.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import re
import sys
from pathlib import Path
from typing import Any, Dict, List, Optional, Tuple
from typing import Any

# Hackery to enable importing of utils from ci/scripts/jenkins
REPO_ROOT = Path(__file__).resolve().parent.parent.parent.parent
Expand All @@ -36,7 +36,7 @@
GITHUB_NAME_REGEX = r"@[a-zA-Z0-9-]+"


def parse_line(line: str) -> Tuple[str, List[str]]:
def parse_line(line: str) -> tuple[str, list[str]]:
line = line.lstrip(" -")
line = line.split()

Expand Down Expand Up @@ -86,7 +86,7 @@ def fetch_issue(github: GitHubRepo, issue_number: int):
return r


def parse_teams(r: Dict[str, Any], issue_number: int) -> Dict[str, str]:
def parse_teams(r: dict[str, Any], issue_number: int) -> dict[str, str]:
"""
Fetch an issue and parse out series of tagged people from the issue body
and comments
Expand Down Expand Up @@ -131,11 +131,11 @@ def add_tag(tag, users):
return {k.lower(): v for k, v in result.items() if k.strip()}


def tags_from_labels(labels: List[Dict[str, Any]]) -> List[str]:
def tags_from_labels(labels: list[dict[str, Any]]) -> list[str]:
return [label["name"] for label in labels]


def add_ccs_to_body(body: str, to_cc: List[str]) -> str:
def add_ccs_to_body(body: str, to_cc: list[str]) -> str:
lines = body.split("\n")

cc_line_idx = None
Expand Down Expand Up @@ -174,8 +174,8 @@ def gen_cc_line(users):


def determine_users_to_cc(
issue: Dict[str, Any], github: GitHubRepo, team_issue: str, issue_data: Optional[Dict[str, Any]]
) -> List[str]:
issue: dict[str, Any], github: GitHubRepo, team_issue: str, issue_data: dict[str, Any] | None
) -> list[str]:
if issue_data is None:
issue_data = fetch_issue(github, issue_number=int(team_issue))

Expand Down Expand Up @@ -205,7 +205,7 @@ def determine_users_to_cc(
return to_cc


def get_tags(pr_data: Dict[str, Any], github: GitHubRepo, team_issue: int) -> str:
def get_tags(pr_data: dict[str, Any], github: GitHubRepo, team_issue: int) -> str:
to_cc = determine_users_to_cc(
issue=pr_data, github=github, team_issue=team_issue, issue_data=None
)
Expand Down
37 changes: 19 additions & 18 deletions ci/scripts/github/github_tvmbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
import sys
import traceback
import warnings
from collections.abc import Callable
from pathlib import Path
from typing import Any, Callable, Dict, List, Optional, Union
from typing import Any

# Hackery to enable importing of utils from ci/scripts/jenkins
REPO_ROOT = Path(__file__).resolve().parent.parent.parent.parent
Expand All @@ -35,9 +36,9 @@
from cmd_utils import init_log
from git_utils import GitHubRepo, git, parse_remote, post

Review = Dict[str, Any]
CIJob = Dict[str, Any]
Comment = Dict[str, Any]
Review = dict[str, Any]
CIJob = dict[str, Any]
Comment = dict[str, Any]
CommentChecker = Callable[[Comment], bool]

EXPECTED_JOBS = ["tvm-ci/pr-head"]
Expand Down Expand Up @@ -194,7 +195,7 @@ def __init__(
owner: str,
repo: str,
dry_run: bool = False,
raw_data: Optional[Dict[str, Any]] = None,
raw_data: dict[str, Any] | None = None,
):
self.owner = owner
self.number = number
Expand Down Expand Up @@ -242,7 +243,7 @@ def checker(obj, parent_key):
def __repr__(self):
return json.dumps(self.raw, indent=2)

def react(self, comment: Dict[str, Any], content: str):
def react(self, comment: dict[str, Any], content: str):
"""
React with a thumbs up to a comment
"""
Expand All @@ -256,7 +257,7 @@ def react(self, comment: Dict[str, Any], content: str):
def head_commit(self):
return self.raw["commits"]["nodes"][0]["commit"]

def co_authors(self) -> List[str]:
def co_authors(self) -> list[str]:
authors = []
for commit in self.raw["authorCommits"]["nodes"]:
# Co-authors always come after the main author according to the
Expand All @@ -271,7 +272,7 @@ def co_authors(self) -> List[str]:
def head_oid(self):
return self.head_commit()["oid"]

def ci_jobs(self) -> List[CIJob]:
def ci_jobs(self) -> list[CIJob]:
"""
Get a list of all CI jobs (GitHub Actions and other) in a unified format
"""
Expand Down Expand Up @@ -310,14 +311,14 @@ def ci_jobs(self) -> List[CIJob]:
logging.info(f"Found CI jobs for {self.head_commit()['oid']} {to_json_str(jobs)}")
return jobs

def reviews(self) -> List[Review]:
def reviews(self) -> list[Review]:
return self.raw["reviews"]["nodes"]

def head_commit_reviews(self) -> List[Review]:
def head_commit_reviews(self) -> list[Review]:
"""
Find reviews associated with the head commit
"""
commits_to_review_status: Dict[str, List[Review]] = {}
commits_to_review_status: dict[str, list[Review]] = {}

for review in self.reviews():
if not review["authorCanPushToRepository"]:
Expand Down Expand Up @@ -347,13 +348,13 @@ def fetch_data(self):
},
)["data"]["repository"]["pullRequest"]

def search_collaborator(self, user: str) -> List[Dict[str, Any]]:
def search_collaborator(self, user: str) -> list[dict[str, Any]]:
"""
Query GitHub for collaborators matching 'user'
"""
return self.search_users(user, COLLABORATORS_QUERY)["collaborators"]["nodes"]

def search_users(self, user: str, query: str) -> List[Dict[str, Any]]:
def search_users(self, user: str, query: str) -> list[dict[str, Any]]:
return self.github.graphql(
query=query,
variables={
Expand All @@ -363,7 +364,7 @@ def search_users(self, user: str, query: str) -> List[Dict[str, Any]]:
},
)["data"]["repository"]

def search_mentionable_users(self, user: str) -> List[Dict[str, Any]]:
def search_mentionable_users(self, user: str) -> list[dict[str, Any]]:
return self.search_users(user, MENTIONABLE_QUERY)["mentionableUsers"]["nodes"]

def comment(self, text: str) -> None:
Expand Down Expand Up @@ -449,15 +450,15 @@ def merge(self) -> None:
def author(self) -> str:
return self.raw["author"]["login"]

def find_failed_ci_jobs(self) -> List[CIJob]:
def find_failed_ci_jobs(self) -> list[CIJob]:
# NEUTRAL is GitHub Action's way of saying cancelled
return [
job
for job in self.ci_jobs()
if job["status"] not in {"SUCCESS", "SUCCESSFUL", "SKIPPED"}
]

def find_missing_expected_jobs(self) -> List[str]:
def find_missing_expected_jobs(self) -> list[str]:
# Map of job name: has seen in completed jobs
seen_expected_jobs = {name: False for name in EXPECTED_JOBS}
logging.info(f"Expected to see jobs: {seen_expected_jobs}")
Expand Down Expand Up @@ -485,7 +486,7 @@ def trigger_gha_ci(self, sha: str) -> None:
)
logging.info(f"Successful workflow_dispatch: {r}")

def merge_if_passed_checks(self) -> Optional[Dict[str, Any]]:
def merge_if_passed_checks(self) -> dict[str, Any] | None:
failed_ci_jobs = self.find_failed_ci_jobs()
all_ci_passed = len(failed_ci_jobs) == 0
has_one_approval = False
Expand Down Expand Up @@ -576,7 +577,7 @@ def rerun_github_actions(self) -> None:
else:
raise e

def comment_failure(self, msg: str, exceptions: Union[Exception, List[Exception]]):
def comment_failure(self, msg: str, exceptions: Exception | list[Exception]):
if not isinstance(exceptions, list):
exceptions = [exceptions]

Expand Down
Loading
Loading