Skip to content

Commit 9b69e7d

Browse files
Merge branch 'main' into vsc/environment-validation
2 parents 0dcfc15 + 217ced2 commit 9b69e7d

File tree

14 files changed

+171
-180
lines changed

14 files changed

+171
-180
lines changed

codeflash/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# These version placeholders will be replaced by uv-dynamic-versioning during build.
2-
__version__ = "0.16.3.post94.dev0+7d3de7c5"
2+
__version__ = "0.16.6"

docs/codeflash-concepts/how-codeflash-works.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Codeflash runs tests for the target function using either pytest or unittest fra
5757

5858
#### Performance benchmarking
5959

60-
Codeflash implements [several techniques](/codeflash-concepts/benchmarking.md) to measure code performance accurately. In particular, it runs multiple iterations of the code in a loop to determine the best performance with the minimum runtime. Codeflash compares the performance of the original code against the optimization, requiring at least a 10% speed improvement before considering it to be faster. This approach eliminates most runtime measurement variability, even on noisy CI systems and virtual machines. The final runtime Codeflash reports is the minimum total time it took to run all the test cases.
60+
Codeflash implements [several techniques](/codeflash-concepts/benchmarking) to measure code performance accurately. In particular, it runs multiple iterations of the code in a loop to determine the best performance with the minimum runtime. Codeflash compares the performance of the original code against the optimization, requiring at least a 10% speed improvement before considering it to be faster. This approach eliminates most runtime measurement variability, even on noisy CI systems and virtual machines. The final runtime Codeflash reports is the minimum total time it took to run all the test cases.
6161

6262
## Creating Pull Requests
6363

docs/docs.json

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,24 @@
2525
]
2626
},
2727
{
28-
"group": "🚀 Getting Started",
28+
"group": "🚀 Quickstart",
2929
"pages": [
3030
"getting-started/local-installation"
3131
]
3232
},
3333
{
34-
"group": "🔧 Continuous Optimization",
34+
"group": "⚡ Optimizing with Codeflash",
3535
"pages": [
36-
"getting-started/codeflash-github-actions",
37-
"optimizing-with-codeflash/optimize-prs",
38-
"optimizing-with-codeflash/benchmarking"
36+
"optimizing-with-codeflash/one-function",
37+
"optimizing-with-codeflash/trace-and-optimize",
38+
"optimizing-with-codeflash/codeflash-all"
3939
]
4040
},
4141
{
42-
"group": "⚡ Optimization Workflows",
42+
"group": "✨ Continuous Optimization",
4343
"pages": [
44-
"optimizing-with-codeflash/one-function",
45-
"optimizing-with-codeflash/trace-and-optimize",
46-
"optimizing-with-codeflash/codeflash-all"
44+
"optimizing-with-codeflash/codeflash-github-actions",
45+
"optimizing-with-codeflash/benchmarking"
4746
]
4847
},
4948
{
@@ -62,21 +61,7 @@
6261
}
6362
]
6463
}
65-
],
66-
"global": {
67-
"anchors": [
68-
{
69-
"anchor": "GitHub",
70-
"href": "https://github.com/codeflash-ai",
71-
"icon": "github"
72-
},
73-
{
74-
"anchor": "Discord",
75-
"href": "https://www.codeflash.ai/discord",
76-
"icon": "discord"
77-
}
78-
]
79-
}
64+
]
8065
},
8166
"logo": {
8267
"light": "/images/codeflash_light.svg",
@@ -85,8 +70,14 @@
8570
"navbar": {
8671
"links": [
8772
{
88-
"label": "Contact",
89-
"href": "mailto:[email protected]"
73+
"label": "Discord",
74+
"href": "https://www.codeflash.ai/discord",
75+
"icon": "discord"
76+
},
77+
{
78+
"label": "GitHub",
79+
"href": "https://github.com/codeflash-ai/codeflash",
80+
"icon": "github"
9081
},
9182
{
9283
"label": "Blog",
@@ -113,7 +104,7 @@
113104
"footer": {
114105
"socials": {
115106
"discord": "https://www.codeflash.ai/discord",
116-
"github": "https://github.com/codeflash-ai",
107+
"github": "https://github.com/codeflash-ai/codeflash",
117108
"linkedin": "https://www.linkedin.com/company/codeflash-ai"
118109
},
119110
"links": [

docs/getting-started/local-installation.mdx

Lines changed: 42 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,32 @@ icon: "download"
66

77
Codeflash is installed and configured on a per-project basis.
88

9-
You can install Codeflash locally for a project by running the following command in the project's virtual environment:
10-
119
### Prerequisites
1210

1311
Before installing Codeflash, ensure you have:
1412

1513
1. **Python 3.9 or above** installed
1614
2. **A Python project** with a virtual environment
1715
3. **Project dependencies installed** in your virtual environment
18-
4. **Tests** (optional) for your code (Codeflash uses tests to verify optimizations)
16+
17+
Good to have (optional):
18+
1. **Unit Tests** that Codeflash uses to ensure correctness of the optimizations
1919

2020
<Warning>
2121
**Virtual Environment Required**
2222

2323
Always install Codeflash in your project's virtual environment, not globally. Make sure your virtual environment is activated before proceeding.
2424

2525
```bash
26-
# Example: Activate your virtual environment
2726
source venv/bin/activate # On Linux/Mac
2827
# or
29-
#venv\Scripts\activate # On Windows
28+
venv\Scripts\activate # On Windows
3029
```
3130
</Warning>
3231
<Steps>
3332
<Step title="Install Codeflash">
33+
34+
You can install Codeflash locally for a project by running the following command in the project's virtual environment:
3435
```bash
3536
pip install codeflash
3637
```
@@ -39,48 +40,39 @@ pip install codeflash
3940
**Codeflash is a Development Dependency**
4041

4142
We recommend installing Codeflash as a development dependency.
42-
It doesn't need to be installed as part of your package requirements.
43-
Codeflash is intended to be used locally and as part of development workflows such as CI.
43+
Codeflash is intended to be used in development workflows locally and as part of CI.
44+
Try to always use the latest version of Codeflash as it improves quickly.
4445

4546
<CodeGroup>
46-
```toml Poetry
47-
[tool.poetry.dependencies.dev]
48-
codeflash = "^latest"
49-
```
50-
5147
```bash uv
5248
uv add --dev codeflash
5349
```
5450

55-
```bash pip
56-
pip install --dev codeflash
51+
```bash poetry
52+
poetry add codeflash@latest --group dev
5753
```
5854
</CodeGroup>
5955
</Tip>
6056
</Step>
6157

6258
<Step title="Generate a Codeflash API Key">
63-
Codeflash uses cloud-hosted AI models to optimize your code. You'll need an API key to use it.
59+
Codeflash uses cloud-hosted AI models and integrations with GitHub. You'll need an API key to authorize your access.
6460

65-
1. Visit the [Codeflash Web App](https://app.codeflash.ai/)
61+
1. Visit the [Codeflash Web App](https://app.codeflash.ai/)
6662
2. Sign up with your GitHub account (free)
6763
3. Navigate to the [API Key](https://app.codeflash.ai/app/apikeys) page to generate your API key
6864

6965
<Note>
7066
**Free Tier Available**
7167

72-
Codeflash offers a **free tier** with a limited number of optimizations per month. Perfect for trying it out or small projects!
68+
Codeflash offers a **free tier** with a limited number of optimizations. Perfect for trying it out on small projects!
7369
</Note>
7470
</Step>
7571

7672
<Step title="Run Automatic Configuration">
7773
Navigate to your project's root directory (where your `pyproject.toml` file is or should be) and run:
7874

7975
```bash
80-
# Make sure you're in your project root
81-
cd /path/to/your/project
82-
83-
# Run the initialization
8476
codeflash init
8577
```
8678

@@ -89,30 +81,31 @@ If you don't have a pyproject.toml file yet, the codeflash init command will ask
8981
<Info>
9082
**What's pyproject.toml?**
9183

92-
`pyproject.toml` is a configuration file that is used to specify build tool settings for Python projects.
93-
pyproject.toml is the modern replacement for setup.py and requirements.txt files.
94-
It's the new standard for Python package metadata.
84+
`pyproject.toml` is a configuration file that is used to specify build and tool settings for Python projects.
85+
`pyproject.toml` is the modern replacement for setup.py and requirements.txt files.
9586
</Info>
9687

9788
When running `codeflash init`, you will see the following prompts:
9889

9990
```text
100-
1. Enter your Codeflash API key:
101-
2. Which Python module do you want me to optimize going forward? (e.g. my_module)
102-
3. Where are your tests located? (e.g. tests/)
103-
4. Which test framework do you use? (pytest/unittest)
91+
1. Enter your Codeflash API key:
92+
2. Install the GitHub app.
93+
3. Which Python module do you want me to optimize going forward? (e.g. my_module)
94+
4. Where are your tests located? (e.g. tests/)
95+
5. Which test framework do you use? (pytest/unittest)
96+
6. Install GitHub actions for Continuous optimization?
10497
```
10598
</Step>
10699
</Steps>
107100

108-
After you have answered these questions, Codeflash will be configured for your project.
109-
The configuration will be saved in the `pyproject.toml` file in the root directory of your project.
110-
To understand the configuration options, and set more advanced options, see the [Configuration](/configuration) page.
101+
After you have answered these questions, the Codeflash configuration will be saved in the `pyproject.toml` file.
102+
To understand the configuration options, and set more advanced options, see the [Manual Configuration](/configuration) page.
111103

112104
### Step 4: Install the Codeflash GitHub App
113105

114106
{/* TODO: Justify to users Why we need the user to install Github App even in local Installation or local optimization? */}
115-
Finally, if you have not done so already, Codeflash will ask you to install the Github App in your repository. The Codeflash GitHub App allows access to your repository to the codeflash-ai bot to open PRs, review code, and provide optimization suggestions.
107+
Finally, if you have not done so already, Codeflash will ask you to install the GitHub App in your repository.
108+
The Codeflash GitHub App allows access to your repository to the codeflash-ai bot to open PRs, review code, and provide optimization suggestions.
116109

117110
Please [install the Codeflash GitHub
118111
app](https://github.com/apps/codeflash-ai/installations/select_target) by choosing the repository you want to install
@@ -128,38 +121,37 @@ Once configured, you can start optimizing your code immediately:
128121
# Optimize a specific function
129122
codeflash --file path/to/your/file.py --function function_name
130123

131-
# Or optimize locally without creating a PR
132-
codeflash --file path/to/your/file.py --function function_name --no-pr
124+
# Or optimize all functions in your codebase
125+
codeflash --all
133126
```
134127

135-
<Tip>
136-
**Pro tip**: Start with a single function to see how Codeflash works before running it on your entire codebase.
137-
</Tip>
138128
</Tab>
139129

140-
<Tab title="Example Project">
141-
<Card title="🚀 Try Our Example Repository" icon="github" href="https://github.com/codeflash-ai/optimize-me">
142-
Want to see Codeflash in action? Check out our **optimize-me** repository with real examples.
130+
<Tab title="Optimize Example Project">
131+
<Card title="🚀 Try optimizing our example repository" icon="github" href="https://github.com/codeflash-ai/optimize-me">
132+
Want to see Codeflash in action and don't know what code to optimize? Check out our **optimize-me** repository with code ready to optimize.
143133

144134
**What's included:**
145135
- Sample Python code with performance issues
146136
- Tests for verification
147137
- Pre-configured `pyproject.toml`
148-
- Before/after optimization examples in PRs
149138
</Card>
150139

151140
<Steps>
152-
<Step title="Clone the Repository">
141+
<Step title="Fork the Repository">
142+
Fork the [optimize-me](https://github.com/codeflash-ai/optimize-me) repo to your GitHub account by clicking "Fork" on the top of the page. This allows Codeflash to open Pull Requests with the optimizations it found on your forked repo.
143+
</Step>
144+
<Step title="Clone the Forked Repository">
153145
```bash
154-
git clone https://github.com/codeflash-ai/optimize-me.git
146+
git clone https://github.com/your_github_username/optimize-me.git
155147
cd optimize-me
156148
```
157149
</Step>
158150

159151
<Step title="Set Up Environment">
160152
```bash
161153
python -m venv .venv
162-
source .venv/bin/activate # or venv\Scripts\activate on Windows
154+
source .venv/bin/activate
163155
pip install -r requirements.txt
164156
pip install codeflash
165157
```
@@ -193,7 +185,9 @@ codeflash --all # optimize the entire repo
193185
</Accordion>
194186

195187
<Accordion title="🧪 No optimizations found or debugging issues">
196-
Use the `--verbose` flag for detailed output:
188+
Do know that not all functions can be optimized as no optimization opportunities may exist for them. This is fine and expected.
189+
190+
To investigate further, use the `--verbose` flag for detailed output:
197191
```bash
198192
codeflash optimize --verbose
199193
```
@@ -203,13 +197,7 @@ codeflash --all # optimize the entire repo
203197
- 🚫 Why certain functions were skipped
204198
- ⚠️ Detailed error messages
205199
- 📊 Performance analysis results
206-
207-
<Tip>
208-
**Common Reasons Functions Are Skipped:**
209-
- Function is too simple (less than 3 lines)
210-
- Function has no clear performance bottleneck
211-
- Function contains unsupported constructs
212-
</Tip>
200+
213201
</Accordion>
214202

215203
<Accordion title="🔍 No tests found errors">
@@ -223,7 +211,7 @@ codeflash --all # optimize the entire repo
223211
pytest --collect-only
224212

225213
# Check your pyproject.toml configuration
226-
cat pyproject.toml | grep -A 5 "\[tool.codeflash\]"
214+
cat pyproject.toml | grep -A 8 "\[tool.codeflash\]"
227215
```
228216
</Accordion>
229217
</AccordionGroup>
@@ -233,5 +221,5 @@ codeflash --all # optimize the entire repo
233221

234222
- Learn about [Codeflash Concepts](/codeflash-concepts/how-codeflash-works)
235223
- Explore [Optimization workflows](/optimizing-with-codeflash/one-function)
236-
- Set up [GitHub Actions integration](/getting-started/codeflash-github-actions)
224+
- Set up [Pull Request Optimization](/optimizing-with-codeflash/codeflash-github-actions)
237225
- Read [configuration options](/configuration) for advanced setups

docs/getting-the-best-out-of-codeflash.mdx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,30 @@ sidebarTitle: "Best Practices"
66
keywords: ["best practices", "tips", "github actions", "tracer", "optimization", "workflow"]
77
---
88

9-
# Getting the best out of Codeflash
9+
Codeflash is a powerful tool; here are our recommendations based on how the Codeflash team and our customers use Codeflash.
1010

11-
Codeflash is a powerful tool; here are our recommendations based on how the Codeflash team uses Codeflash.
11+
### Install the GitHub App and actions workflow
1212

13-
### Install the Github App and actions workflow
14-
15-
After you install Codeflash on an actively developed project, [installing the GitHub App](getting-started/codeflash-github-actions) and setting up the
16-
GitHub Actions workflow will automatically optimize your code whenever new pull requests are opened. This ensures you get the best version of any changes you make to your code without any extra effort. We find that PRs are also the best time to review these changes, because the code is fresh in your mind.
13+
After you install Codeflash on an actively developed project, [installing the GitHub Actions](optimizing-with-codeflash/codeflash-github-actions) will automatically optimize your code whenever new pull requests are opened. This ensures you get the best version of any changes you make to your code without any extra effort. We find that PRs are also the best time to review these changes, because the code is fresh in your mind.
1714

1815
### Find and optimize entire scripts with the Codeflash Tracer
1916

2017
Find the best results by running [Codeflash Optimize](optimizing-with-codeflash/trace-and-optimize) on your script to optimize it.
2118
This internally runs a profiler, captures inputs to all the functions your script calls, and uses those inputs to create Replay tests and benchmarks.
2219
The optimizations you get with this method, show you how much faster your workflow will get plus guarantee that your workflow won't break if you merge in the optimizations.
2320

24-
###
2521

2622
### Find optimizations on your whole codebase with `codeflash --all`
2723

2824
If you have a lot of existing code, run [`codeflash --all`](optimizing-with-codeflash/codeflash-all) to discover and fix any
2925
slow code in your project. Codeflash will open new pull requests for any optimizations it finds, and you can review and merge them at your own pace.
3026

27+
It is first recommended to trace your tests to achieve higher quality optimizations with this approach
28+
29+
```bash
30+
codeflash optimize --trace-only -m pytest tests/ ; codeflash --all
31+
```
32+
3133

3234
### Review the PRs Codeflash opens
3335

527 KB
Loading
-33.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)