|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | 3 | import ast |
4 | | -import json |
5 | 4 | import os |
6 | 5 | import tempfile |
7 | 6 | import time |
|
13 | 12 | from codeflash.cli_cmds.console import console, logger, progress_bar |
14 | 13 | from codeflash.code_utils import env_utils |
15 | 14 | from codeflash.code_utils.code_utils import cleanup_paths, get_run_tmp_file |
16 | | -from codeflash.code_utils.env_utils import get_pr_number |
| 15 | +from codeflash.code_utils.env_utils import get_pr_number, is_pr_draft |
17 | 16 | from codeflash.either import is_successful |
18 | 17 | from codeflash.models.models import ValidCode |
19 | 18 | from codeflash.telemetry.posthog_cf import ph |
@@ -64,7 +63,6 @@ def run_benchmarks( |
64 | 63 | from codeflash.benchmarking.replay_test import generate_replay_test |
65 | 64 | from codeflash.benchmarking.trace_benchmarks import trace_benchmarks_pytest |
66 | 65 | from codeflash.benchmarking.utils import print_benchmark_table, validate_and_format_benchmark_table |
67 | | - from codeflash.code_utils.env_utils import get_pr_number |
68 | 66 |
|
69 | 67 | with progress_bar( |
70 | 68 | f"Running benchmarks in {self.args.benchmarks_root}", transient=True, revert_to_print=bool(get_pr_number()) |
@@ -394,18 +392,3 @@ def run_with_args(args: Namespace) -> None: |
394 | 392 | optimizer.cleanup_temporary_paths() |
395 | 393 |
|
396 | 394 | raise SystemExit from None |
397 | | - |
398 | | - |
399 | | -def is_pr_draft() -> bool: |
400 | | - """Check if the PR is draft. in the github action context.""" |
401 | | - try: |
402 | | - event_path = os.getenv("GITHUB_EVENT_PATH") |
403 | | - pr_number = get_pr_number() |
404 | | - if pr_number is not None and event_path: |
405 | | - with Path(event_path).open() as f: |
406 | | - event_data = json.load(f) |
407 | | - return bool(event_data["pull_request"]["draft"]) |
408 | | - return False # noqa |
409 | | - except Exception as e: |
410 | | - logger.warning(f"Error checking if PR is draft: {e}") |
411 | | - return False |
0 commit comments