Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 11 additions & 31 deletions codeflash/lsp/beta.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,37 +235,11 @@ def get_config_suggestions(_params: any) -> dict[str, any]:
tests_root_suggestions.append(".")
default_tests_root = tests_root_suggestions[0] if tests_root_suggestions else "."

try:
configured_module_root = (
Path(server.args.module_root).relative_to(Path.cwd()) if server.args.module_root else None
)
except: # noqa : E722
configured_module_root = None
try:
configured_tests_root = Path(server.args.tests_root).relative_to(Path.cwd()) if server.args.tests_root else None
except: # noqa : E722
configured_tests_root = None
try:
configured_test_framework = server.args.test_framework if server.args.test_framework else None
except: # noqa : E722
configured_test_framework = None
configured_formatter = ""
try:
if isinstance(server.args.formatter_cmds, list):
configured_formatter = " && ".join([cmd.strip() for cmd in server.args.formatter_cmds])
elif isinstance(server.args.formatter_cmds, str):
configured_formatter = server.args.formatter_cmds.strip()
except: # noqa : E722
configured_formatter = "disabled"

return {
"module_root": {"choices": module_root_suggestions, "default": configured_module_root or default_module_root},
"tests_root": {"choices": tests_root_suggestions, "default": configured_tests_root or default_tests_root},
"test_framework": {
"choices": test_framework_suggestions,
"default": configured_test_framework or default_test_framework,
},
"formatter_cmds": {"choices": formatter_suggestions, "default": configured_formatter or default_formatter},
"module_root": {"choices": module_root_suggestions, "default": default_module_root},
"tests_root": {"choices": tests_root_suggestions, "default": default_tests_root},
"test_framework": {"choices": test_framework_suggestions, "default": default_test_framework},
"formatter_cmds": {"choices": formatter_suggestions, "default": default_formatter},
}


Expand Down Expand Up @@ -319,7 +293,13 @@ def init_project(params: ValidateProjectParams) -> dict[str, str]:
}

args = process_args()
return {"status": "success", "moduleRoot": args.module_root, "pyprojectPath": pyproject_toml_path, "root": root}
return {
"status": "success",
"moduleRoot": args.module_root,
"pyprojectPath": pyproject_toml_path,
"root": root,
"existingConfig": config,
}


def _initialize_optimizer_if_api_key_is_valid(api_key: Optional[str] = None) -> dict[str, str]:
Expand Down
Loading