Skip to content

Commit

Permalink
Refactor: Simplofy code in dev (#33294)
Browse files Browse the repository at this point in the history
  • Loading branch information
eumiro authored Aug 10, 2023
1 parent cc8519d commit 3b313e2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion dev/check_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def check_release(files: list[str], version: str):


def expand_name_variations(files):
return list(sorted(base + suffix for base, suffix in product(files, ["", ".asc", ".sha512"])))
return sorted(base + suffix for base, suffix in product(files, ["", ".asc", ".sha512"]))


def check_upgrade_check(files: list[str], version: str):
Expand Down
2 changes: 1 addition & 1 deletion dev/perf/dags/elastic_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def chain_as_grid(*tasks: BashOperator):
"""
if len(tasks) > 100 * 99 / 2:
raise ValueError("Cannot generate grid DAGs with lateral size larger than 100 tasks.")
grid_size = min(n for n in range(100) if n * (n + 1) / 2 >= len(tasks))
grid_size = next(n for n in range(100) if n * (n + 1) / 2 >= len(tasks))

def index(i, j):
"""
Expand Down
2 changes: 1 addition & 1 deletion dev/send_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def result(
@cli.command("announce")
@click.option(
"--receiver_email",
default=",".join(list(MAILING_LIST.values())),
default=",".join(MAILING_LIST.values()),
prompt="The receiver email (To:)",
help="Receiver's email address. If more than 1, separate them by comma",
)
Expand Down
11 changes: 4 additions & 7 deletions dev/stats/get_important_pr_candidates.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# under the License.
from __future__ import annotations

import heapq
import logging
import math
import pickle
Expand Down Expand Up @@ -346,9 +347,7 @@ def main(
if load:
console.print("Loading PRs from cache and recalculating scores.")
selected_prs = pickle.load(load, encoding="bytes")
issue_num = 0
for pr in selected_prs:
issue_num += 1
for issue_num, pr in enumerate(selected_prs, 1):
console.print(
f"[green]Loading PR: #{pr.pull_request.number} `{pr.pull_request.title}`.[/]"
f" Score: {pr.score}."
Expand All @@ -363,12 +362,10 @@ def main(
repo = g.get_repo("apache/airflow")
commits = repo.get_commits(since=date_start, until=date_end)
pulls: list[PullRequest] = [pull for commit in commits for pull in commit.get_pulls()]
issue_num = 0
scores: dict = {}
for pull in pulls:
for issue_num, pull in enumerate(pulls, 1):
p = PrStat(g=g, pull_request=pull) # type: ignore
scores.update({pull.number: [p.score, pull.title]})
issue_num += 1
console.print(
f"[green]Selecting PR: #{pull.number} `{pull.title}` as candidate.[/]"
f" Score: {scores[pull.number][0]}."
Expand All @@ -384,7 +381,7 @@ def main(
break

console.print(f"Top {top_number} out of {issue_num} PRs:")
for pr_scored in sorted(scores.items(), key=lambda s: s[1], reverse=True)[:top_number]:
for pr_scored in heapq.nlargest(top_number, scores.items(), key=lambda s: s[1]):
console.print(f"[green] * PR #{pr_scored[0]}: {pr_scored[1][1]}. Score: [magenta]{pr_scored[1][0]}")

if save:
Expand Down

0 comments on commit 3b313e2

Please sign in to comment.