Skip to content

Commit e10630d

Browse files
authored
Merge pull request #317 from codeflash-ai/replay-test-save-dir
Save replay tests to test dir
2 parents 55a48eb + d8b2ad6 commit e10630d

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

codeflash/cli_cmds/cli.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,6 @@ def process_pyproject_config(args: Namespace) -> Namespace:
137137
assert Path(args.benchmarks_root).is_dir(), (
138138
f"--benchmarks-root {args.benchmarks_root} must be a valid directory"
139139
)
140-
assert Path(args.benchmarks_root).resolve().is_relative_to(Path(args.tests_root).resolve()), (
141-
f"--benchmarks-root {args.benchmarks_root} must be a subdirectory of --tests-root {args.tests_root}"
142-
)
143140
if env_utils.get_pr_number() is not None:
144141
import git
145142

codeflash/optimization/optimizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def run(self) -> None:
128128
trace_file.unlink()
129129

130130
self.replay_tests_dir = Path(
131-
tempfile.mkdtemp(prefix="codeflash_replay_tests_", dir=self.args.benchmarks_root)
131+
tempfile.mkdtemp(prefix="codeflash_replay_tests_", dir=self.args.tests_root)
132132
)
133133
trace_benchmarks_pytest(
134134
self.args.benchmarks_root, self.args.tests_root, self.args.project_root, trace_file

docs/docs/configuration.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ tests-root = "tests"
1616
test-framework = "pytest"
1717
formatter-cmds = ["black $file"]
1818
# optional configuration
19+
benchmarks-root = "tests/benchmarks" # Required when running with --benchmark
1920
ignore-paths = ["my_module/build/"]
2021
pytest-cmd = "pytest"
2122
disable-imports-sorting = false
@@ -29,6 +30,7 @@ Required Options:
2930
- `test-framework`: The test framework you use for your project. Codeflash supports `pytest` and `unittest`.
3031

3132
Optional Configuration:
33+
- `benchmarks-root`: The directory where your benchmarks are located. Codeflash will use this directory to discover existing benchmarks. Note that this option is required when running with `--benchmark`.
3234
- `ignore-paths`: A list of paths withing the `module-root` to ignore when optimizing code. Codeflash will not optimize code in these paths. Useful for ignoring build directories or other generated code. You can also leave this empty if not needed.
3335
- `pytest-cmd`: The command to run your tests. Defaults to `pytest`. You can specify extra commandline arguments here for pytest.
3436
- `formatter-cmds`: The command line to run your code formatter or linter. Defaults to `["black $file"]`. In the command line `$file` refers to the current file being optimized. The assumption with using tools here is that they overwrite the same file and returns a zero exit code. You can also specify multiple tools here that run in a chain as a toml array. You can also disable code formatting by setting this to `["disabled"]`.

docs/docs/optimizing-with-codeflash/benchmarking.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ sidebar_position: 5
33
---
44
# Using Benchmarks
55

6-
Codeflash is able the determine the impact of an optimization on predefined benchmarks, when used in benchmark mode.
6+
Codeflash is able to determine the impact of an optimization on predefined benchmarks, when used in benchmark mode.
77

88
Benchmark mode is an easy way for users to define workflows that are performance-critical and need to be optimized.
99
For example, if a user has an important function that requires minimal latency, the user can define a benchmark for that function.
@@ -13,7 +13,7 @@ Codeflash will then calculate the impact (if any) of any optimization on the per
1313

1414
1. **Create a benchmarks root**
1515

16-
Create a directory for benchmarks. This directory must be a sub directory of your tests directory.
16+
Create a directory for benchmarks if it does not already exist.
1717

1818
In your pyproject.toml, add the path to the 'benchmarks-root' section.
1919
```yaml

0 commit comments

Comments
 (0)