Skip to content

Commit 678b55a

Browse files
committed
Revamp and polish the docs more
Signed-off-by: Saurabh Misra <[email protected]>
1 parent fbb4bbe commit 678b55a

File tree

13 files changed

+165
-179
lines changed

13 files changed

+165
-179
lines changed

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: 39 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,29 @@ 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)
1916

2017
<Warning>
2118
**Virtual Environment Required**
2219

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

2522
```bash
26-
# Example: Activate your virtual environment
2723
source venv/bin/activate # On Linux/Mac
2824
# or
29-
#venv\Scripts\activate # On Windows
25+
venv\Scripts\activate # On Windows
3026
```
3127
</Warning>
3228
<Steps>
3329
<Step title="Install Codeflash">
30+
31+
You can install Codeflash locally for a project by running the following command in the project's virtual environment:
3432
```bash
3533
pip install codeflash
3634
```
@@ -39,48 +37,39 @@ pip install codeflash
3937
**Codeflash is a Development Dependency**
4038

4139
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.
40+
Codeflash is intended to be used in development workflows locally and as part of CI.
41+
Try to always use the latest version of Codeflash as it improves quickly.
4442

4543
<CodeGroup>
46-
```toml Poetry
47-
[tool.poetry.dependencies.dev]
48-
codeflash = "^latest"
49-
```
50-
5144
```bash uv
5245
uv add --dev codeflash
5346
```
5447

55-
```bash pip
56-
pip install --dev codeflash
48+
```bash poetry
49+
poetry add codeflash@latest --group dev
5750
```
5851
</CodeGroup>
5952
</Tip>
6053
</Step>
6154

6255
<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.
56+
Codeflash uses cloud-hosted AI models and integrations with GitHub. You'll need an API key to authorize your accesss.
6457

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

6962
<Note>
7063
**Free Tier Available**
7164

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

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

7972
```bash
80-
# Make sure you're in your project root
81-
cd /path/to/your/project
82-
83-
# Run the initialization
8473
codeflash init
8574
```
8675

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

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.
81+
`pyproject.toml` is a configuration file that is used to specify build and tool settings for Python projects.
82+
`pyproject.toml` is the modern replacement for setup.py and requirements.txt files.
9583
</Info>
9684

9785
When running `codeflash init`, you will see the following prompts:
9886

9987
```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)
88+
1. Enter your Codeflash API key:
89+
2. Install the GitHub app.
90+
3. Which Python module do you want me to optimize going forward? (e.g. my_module)
91+
4. Where are your tests located? (e.g. tests/)
92+
5. Which test framework do you use? (pytest/unittest)
93+
6. Install GitHub actions for Continuous optimization?
10494
```
10595
</Step>
10696
</Steps>
10797

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.
98+
After you have answered these questions, the Codeflash configuration will be saved in the `pyproject.toml` file.
99+
To understand the configuration options, and set more advanced options, see the [Manual Configuration](/configuration) page.
111100

112101
### Step 4: Install the Codeflash GitHub App
113102

114103
{/* 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.
104+
Finally, if you have not done so already, Codeflash will ask you to install the GitHub App in your repository.
105+
The Codeflash GitHub App allows access to your repository to the codeflash-ai bot to open PRs, review code, and provide optimization suggestions.
116106

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

131-
# Or optimize locally without creating a PR
132-
codeflash --file path/to/your/file.py --function function_name --no-pr
121+
# Or optimize all functions in your codebase
122+
codeflash --all
133123
```
134124

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

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.
127+
<Tab title="Optimize Example Project">
128+
<Card title="🚀 Try optimizing our example repository" icon="github" href="https://github.com/codeflash-ai/optimize-me">
129+
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.
143130

144131
**What's included:**
145132
- Sample Python code with performance issues
146133
- Tests for verification
147134
- Pre-configured `pyproject.toml`
148-
- Before/after optimization examples in PRs
149135
</Card>
150136

151137
<Steps>
152-
<Step title="Clone the Repository">
138+
<Step title="Fork the Repository">
139+
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.
140+
</Step>
141+
<Step title="Clone the Forked Repository">
153142
```bash
154-
git clone https://github.com/codeflash-ai/optimize-me.git
143+
git clone https://github.com/your_github_username/optimize-me.git
155144
cd optimize-me
156145
```
157146
</Step>
158147

159148
<Step title="Set Up Environment">
160149
```bash
161150
python -m venv .venv
162-
source .venv/bin/activate # or venv\Scripts\activate on Windows
151+
source .venv/bin/activate
163152
pip install -r requirements.txt
164153
pip install codeflash
165154
```
@@ -193,7 +182,9 @@ codeflash --all # optimize the entire repo
193182
</Accordion>
194183

195184
<Accordion title="🧪 No optimizations found or debugging issues">
196-
Use the `--verbose` flag for detailed output:
185+
Do know that not all functions can be optimized as no optimization opportunities may exist for them. This is fine and expected.
186+
187+
To investigate further, use the `--verbose` flag for detailed output:
197188
```bash
198189
codeflash optimize --verbose
199190
```
@@ -203,13 +194,7 @@ codeflash --all # optimize the entire repo
203194
- 🚫 Why certain functions were skipped
204195
- ⚠️ Detailed error messages
205196
- 📊 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>
197+
213198
</Accordion>
214199

215200
<Accordion title="🔍 No tests found errors">
@@ -223,7 +208,7 @@ codeflash --all # optimize the entire repo
223208
pytest --collect-only
224209

225210
# Check your pyproject.toml configuration
226-
cat pyproject.toml | grep -A 5 "\[tool.codeflash\]"
211+
cat pyproject.toml | grep -A 8 "\[tool.codeflash\]"
227212
```
228213
</Accordion>
229214
</AccordionGroup>
@@ -233,5 +218,5 @@ codeflash --all # optimize the entire repo
233218

234219
- Learn about [Codeflash Concepts](/codeflash-concepts/how-codeflash-works)
235220
- Explore [Optimization workflows](/optimizing-with-codeflash/one-function)
236-
- Set up [GitHub Actions integration](/getting-started/codeflash-github-actions)
221+
- Set up [Pull Request Optimization](/optimizing-with-codeflash/codeflash-github-actions)
237222
- 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)