Skip to content

chore: remove syntax highlight #158

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 1 commit into from
Jan 28, 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
162 changes: 0 additions & 162 deletions src/codegen/runner/diff/syntax_highlight.py

This file was deleted.

1 change: 0 additions & 1 deletion src/codegen/runner/models/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class RunnerFeatureFlags(BaseModel):
ts_dependency_manager: bool = False

import_resolution_overrides: dict[str, str] = {}
syntax_highlight: bool = False

def encoded_json(self):
return base64.b64encode(self.model_dump_json().encode("utf-8")).decode("utf-8")
Expand Down
14 changes: 0 additions & 14 deletions src/codegen/runner/sandbox/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

from codegen.git.models.pr_options import PROptions
from codegen.runner.diff.get_raw_diff import get_raw_diff
from codegen.runner.diff.syntax_highlight import syntax_highlight_modified_files
from codegen.runner.models.codemod import BranchConfig, Codemod, CodemodRunResult, CreatedBranch, GroupingConfig
from codegen.runner.models.configs import get_runner_feature_flags
from codegen.runner.sandbox.repo import SandboxRepo
from codegen.runner.utils.branch_name import get_head_branch_name
from codegen.runner.utils.exception_utils import update_observation_meta
Expand All @@ -29,12 +27,10 @@ class SandboxExecutor:

codebase: CodebaseType
remote_repo: SandboxRepo
_is_syntax_highlight_enabled: bool

def __init__(self, codebase: CodebaseType):
self.codebase = codebase
self.remote_repo = SandboxRepo(self.codebase)
self._is_syntax_highlight_enabled = get_runner_feature_flags().syntax_highlight

async def find_flags(self, execute_func: Callable) -> list[CodeFlag]:
"""Runs the execute_func in find_mode to find flags"""
Expand Down Expand Up @@ -172,16 +168,6 @@ async def _get_structured_run_output(self, result: CodemodRunResult) -> CodemodR
result.observation = raw_diff
result.base_commit = self.codebase.current_commit.hexsha if self.codebase.current_commit else "HEAD"

if self._is_syntax_highlight_enabled:
logger.info("> Syntax highlighting modified files")
try:
result.highlighted_diff = syntax_highlight_modified_files(self.codebase, raw_diff, flags)
except Exception as e:
# TODO: this doesn't work during webhooks. Maybe due to installation dependencies?
logger.exception(f"Error! Failed to syntax highlight modified files: {e}")
else:
logger.info("> Skipping syntax highlighting, because feature flag is not enabled")

# =====[ Finalize CodemodRun state ]=====
# Include logs etc.
logger.info("> Extracting/formatting logs")
Expand Down
12 changes: 1 addition & 11 deletions tests/unit/codegen/runner/sandbox/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ def codebase(tmpdir, request) -> Codebase:

@pytest.fixture
def executor(codebase: Codebase) -> Generator[SandboxExecutor]:
with patch("codegen.runner.sandbox.executor.get_runner_feature_flags") as mock_ff:
mock_ff.return_value = RunnerFeatureFlags(syntax_highlight=False)

yield SandboxExecutor(codebase)
yield SandboxExecutor(codebase)


@pytest.fixture
Expand All @@ -42,13 +39,6 @@ def runner(codebase: Codebase, tmpdir):
yield SandboxRunner(container_id="ta-123", repo_config=codebase.op.repo_config)


@pytest.fixture(autouse=True)
def mock_runner_flags():
with patch("codegen.runner.sandbox.executor.get_runner_feature_flags") as mock_ff:
mock_ff.return_value = RunnerFeatureFlags(syntax_highlight=False)
yield mock_ff


@pytest.fixture(autouse=True)
def mock_codebase_config():
with patch("codegen.runner.sandbox.runner.get_codebase_config") as mock_config:
Expand Down