Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
ab500c1
Update codeflash.code-workspace
KRRT7 Sep 13, 2025
f98dae6
Update parse_test_output.py
KRRT7 Sep 16, 2025
96211b8
add tests_project_root to the wrappers
KRRT7 Sep 16, 2025
f872d5d
Update codeflash.code-workspace
KRRT7 Sep 16, 2025
ee1d386
Revert "add tests_project_root to the wrappers"
KRRT7 Sep 16, 2025
b858881
Update test_runner.py
KRRT7 Sep 16, 2025
a42c63a
Delete test_extract_test_context_from_frame.py
KRRT7 Sep 17, 2025
fadbdf7
better impl
KRRT7 Sep 17, 2025
1034ee8
Update parse_test_output.py
KRRT7 Sep 17, 2025
4ae0f93
calculate throughput
KRRT7 Sep 17, 2025
fb66ff5
add unit tests
KRRT7 Sep 17, 2025
2190963
fix wrapper validation test
KRRT7 Sep 17, 2025
2a3c975
fix linting
KRRT7 Sep 17, 2025
9c53948
cleanup
KRRT7 Sep 17, 2025
e5c4562
Update function_optimizer.py
KRRT7 Sep 17, 2025
04d31b5
optimized candidate result oo
KRRT7 Sep 17, 2025
8e516fc
critic
KRRT7 Sep 18, 2025
d7f9bbd
update tests again
KRRT7 Sep 18, 2025
58e5592
Update codeflash_wrap_decorator.py
KRRT7 Sep 18, 2025
a7a06ea
Update test_async_wrapper_sqlite_validation.py
KRRT7 Sep 22, 2025
d1b40d0
check.
KRRT7 Sep 22, 2025
a947ea0
go
KRRT7 Sep 22, 2025
2e0f38f
throughput
KRRT7 Sep 22, 2025
d3eefca
perfstdout
KRRT7 Sep 22, 2025
039c5ba
calculate throughtput for baseline
KRRT7 Sep 22, 2025
aba3dcb
Update function_optimizer.py
KRRT7 Sep 22, 2025
d3afd8a
Update critic.py
KRRT7 Sep 22, 2025
971470e
adjust critic
KRRT7 Sep 22, 2025
00a8981
update tests
KRRT7 Sep 22, 2025
1e4b3ba
pre-commit fixes
KRRT7 Sep 22, 2025
654055d
unbound local
KRRT7 Sep 22, 2025
540b8aa
Optimize AsyncCallInstrumenter.visit_ClassDef
codeflash-ai[bot] Sep 22, 2025
7aa30a8
Merge pull request #744 from codeflash-ai/codeflash/optimize-pr739-20…
KRRT7 Sep 22, 2025
fecdc94
Update .pre-commit-config.yaml
KRRT7 Sep 22, 2025
eccdeff
Update pre-commit.yaml
KRRT7 Sep 22, 2025
8b1b2be
Update .pre-commit-config.yaml
KRRT7 Sep 22, 2025
515b976
Delete pre-commit.yaml
KRRT7 Sep 22, 2025
30c8988
give throughput context to explanations
KRRT7 Sep 22, 2025
d8849a5
logger.debug
KRRT7 Sep 23, 2025
47384e2
add end to end test
KRRT7 Sep 23, 2025
43615bd
Create e2e-async.yaml
KRRT7 Sep 23, 2025
9aa34d9
Merge pull request #752 from codeflash-ai/end-to-end-test
KRRT7 Sep 23, 2025
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
69 changes: 69 additions & 0 deletions .github/workflows/e2e-async.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: E2E - Async

on:
pull_request:
paths:
- '**' # Trigger for all paths

workflow_dispatch:

jobs:
async-optimization:
# Dynamically determine if environment is needed only when workflow files change and contributor is external
environment: ${{ (github.event_name == 'workflow_dispatch' || (contains(toJSON(github.event.pull_request.files.*.filename), '.github/workflows/') && github.event.pull_request.user.login != 'misrasaurabh1' && github.event.pull_request.user.login != 'KRRT7')) && 'external-trusted-contributors' || '' }}

runs-on: ubuntu-latest
env:
CODEFLASH_AIS_SERVER: prod
POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
CODEFLASH_API_KEY: ${{ secrets.CODEFLASH_API_KEY }}
COLUMNS: 110
MAX_RETRIES: 3
RETRY_DELAY: 5
EXPECTED_IMPROVEMENT_PCT: 10
CODEFLASH_END_TO_END: 1
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Validate PR
run: |
# Check for any workflow changes
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then
echo "⚠️ Workflow changes detected."

# Get the PR author
AUTHOR="${{ github.event.pull_request.user.login }}"
echo "PR Author: $AUTHOR"

# Allowlist check
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
echo "✅ Authorized user ($AUTHOR). Proceeding."
elif [[ "${{ github.event.pull_request.state }}" == "open" ]]; then
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
else
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
exit 1
fi
else
echo "✅ No workflow file changes detected. Proceeding."
fi

- name: Set up Python 3.11 for CLI
uses: astral-sh/setup-uv@v5
with:
python-version: 3.11.6

- name: Install dependencies (CLI)
run: |
uv sync

- name: Run Codeflash to optimize async code
id: optimize_async_code
run: |
uv run python tests/scripts/end_to_end_test_async.py
19 changes: 0 additions & 19 deletions .github/workflows/pre-commit.yaml

This file was deleted.

3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.7
rev: v0.13.1
hooks:
# Run the linter.
- id: ruff-check
args: [ --config=pyproject.toml ]
# Run the formatter.
- id: ruff-format
18 changes: 15 additions & 3 deletions code_to_optimize/code_directories/async_e2e/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
import time
async def fake_api_call(delay, data):
time.sleep(0.0001)
return f"Processed: {data}"
import asyncio


async def retry_with_backoff(func, max_retries=3):
if max_retries < 1:
raise ValueError("max_retries must be at least 1")
last_exception = None
for attempt in range(max_retries):
try:
return await func()
except Exception as e:
last_exception = e
if attempt < max_retries - 1:
time.sleep(0.0001 * attempt)
raise last_exception
6 changes: 5 additions & 1 deletion codeflash.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@
"request": "launch",
"program": "${workspaceFolder:codeflash}/codeflash/main.py",
"args": [
"--file", "src/async_examples/shocker.py", "--verbose"
"--file",
"src/async_examples/concurrency.py",
"--function",
"task",
"--verbose"
],
"cwd": "${input:chooseCwd}",
"console": "integratedTerminal",
Expand Down
9 changes: 9 additions & 0 deletions codeflash/api/aiservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ def get_new_explanation( # noqa: D417
annotated_tests: str,
optimization_id: str,
original_explanation: str,
original_throughput: str | None = None,
optimized_throughput: str | None = None,
throughput_improvement: str | None = None,
) -> str:
"""Optimize the given python code for performance by making a request to the Django endpoint.

Expand All @@ -314,6 +317,9 @@ def get_new_explanation( # noqa: D417
- annotated_tests: str - test functions annotated with runtime
- optimization_id: str - unique id of opt candidate
- original_explanation: str - original_explanation generated for the opt candidate
- original_throughput: str | None - throughput for the baseline code (operations per second)
- optimized_throughput: str | None - throughput for the optimized code (operations per second)
- throughput_improvement: str | None - throughput improvement percentage

Returns
-------
Expand All @@ -333,6 +339,9 @@ def get_new_explanation( # noqa: D417
"optimization_id": optimization_id,
"original_explanation": original_explanation,
"dependency_code": dependency_code,
"original_throughput": original_throughput,
"optimized_throughput": optimized_throughput,
"throughput_improvement": throughput_improvement,
}
logger.info("Generating explanation")
console.rule()
Expand Down
Loading
Loading