update cli references order
This commit is contained in:
parent
bd6b22d0b4
commit
6f84d0e32a
1 changed files with 181 additions and 176 deletions
|
|
@ -26,6 +26,7 @@ This guide covers all Codeflash CLI commands with practical examples you can run
|
|||
|
||||
---
|
||||
|
||||
|
||||
## Quick Start
|
||||
|
||||
<Tabs>
|
||||
|
|
@ -51,6 +52,186 @@ This guide covers all Codeflash CLI commands with practical examples you can run
|
|||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
---
|
||||
|
||||
## Common Workflows
|
||||
|
||||
### 1. First-Time Setup
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Codeflash">
|
||||
```bash
|
||||
pip install codeflash
|
||||
```
|
||||
</Step>
|
||||
<Step title="Initialize Project">
|
||||
```bash
|
||||
codeflash init
|
||||
```
|
||||
</Step>
|
||||
<Step title="Verify Setup">
|
||||
```bash
|
||||
codeflash --verify-setup
|
||||
```
|
||||
</Step>
|
||||
<Step title="Run First Optimization">
|
||||
```bash
|
||||
codeflash --file src/main.py --function my_function --no-pr
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
---
|
||||
|
||||
### 2. Optimize a Workflow
|
||||
|
||||
<Steps>
|
||||
<Step title="Trace Your Script">
|
||||
```bash
|
||||
codeflash optimize my_script.py --arg1 value1
|
||||
```
|
||||
</Step>
|
||||
<Step title="Review Optimizations">
|
||||
Check the generated PR or local changes for optimization suggestions.
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
---
|
||||
|
||||
### 3. CI/CD Integration
|
||||
|
||||
<Steps>
|
||||
<Step title="Set Up GitHub Actions">
|
||||
```bash
|
||||
codeflash init-actions
|
||||
```
|
||||
</Step>
|
||||
<Step title="Merge the Workflow PR">
|
||||
Review and merge the generated GitHub Actions workflow.
|
||||
</Step>
|
||||
<Step title="Automatic Optimization">
|
||||
Codeflash will now optimize code in every PR automatically!
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
---
|
||||
|
||||
## Help & Version
|
||||
|
||||
```bash
|
||||
# Display version
|
||||
codeflash --version
|
||||
|
||||
# Main help
|
||||
codeflash --help
|
||||
|
||||
# Subcommand help
|
||||
codeflash optimize --help
|
||||
codeflash init --help
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Complete Flag Reference
|
||||
|
||||
### Main Command Flags
|
||||
|
||||
| Flag | Type | Description |
|
||||
|------|------|-------------|
|
||||
| `--file` | `PATH` | Optimize only this file |
|
||||
| `--function` | `NAME` | Optimize only this function (requires `--file`) |
|
||||
| `--all` | `[PATH]` | Optimize all functions. Optional path to start from |
|
||||
| `--replay-test` | `PATH` | Path to replay test file(s) |
|
||||
| `--benchmark` | flag | Enable benchmark mode |
|
||||
| `--no-pr` | flag | Don't create PR, update locally |
|
||||
| `--no-gen-tests` | flag | Don't generate tests |
|
||||
| `--no-draft` | flag | Skip draft PRs |
|
||||
| `--worktree` | flag | Use git worktree |
|
||||
| `--staging-review` | flag | Upload to staging |
|
||||
| `--verbose` / `-v` | flag | Verbose debug output |
|
||||
| `--verify-setup` | flag | Run setup verification |
|
||||
| `--version` | flag | Show version |
|
||||
|
||||
### Configuration Override Flags
|
||||
|
||||
| Flag | Type | Description |
|
||||
|------|------|-------------|
|
||||
| `--config-file` | `PATH` | Path to pyproject.toml |
|
||||
| `--module-root` | `PATH` | Python module root directory |
|
||||
| `--tests-root` | `PATH` | Tests directory |
|
||||
| `--benchmarks-root` | `PATH` | Benchmarks directory |
|
||||
|
||||
### Optimize Subcommand Flags
|
||||
|
||||
| Flag | Type | Description |
|
||||
|------|------|-------------|
|
||||
| `--output` | `PATH` | Trace file output path (default: `codeflash.trace`) |
|
||||
| `--timeout` | `INT` | Maximum trace time in seconds |
|
||||
| `--max-function-count` | `INT` | Max times to trace a function (default: 100) |
|
||||
| `--config-file-path` | `PATH` | Path to pyproject.toml |
|
||||
| `--trace-only` | flag | Only trace, don't optimize |
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
<AccordionGroup>
|
||||
<Accordion title="'Functions outside module-root' Error">
|
||||
**Problem**: Function not found because file is outside `module-root`.
|
||||
|
||||
**Solution**: Ensure your file is within the `module-root` directory specified in `pyproject.toml`.
|
||||
|
||||
```bash
|
||||
# Check your module-root
|
||||
grep "module-root" pyproject.toml
|
||||
|
||||
# Use the correct path (e.g., if module-root is "src")
|
||||
codeflash --file src/myfile.py --function my_function --no-pr
|
||||
```
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="'benchmarks-root must be specified' Error">
|
||||
**Problem**: Using `--benchmark` without specifying benchmarks directory.
|
||||
|
||||
**Solution**: Either add `benchmarks-root` to `pyproject.toml` or use the flag:
|
||||
|
||||
```bash
|
||||
codeflash --file src/app.py --benchmark --benchmarks-root tests/benchmarks --no-pr
|
||||
```
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Replay Test File Not Found">
|
||||
**Problem**: Replay test filename doesn't match expected path.
|
||||
|
||||
**Solution**: Replay tests include the module path in their name. Check the actual filename:
|
||||
|
||||
```bash
|
||||
# Linux/macOS
|
||||
ls tests/test_*replay*.py
|
||||
|
||||
# Windows
|
||||
dir tests\test_*replay*.py
|
||||
```
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="GitHub App Required">
|
||||
**Problem**: PR creation fails due to missing GitHub App.
|
||||
|
||||
**Solution**: Install the Codeflash GitHub App or use `--no-pr` for local optimization:
|
||||
|
||||
```bash
|
||||
# Local optimization
|
||||
codeflash --file src/app.py --function main --no-pr
|
||||
|
||||
# Or install the GitHub App
|
||||
# https://github.com/apps/codeflash-ai/installations/select_target
|
||||
```
|
||||
</Accordion>
|
||||
</AccordionGroup>
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Core Commands
|
||||
|
|
@ -474,182 +655,6 @@ codeflash --all --staging-review --no-pr
|
|||
```
|
||||
</Accordion>
|
||||
|
||||
---
|
||||
|
||||
## Help & Version
|
||||
|
||||
```bash
|
||||
# Display version
|
||||
codeflash --version
|
||||
|
||||
# Main help
|
||||
codeflash --help
|
||||
|
||||
# Subcommand help
|
||||
codeflash optimize --help
|
||||
codeflash init --help
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Complete Flag Reference
|
||||
|
||||
### Main Command Flags
|
||||
|
||||
| Flag | Type | Description |
|
||||
|------|------|-------------|
|
||||
| `--file` | `PATH` | Optimize only this file |
|
||||
| `--function` | `NAME` | Optimize only this function (requires `--file`) |
|
||||
| `--all` | `[PATH]` | Optimize all functions. Optional path to start from |
|
||||
| `--replay-test` | `PATH` | Path to replay test file(s) |
|
||||
| `--benchmark` | flag | Enable benchmark mode |
|
||||
| `--no-pr` | flag | Don't create PR, update locally |
|
||||
| `--no-gen-tests` | flag | Don't generate tests |
|
||||
| `--no-draft` | flag | Skip draft PRs |
|
||||
| `--worktree` | flag | Use git worktree |
|
||||
| `--staging-review` | flag | Upload to staging |
|
||||
| `--verbose` / `-v` | flag | Verbose debug output |
|
||||
| `--verify-setup` | flag | Run setup verification |
|
||||
| `--version` | flag | Show version |
|
||||
|
||||
### Configuration Override Flags
|
||||
|
||||
| Flag | Type | Description |
|
||||
|------|------|-------------|
|
||||
| `--config-file` | `PATH` | Path to pyproject.toml |
|
||||
| `--module-root` | `PATH` | Python module root directory |
|
||||
| `--tests-root` | `PATH` | Tests directory |
|
||||
| `--benchmarks-root` | `PATH` | Benchmarks directory |
|
||||
|
||||
### Optimize Subcommand Flags
|
||||
|
||||
| Flag | Type | Description |
|
||||
|------|------|-------------|
|
||||
| `--output` | `PATH` | Trace file output path (default: `codeflash.trace`) |
|
||||
| `--timeout` | `INT` | Maximum trace time in seconds |
|
||||
| `--max-function-count` | `INT` | Max times to trace a function (default: 100) |
|
||||
| `--config-file-path` | `PATH` | Path to pyproject.toml |
|
||||
| `--trace-only` | flag | Only trace, don't optimize |
|
||||
|
||||
---
|
||||
|
||||
## Common Workflows
|
||||
|
||||
### 1. First-Time Setup
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Codeflash">
|
||||
```bash
|
||||
pip install codeflash
|
||||
```
|
||||
</Step>
|
||||
<Step title="Initialize Project">
|
||||
```bash
|
||||
codeflash init
|
||||
```
|
||||
</Step>
|
||||
<Step title="Verify Setup">
|
||||
```bash
|
||||
codeflash --verify-setup
|
||||
```
|
||||
</Step>
|
||||
<Step title="Run First Optimization">
|
||||
```bash
|
||||
codeflash --file src/main.py --function my_function --no-pr
|
||||
```
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
---
|
||||
|
||||
### 2. Optimize a Workflow
|
||||
|
||||
<Steps>
|
||||
<Step title="Trace Your Script">
|
||||
```bash
|
||||
codeflash optimize my_script.py --arg1 value1
|
||||
```
|
||||
</Step>
|
||||
<Step title="Review Optimizations">
|
||||
Check the generated PR or local changes for optimization suggestions.
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
---
|
||||
|
||||
### 3. CI/CD Integration
|
||||
|
||||
<Steps>
|
||||
<Step title="Set Up GitHub Actions">
|
||||
```bash
|
||||
codeflash init-actions
|
||||
```
|
||||
</Step>
|
||||
<Step title="Merge the Workflow PR">
|
||||
Review and merge the generated GitHub Actions workflow.
|
||||
</Step>
|
||||
<Step title="Automatic Optimization">
|
||||
Codeflash will now optimize code in every PR automatically!
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
<AccordionGroup>
|
||||
<Accordion title="'Functions outside module-root' Error">
|
||||
**Problem**: Function not found because file is outside `module-root`.
|
||||
|
||||
**Solution**: Ensure your file is within the `module-root` directory specified in `pyproject.toml`.
|
||||
|
||||
```bash
|
||||
# Check your module-root
|
||||
grep "module-root" pyproject.toml
|
||||
|
||||
# Use the correct path (e.g., if module-root is "src")
|
||||
codeflash --file src/myfile.py --function my_function --no-pr
|
||||
```
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="'benchmarks-root must be specified' Error">
|
||||
**Problem**: Using `--benchmark` without specifying benchmarks directory.
|
||||
|
||||
**Solution**: Either add `benchmarks-root` to `pyproject.toml` or use the flag:
|
||||
|
||||
```bash
|
||||
codeflash --file src/app.py --benchmark --benchmarks-root tests/benchmarks --no-pr
|
||||
```
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Replay Test File Not Found">
|
||||
**Problem**: Replay test filename doesn't match expected path.
|
||||
|
||||
**Solution**: Replay tests include the module path in their name. Check the actual filename:
|
||||
|
||||
```bash
|
||||
# Linux/macOS
|
||||
ls tests/test_*replay*.py
|
||||
|
||||
# Windows
|
||||
dir tests\test_*replay*.py
|
||||
```
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="GitHub App Required">
|
||||
**Problem**: PR creation fails due to missing GitHub App.
|
||||
|
||||
**Solution**: Install the Codeflash GitHub App or use `--no-pr` for local optimization:
|
||||
|
||||
```bash
|
||||
# Local optimization
|
||||
codeflash --file src/app.py --function main --no-pr
|
||||
|
||||
# Or install the GitHub App
|
||||
# https://github.com/apps/codeflash-ai/installations/select_target
|
||||
```
|
||||
</Accordion>
|
||||
</AccordionGroup>
|
||||
|
||||
---
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue