Skip to content

Commit c18b146

Browse files
committed
Merge branch 'windows-fixes' of https://github.com/codeflash-ai/codeflash into windows-fixes
2 parents fa44c89 + 997e8cf commit c18b146

33 files changed

+627
-558
lines changed

.github/workflows/codeflash-optimize.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ concurrency:
1212

1313
jobs:
1414
optimize:
15-
name: Optimize new code in this PR
15+
name: Optimize new Python code
1616
if: ${{ github.actor != 'codeflash-ai[bot]' }}
1717
runs-on: ubuntu-latest
1818
env:
@@ -22,23 +22,24 @@ jobs:
2222
CODEFLASH_PR_NUMBER: ${{ github.event.number }}
2323
COLUMNS: 110
2424
steps:
25-
- uses: actions/checkout@v4
25+
- name: 🛎️ Checkout
26+
uses: actions/checkout@v4
2627
with:
2728
fetch-depth: 0
2829

29-
- name: Set up Python 3.11 for CLI
30+
- name: 🐍 Set up Python 3.11 for CLI
3031
uses: astral-sh/setup-uv@v5
3132
with:
3233
python-version: 3.11.6
3334

34-
- name: Install dependencies (CLI)
35+
- name: 📦 Install dependencies (CLI)
3536
run: |
3637
uv tool install poetry
3738
uv venv
3839
source .venv/bin/activate
3940
poetry install --with dev
4041
41-
- name: Run Codeflash to optimize code
42+
- name: ⚡️Codeflash Optimization
4243
id: optimize_code
4344
run: |
4445
source .venv/bin/activate

codeflash/cli_cmds/cmd_init.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def init_codeflash() -> None:
7373

7474
install_github_app()
7575

76-
install_github_actions()
76+
install_github_actions(override_formatter_check=True)
7777

7878
click.echo(
7979
f"{LF}"
@@ -362,9 +362,9 @@ def check_for_toml_or_setup_file() -> str | None:
362362
return cast(str, project_name)
363363

364364

365-
def install_github_actions() -> None:
365+
def install_github_actions(override_formatter_check: bool=False) -> None:
366366
try:
367-
config, config_file_path = parse_config_file()
367+
config, config_file_path = parse_config_file(override_formatter_check=override_formatter_check)
368368

369369
ph("cli-github-actions-install-started")
370370
try:
@@ -504,11 +504,11 @@ def get_dependency_manager_installation_string(dep_manager: DependencyManager) -
504504
py_version = sys.version_info
505505
python_version_string = f"'{py_version.major}.{py_version.minor}'"
506506
if dep_manager == DependencyManager.UV:
507-
return """name: Setup UV
507+
return """name: 🐍 Setup UV
508508
uses: astral-sh/setup-uv@v4
509509
with:
510510
enable-cache: true"""
511-
return f"""name: Set up Python
511+
return f"""name: 🐍 Set up Python
512512
uses: actions/setup-python@v5
513513
with:
514514
python-version: {python_version_string}"""

codeflash/cli_cmds/console.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
)
2828

2929
logger = logging.getLogger("rich")
30-
30+
logging.getLogger('parso').setLevel(logging.WARNING)
3131

3232
def paneled_text(
3333
text: str, panel_args: dict[str, str | bool] | None = None, text_args: dict[str, str] | None = None

codeflash/cli_cmds/workflows/codeflash-optimize.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ concurrency:
1515

1616
jobs:
1717
optimize:
18-
name: Optimize new Python code in this PR
18+
name: Optimize new Python code
1919
# Don't run codeflash on codeflash-ai[bot] commits, prevent duplicate optimizations
2020
if: ${{ github.actor != 'codeflash-ai[bot]' }}
2121
runs-on: ubuntu-latest
@@ -24,11 +24,12 @@ jobs:
2424
CODEFLASH_PR_NUMBER: ${{ github.event.number }}
2525
{{ working_directory }}
2626
steps:
27-
- uses: actions/checkout@v4
27+
- name: 🛎️ Checkout
28+
uses: actions/checkout@v4
2829
with:
2930
fetch-depth: 0
3031
- {{ setup_python_dependency_manager }}
31-
- name: Install Project Dependencies
32+
- name: 📦 Install Dependencies
3233
run: {{ install_dependencies_command }}
33-
- name: Run Codeflash to optimize code
34+
- name: ⚡️Codeflash Optimization
3435
run: {{ codeflash_command }}

codeflash/code_utils/config_parser.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def find_pyproject_toml(config_file: Path | None = None) -> Path:
3131
raise ValueError(msg)
3232

3333

34-
def parse_config_file(config_file_path: Path | None = None) -> tuple[dict[str, Any], Path]:
34+
def parse_config_file(config_file_path: Path | None = None, override_formatter_check: bool=False) -> tuple[dict[str, Any], Path]:
3535
config_file_path = find_pyproject_toml(config_file_path)
3636
try:
3737
with config_file_path.open("rb") as f:
@@ -85,10 +85,12 @@ def parse_config_file(config_file_path: Path | None = None) -> tuple[dict[str, A
8585
"In pyproject.toml, Codeflash only supports the 'test-framework' as pytest and unittest."
8686
)
8787
if len(config["formatter-cmds"]) > 0:
88-
assert config["formatter-cmds"][0] != "your-formatter $file", (
89-
"The formatter command is not set correctly in pyproject.toml. Please set the "
90-
"formatter command in the 'formatter-cmds' key. More info - https://docs.codeflash.ai/configuration"
91-
)
88+
#see if this is happening during Github actions setup
89+
if not override_formatter_check:
90+
assert config["formatter-cmds"][0] != "your-formatter $file", (
91+
"The formatter command is not set correctly in pyproject.toml. Please set the "
92+
"formatter command in the 'formatter-cmds' key. More info - https://docs.codeflash.ai/configuration"
93+
)
9294
for key in list(config.keys()):
9395
if "-" in key:
9496
config[key.replace("-", "_")] = config[key]

codeflash/code_utils/instrument_existing_tests.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
from codeflash.cli_cmds.console import logger
1010
from codeflash.code_utils.code_utils import get_run_tmp_file, module_name_from_file_path
1111
from codeflash.discovery.functions_to_optimize import FunctionToOptimize
12-
from codeflash.models.models import FunctionParent, TestingMode
13-
from codeflash.verification.test_results import VerificationType
12+
from codeflash.models.models import FunctionParent, TestingMode, VerificationType
1413

1514
if TYPE_CHECKING:
1615
from collections.abc import Iterable

codeflash/discovery/discover_unit_tests.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
from codeflash.cli_cmds.console import console, logger
1717
from codeflash.code_utils.code_utils import get_run_tmp_file, module_name_from_file_path
1818
from codeflash.code_utils.compat import SAFE_SYS_EXECUTABLE
19-
from codeflash.models.models import CodePosition, FunctionCalledInTest, TestsInFile
20-
from codeflash.verification.test_results import TestType
19+
from codeflash.models.models import CodePosition, FunctionCalledInTest, TestsInFile, TestType
2120

2221
if TYPE_CHECKING:
2322
from codeflash.verification.verification_utils import TestConfig

codeflash/discovery/pytest_new_process_discovery.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ def pytest_collection_finish(self, session) -> None:
1616
collected_tests.extend(session.items)
1717
pytest_rootdir = session.config.rootdir
1818

19+
def pytest_collection_modifyitems(config, items):
20+
skip_benchmark = pytest.mark.skip(reason="Skipping benchmark tests")
21+
for item in items:
22+
if "benchmark" in item.fixturenames:
23+
item.add_marker(skip_benchmark)
1924

2025
def parse_pytest_collection_results(pytest_tests: list[Any]) -> list[dict[str, str]]:
2126
test_results = []
@@ -34,7 +39,7 @@ def parse_pytest_collection_results(pytest_tests: list[Any]) -> list[dict[str, s
3439

3540
try:
3641
exitcode = pytest.main(
37-
[tests_root, "-pno:logging", "--collect-only", "-m", "not skip"], plugins=[PytestCollectionPlugin()]
42+
[tests_root, "-p no:logging", "--collect-only", "-m", "not skip",], plugins=[PytestCollectionPlugin()]
3843
)
3944
except Exception as e: # noqa: BLE001
4045
print(f"Failed to collect tests: {e!s}") # noqa: T201

codeflash/github/PrComment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pydantic.dataclasses import dataclass
55

66
from codeflash.code_utils.time_utils import humanize_runtime
7-
from codeflash.verification.test_results import TestResults
7+
from codeflash.models.models import TestResults
88

99

1010
@dataclass(frozen=True, config={"arbitrary_types_allowed": True})

0 commit comments

Comments
 (0)