-
Couldn't load subscription status.
- Fork 22
[LSP] validating python and git environment #670
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
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0cd4d5e
validating python and git environment with the lsp
mohammedahmed18 27745fb
revert
mohammedahmed18 d7d1722
fix: processing args in lsp
mohammedahmed18 d598283
Merge branch 'main' into vsc/environment-validation
Saga4 53660de
typo
mohammedahmed18 7d3de7c
Merge branch 'vsc/environment-validation' of github.com:codeflash-ai/…
mohammedahmed18 4ad1e99
lsp: handle when the optimized function is not found
mohammedahmed18 0dcfc15
refactoring
mohammedahmed18 9b69e7d
Merge branch 'main' into vsc/environment-validation
mohammedahmed18 47a5100
native exclude for binary files in the temp diff
mohammedahmed18 a0e2edb
comment
mohammedahmed18 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ | |
| from codeflash.code_utils.git_utils import get_git_diff, get_repo_owner_and_name | ||
| from codeflash.code_utils.time_utils import humanize_runtime | ||
| from codeflash.discovery.discover_unit_tests import discover_unit_tests | ||
| from codeflash.lsp.helpers import is_LSP_enabled | ||
| from codeflash.models.models import FunctionParent | ||
| from codeflash.telemetry.posthog_cf import ph | ||
|
|
||
|
|
@@ -168,6 +169,7 @@ def get_functions_to_optimize( | |
| ) | ||
| functions: dict[str, list[FunctionToOptimize]] | ||
| trace_file_path: Path | None = None | ||
| is_lsp = is_LSP_enabled() | ||
| with warnings.catch_warnings(): | ||
| warnings.simplefilter(action="ignore", category=SyntaxWarning) | ||
| if optimize_all: | ||
|
|
@@ -185,6 +187,8 @@ def get_functions_to_optimize( | |
| if only_get_this_function is not None: | ||
| split_function = only_get_this_function.split(".") | ||
| if len(split_function) > 2: | ||
| if is_lsp: | ||
| return functions, 0, None | ||
| exit_with_message( | ||
| "Function name should be in the format 'function_name' or 'class_name.function_name'" | ||
| ) | ||
|
|
@@ -200,6 +204,8 @@ def get_functions_to_optimize( | |
| ): | ||
| found_function = fn | ||
| if found_function is None: | ||
| if is_lsp: | ||
| return functions, 0, None | ||
| exit_with_message( | ||
| f"Function {only_function_name} not found in file {file}\nor the function does not have a 'return' statement or is a property" | ||
| ) | ||
|
|
@@ -470,6 +476,9 @@ def was_function_previously_optimized( | |
| Tuple of (filtered_functions_dict, remaining_count) | ||
|
|
||
| """ | ||
| if is_LSP_enabled(): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Q: could this raise questions on underterministic nature of optimizations if the function has is same. |
||
| return False | ||
|
|
||
| # Check optimization status if repository info is provided | ||
| # already_optimized_count = 0 | ||
| try: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: rather than regex we can us git diff exclude and list all the exclude file types. or we can alter the .gitignore or gitattributes file too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or we can also go with --diff-filter=AMT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I am thinking either we can just change the file type to text rather than excluding them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah exclude sounds like a good option
actually this shouldn't happen in the first place, git can't apply patches with binary diffs, so this would be the user mistake if he forgot to ignore them