Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Simpify code in dev #33294

Merged
merged 1 commit into from
Aug 10, 2023
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading