Skip to content

Commit 617a888

Browse files
committed
Merge remote-tracking branch 'origin/main' into blocking-wall-FOR
2 parents 56172db + 680d0da commit 617a888

File tree

5 files changed

+47
-18
lines changed

5 files changed

+47
-18
lines changed

codeflash/LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Business Source License 1.1
33
Parameters
44

55
Licensor: CodeFlash Inc.
6-
Licensed Work: Codeflash Client version 0.9.x
6+
Licensed Work: Codeflash Client version 0.10.x
77
The Licensed Work is (c) 2024 CodeFlash Inc.
88

99
Additional Use Grant: None. Production use of the Licensed Work is only permitted
@@ -13,7 +13,7 @@ Additional Use Grant: None. Production use of the Licensed Work is only permitte
1313
Platform. Please visit codeflash.ai for further
1414
information.
1515

16-
Change Date: 2029-01-06
16+
Change Date: 2029-02-25
1717

1818
Change License: MIT
1919

codeflash/cli_cmds/cmd_init.py

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -220,19 +220,26 @@ def collect_setup_info() -> SetupInfo:
220220
carousel=True,
221221
)
222222

223+
git_remote = ""
223224
try:
224225
repo = Repo(str(module_root), search_parent_directories=True)
225226
git_remotes = get_git_remotes(repo)
226-
if len(git_remotes) > 1:
227-
git_remote = inquirer_wrapper(
228-
inquirer.list_input,
229-
message="What git remote do you want Codeflash to use for new Pull Requests? ",
230-
choices=git_remotes,
231-
default="origin",
232-
carousel=True,
233-
)
227+
if git_remotes: # Only proceed if there are remotes
228+
if len(git_remotes) > 1:
229+
git_remote = inquirer_wrapper(
230+
inquirer.list_input,
231+
message="What git remote do you want Codeflash to use for new Pull Requests? ",
232+
choices=git_remotes,
233+
default="origin",
234+
carousel=True,
235+
)
236+
else:
237+
git_remote = git_remotes[0]
234238
else:
235-
git_remote = git_remotes[0]
239+
click.echo(
240+
"No git remotes found. You can still use Codeflash locally, but you'll need to set up a remote "
241+
"repository to use GitHub features."
242+
)
236243
except InvalidGitRepositoryError:
237244
git_remote = ""
238245

@@ -372,6 +379,19 @@ def install_github_actions() -> None:
372379
workflows_path = git_root / ".github" / "workflows"
373380
optimize_yaml_path = workflows_path / "codeflash.yaml"
374381

382+
# Check if the workflow file already exists
383+
if optimize_yaml_path.exists():
384+
confirm_overwrite = inquirer_wrapper(
385+
inquirer.confirm,
386+
message=f"⚡️ GitHub Actions workflow already exists at {optimize_yaml_path}. Overwrite?",
387+
default=False, # Don't overwrite by default
388+
)
389+
ph("cli-github-optimization-confirm-workflow-overwrite", {"confirm_overwrite": confirm_overwrite})
390+
if not confirm_overwrite:
391+
click.echo("⏩️ Skipping workflow creation.")
392+
ph("cli-github-workflow-skipped")
393+
return
394+
375395
confirm_creation_yes = inquirer_wrapper(
376396
inquirer.confirm,
377397
message="⚡️Shall I set up a GitHub action that will continuously optimize all new code in GitHub PRs"
@@ -574,6 +594,11 @@ def configure_pyproject_toml(setup_info: SetupInfo) -> None:
574594
)
575595
elif formatter == "don't use a formatter":
576596
formatter_cmds.append("disabled")
597+
if formatter in ["black", "ruff"]:
598+
try:
599+
result = subprocess.run([formatter], capture_output=True, check=False)
600+
except FileNotFoundError as e:
601+
click.echo(f"⚠️ Formatter not found: {formatter}, please ensure it is installed")
577602
codeflash_section["formatter-cmds"] = formatter_cmds
578603
# Add the 'codeflash' section, ensuring 'tool' section exists
579604
tool_section = pyproject_data.get("tool", tomlkit.table())

codeflash/github/PrComment.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ class PrComment:
2020
winning_benchmarking_test_results: TestResults
2121

2222
def to_json(self) -> dict[str, Union[dict[str, dict[str, int]], int, str]]:
23+
24+
report_table = {
25+
test_type.to_name(): result
26+
for test_type, result in self.winning_behavioral_test_results.get_test_pass_fail_report_by_type().items()
27+
if test_type.to_name()
28+
}
29+
2330
return {
2431
"optimization_explanation": self.optimization_explanation,
2532
"best_runtime": humanize_runtime(self.best_runtime),
@@ -29,10 +36,7 @@ def to_json(self) -> dict[str, Union[dict[str, dict[str, int]], int, str]]:
2936
"speedup_x": self.speedup_x,
3037
"speedup_pct": self.speedup_pct,
3138
"loop_count": self.winning_benchmarking_test_results.number_of_loops(),
32-
"report_table": {
33-
test_type.to_name(): result
34-
for test_type, result in self.winning_behavioral_test_results.get_test_pass_fail_report_by_type().items()
35-
},
39+
"report_table": report_table
3640
}
3741

3842

codeflash/version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# These version placeholders will be replaced by poetry-dynamic-versioning during `poetry build`.
2-
__version__ = "0.9.2"
3-
__version_tuple__ = (0, 9, 2)
2+
__version__ = "0.10.0"
3+
__version_tuple__ = (0, 10, 0)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ exclude = [
6767

6868
# Versions here the minimum required versions for the project. These should be as loose as possible.
6969
[tool.poetry.dependencies]
70-
python = "^3.9"
70+
python = ">=3.9"
7171
unidiff = ">=0.7.4"
7272
pytest = ">=7.0.0"
7373
gitpython = ">=3.1.31"

0 commit comments

Comments
 (0)