Skip to content

disable concolic testing in LSP mode #450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 27, 2025
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion codeflash/api/aiservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pydantic.json import pydantic_encoder

from codeflash.cli_cmds.console import console, logger
from codeflash.code_utils.env_utils import get_codeflash_api_key
from codeflash.code_utils.env_utils import get_codeflash_api_key, is_LSP_enabled
from codeflash.code_utils.git_utils import get_last_commit_author_if_pr_exists, get_repo_owner_and_name
from codeflash.models.models import OptimizedCandidate
from codeflash.telemetry.posthog_cf import ph
Expand Down Expand Up @@ -182,6 +182,7 @@ def optimize_python_code_line_profiler( # noqa: D417
"python_version": platform.python_version(),
"experiment_metadata": experiment_metadata,
"codeflash_version": codeflash_version,
"lsp_mode": is_LSP_enabled(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: What changes in aiservices are we thinking to change for LSP server?
No of candidates and tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently we only limit the number of line profiler candidates to 5, the aiservice already is ready for this change

}

logger.info("Generating optimized candidates…")
Expand Down
7 changes: 6 additions & 1 deletion codeflash/code_utils/env_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pathlib import Path
from typing import Any, Optional

from codeflash.cli_cmds.console import logger
from codeflash.cli_cmds.console import console, logger
from codeflash.code_utils.code_utils import exit_with_message
from codeflash.code_utils.formatter import format_code
from codeflash.code_utils.shell_utils import read_api_key_from_shell_config
Expand Down Expand Up @@ -110,3 +110,8 @@ def get_cached_gh_event_data() -> dict[str, Any] | None:
return None
with Path(event_path).open() as f:
return json.load(f) # type: ignore # noqa


@lru_cache(maxsize=1)
def is_LSP_enabled() -> bool:
return console.quiet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Isnt it redundant as we already have it in main function in beta.py?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, console.quiet by default is False, beta.py sets it to True & this function let's other parts of the codebase when it's been set to true.

6 changes: 6 additions & 0 deletions codeflash/verification/concolic_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from codeflash.cli_cmds.console import console, logger
from codeflash.code_utils.compat import SAFE_SYS_EXECUTABLE
from codeflash.code_utils.concolic_utils import clean_concolic_tests
from codeflash.code_utils.env_utils import is_LSP_enabled
from codeflash.code_utils.static_analysis import has_typed_parameters
from codeflash.discovery.discover_unit_tests import discover_unit_tests
from codeflash.telemetry.posthog_cf import ph
Expand All @@ -28,6 +29,11 @@ def generate_concolic_tests(
start_time = time.perf_counter()
function_to_concolic_tests = {}
concolic_test_suite_code = ""

if is_LSP_enabled():
logger.debug("Skipping concolic test generation in LSP mode")
return function_to_concolic_tests, concolic_test_suite_code

if (
test_cfg.concolic_test_root_dir
and isinstance(function_to_optimize_ast, (ast.FunctionDef, ast.AsyncFunctionDef))
Expand Down
Loading