-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ch] Dr. CI to use CH Part 1 (#5634)
Moves most queries used by Dr. CI to CH. There are some one off queries that I still need to track down * types changed: the CH query doesn't have nulls, so I changed null checks to check for the corresponding default value ("" for string, 0 for int, time 0 for timestamps) and removed a lot of `!`. This causes a mild conflict with the `JobData` struct, so there's some casting that I don't think actually does anything. I'm also not sure how accurate the typing was originally, since I think some ids were int before too * is there a runtime type checker for typescript? * I tried and failed to add a linter, like https://typescript-eslint.io/rules/strict-boolean-expressions/ to make sure the null/existence checks were correct. It would be nice to figure this out * CH returns timestamps without the "Z" timezone, but they are all in UTC, so use `dayjs.utc` to make sure it is correct (`dayjs` uses local timezone by default) I checked the outputs by cherry picking csl/comp_orig (4db3fa5) onto this branch and origin/main (origin/main also needs 055a919 to fix a bug), running curl `curl "http://localhost:3000/api/drci/drci" --data 'repo=pytorch' > ../_logs/<new, orig>.json`, running a script <summary><details> ``` import json from library import REPO_ROOT import re def failures(thing): thing = thing["failures"] for pr_num in thing: for classification in thing[pr_num]: thing[pr_num][classification] = sorted(thing[pr_num][classification], key=lambda x: x["id"]) for failure in thing[pr_num][classification]: if failure["failure_captures"] == None: failure["failure_captures"] = [] if failure["failure_context"] == None: failure["failure_context"] = [] if failure["failure_lines"] == None: failure["failure_lines"] = [] if failure["runnerName"] == None: failure["runnerName"] = "" for key, value in failure.items(): date_match = re.match(r"(.*) (.*)\.000000000", str(value)) if date_match: failure[key] = f"date" date_match_2 = re.match(r"(\d\d\d\d-\d\d-\d\d)T(\d\d:\d\d:\d\d).*", str(value)) if date_match_2: failure[key] = f"date" return thing def comments(thing): thing = thing["comments"] s = "\n" for pr_num in sorted(thing.keys()): s += f"{pr_num}\n" s += f"{thing[pr_num]['new']}\n" s += f"{thing[pr_num]['body']}\n" return s if __name__ == "__main__": orig_file = REPO_ROOT / "../test-infra/_logs/orig.json" new_file = REPO_ROOT / "../test-infra/_logs/new.json" with open(orig_file, "r") as f: orig = json.load(f) with open(new_file, "r") as f: new = json.load(f) o_thing = failures(orig) n_thing = failures(new) with open(orig_file, "w") as f: json.dump(o_thing, f, indent=2, sort_keys=True) print(comments(orig), file=f) with open(new_file, "w") as f: json.dump(n_thing, f, indent=2, sort_keys=True) print(comments(new), file=f) ``` </details></summary> and the diffing the files There were small differences which I then checked individually, and they were due to the databases not being exactly the same when I did the curls. There were also some small differences in which disable issues were used, but based on the code for that I think it's still technically correct
- Loading branch information
Showing
17 changed files
with
446 additions
and
512 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"pr_nums": "Array(String)", | ||
"owner": "String", | ||
"project": "String" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
SELECT | ||
pr_num, | ||
merge_commit_sha, | ||
FROM | ||
default.merges final | ||
WHERE | ||
pr_num in {pr_nums: Array(Int64)} | ||
AND owner = {owner: String} | ||
AND project = {project: String} | ||
AND merge_commit_sha != '' | ||
ORDER BY | ||
comment_id DESC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.