Skip to content

Commit 1d3aeb9

Browse files
committed
wrapped
1 parent 7a6b204 commit 1d3aeb9

12 files changed

Lines changed: 35 additions & 40 deletions

File tree

codeflash/api/aiservice.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,6 @@ def get_optimization_review(
722722
function_trace_id: str,
723723
coverage_message: str,
724724
replay_tests: str,
725-
concolic_tests: str,
726725
calling_fn_details: str,
727726
) -> OptimizationReviewResult:
728727
"""Compute the optimization review of current Pull Request.

codeflash/benchmarking/plugin/plugin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def get_benchmark_timings(trace_path: Path) -> dict[BenchmarkKey, int]:
200200

201201
# Pytest hooks
202202
@pytest.hookimpl
203-
def pytest_sessionfinish(self, session, exitstatus) -> None:
203+
def pytest_sessionfinish(self, session, exitstatus) -> None: # noqa: ANN001
204204
"""Execute after whole test run is completed."""
205205
# Write any remaining benchmark timings to the database
206206
codeflash_trace.close()
@@ -218,7 +218,7 @@ def pytest_collection_modifyitems(config: pytest.Config, items: list[pytest.Item
218218
skip_no_benchmark = pytest.mark.skip(reason="Test requires benchmark fixture")
219219
for item in items:
220220
# Check for direct benchmark fixture usage
221-
has_fixture = hasattr(item, "fixturenames") and "benchmark" in item.fixturenames
221+
has_fixture = hasattr(item, "fixturenames") and "benchmark" in item.fixturenames # ty:ignore[unsupported-operator]
222222

223223
# Check for @pytest.mark.benchmark marker
224224
has_marker = False
@@ -236,7 +236,7 @@ class Benchmark: # noqa: D106
236236
def __init__(self, request: pytest.FixtureRequest) -> None:
237237
self.request = request
238238

239-
def __call__(self, func, *args, **kwargs): # type: ignore # noqa: ANN002, ANN003, ANN204, PGH003
239+
def __call__(self, func, *args, **kwargs): # noqa: ANN001, ANN002, ANN003, ANN204
240240
"""Handle both direct function calls and decorator usage."""
241241
if args or kwargs:
242242
# Used as benchmark(func, *args, **kwargs)

codeflash/code_utils/code_extractor.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ def visit_FunctionDef(self, node: cst.FunctionDef) -> Optional[bool]:
4444
self.scope_depth += 1
4545
return True
4646

47-
def leave_FunctionDef(self, original_node: cst.FunctionDef) -> None: # noqa: ARG002
47+
def leave_FunctionDef(self, original_node: cst.FunctionDef) -> None:
4848
self.scope_depth -= 1
4949

50-
def visit_ClassDef(self, node: cst.ClassDef) -> Optional[bool]: # noqa: ARG002
50+
def visit_ClassDef(self, node: cst.ClassDef) -> Optional[bool]:
5151
self.scope_depth += 1
5252
return True
5353

54-
def leave_ClassDef(self, original_node: cst.ClassDef) -> None: # noqa: ARG002
54+
def leave_ClassDef(self, original_node: cst.ClassDef) -> None:
5555
self.scope_depth -= 1
5656

5757

@@ -65,7 +65,7 @@ def __init__(self, new_functions: dict[str, cst.FunctionDef], new_function_order
6565
self.processed_functions: set[str] = set()
6666
self.scope_depth = 0
6767

68-
def visit_FunctionDef(self, node: cst.FunctionDef) -> None: # noqa: ARG002
68+
def visit_FunctionDef(self, node: cst.FunctionDef) -> None:
6969
self.scope_depth += 1
7070

7171
def leave_FunctionDef(self, original_node: cst.FunctionDef, updated_node: cst.FunctionDef) -> cst.FunctionDef:
@@ -80,14 +80,14 @@ def leave_FunctionDef(self, original_node: cst.FunctionDef, updated_node: cst.Fu
8080
return self.new_functions[name]
8181
return updated_node
8282

83-
def visit_ClassDef(self, node: cst.ClassDef) -> None: # noqa: ARG002
83+
def visit_ClassDef(self, node: cst.ClassDef) -> None:
8484
self.scope_depth += 1
8585

86-
def leave_ClassDef(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.ClassDef: # noqa: ARG002
86+
def leave_ClassDef(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.ClassDef:
8787
self.scope_depth -= 1
8888
return updated_node
8989

90-
def leave_Module(self, original_node: cst.Module, updated_node: cst.Module) -> cst.Module: # noqa: ARG002
90+
def leave_Module(self, original_node: cst.Module, updated_node: cst.Module) -> cst.Module:
9191
# Add any new functions that weren't in the original file
9292
new_statements = list(updated_node.body)
9393

@@ -370,7 +370,7 @@ def __init__(self, global_statements: list[cst.SimpleStatementLine]) -> None:
370370
super().__init__()
371371
self.global_statements = global_statements
372372

373-
def leave_Module(self, original_node: cst.Module, updated_node: cst.Module) -> cst.Module: # noqa: ARG002
373+
def leave_Module(self, original_node: cst.Module, updated_node: cst.Module) -> cst.Module:
374374
if not self.global_statements:
375375
return updated_node
376376

@@ -1553,10 +1553,7 @@ def is_numerical_code(code_string: str, function_name: str | None = None) -> boo
15531553

15541554
# If numba is not installed and all modules used require numba for optimization,
15551555
# return False since we can't optimize this code
1556-
if not has_numba and modules_used.issubset(NUMBA_REQUIRED_MODULES):
1557-
return False
1558-
1559-
return True
1556+
return not (not has_numba and modules_used.issubset(NUMBA_REQUIRED_MODULES))
15601557

15611558

15621559
def get_opt_review_metrics(

codeflash/code_utils/instrument_existing_tests.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -690,15 +690,14 @@ def detect_frameworks_from_code(code: str) -> dict[str, str]:
690690
frameworks["tensorflow"] = alias.asname if alias.asname else module_name
691691
elif module_name == "jax":
692692
frameworks["jax"] = alias.asname if alias.asname else module_name
693-
elif isinstance(node, ast.ImportFrom):
694-
if node.module:
695-
module_name = node.module.split(".")[0]
696-
if module_name == "torch" and "torch" not in frameworks:
697-
frameworks["torch"] = module_name
698-
elif module_name == "tensorflow" and "tensorflow" not in frameworks:
699-
frameworks["tensorflow"] = module_name
700-
elif module_name == "jax" and "jax" not in frameworks:
701-
frameworks["jax"] = module_name
693+
elif isinstance(node, ast.ImportFrom) and node.module:
694+
module_name = node.module.split(".")[0]
695+
if module_name == "torch" and "torch" not in frameworks:
696+
frameworks["torch"] = module_name
697+
elif module_name == "tensorflow" and "tensorflow" not in frameworks:
698+
frameworks["tensorflow"] = module_name
699+
elif module_name == "jax" and "jax" not in frameworks:
700+
frameworks["jax"] = module_name
702701

703702
return frameworks
704703

codeflash/main.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,21 @@ def main() -> None:
3030
if args.config_file and Path.exists(args.config_file):
3131
pyproject_config, _ = parse_config_file(args.config_file)
3232
disable_telemetry = pyproject_config.get("disable_telemetry", False)
33-
init_sentry(not disable_telemetry, exclude_errors=True)
34-
posthog_cf.initialize_posthog(not disable_telemetry)
33+
init_sentry(enabled=not disable_telemetry, exclude_errors=True)
34+
posthog_cf.initialize_posthog(enabled=not disable_telemetry)
3535
args.func()
3636
elif args.verify_setup:
3737
args = process_pyproject_config(args)
38-
init_sentry(not args.disable_telemetry, exclude_errors=True)
39-
posthog_cf.initialize_posthog(not args.disable_telemetry)
38+
init_sentry(enabled=not args.disable_telemetry, exclude_errors=True)
39+
posthog_cf.initialize_posthog(enabled=not args.disable_telemetry)
4040
ask_run_end_to_end_test(args)
4141
else:
4242
args = process_pyproject_config(args)
4343
if not env_utils.check_formatter_installed(args.formatter_cmds):
4444
return
4545
args.previous_checkpoint_functions = ask_should_use_checkpoint_get_functions(args)
46-
init_sentry(not args.disable_telemetry, exclude_errors=True)
47-
posthog_cf.initialize_posthog(not args.disable_telemetry)
46+
init_sentry(enabled=not args.disable_telemetry, exclude_errors=True)
47+
posthog_cf.initialize_posthog(enabled=not args.disable_telemetry)
4848

4949
from codeflash.optimization import optimizer
5050

codeflash/optimization/function_optimizer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2486,8 +2486,6 @@ def run_and_parse_tests(
24862486
pytest_cmd=self.test_cfg.pytest_cmd,
24872487
pytest_timeout=INDIVIDUAL_TESTCASE_TIMEOUT,
24882488
pytest_target_runtime_seconds=testing_time,
2489-
pytest_min_loops=1,
2490-
pytest_max_loops=1,
24912489
test_framework=self.test_cfg.test_framework,
24922490
)
24932491
elif testing_type == TestingMode.PERFORMANCE:

codeflash/telemetry/posthog_cf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
_posthog = None
1313

1414

15-
def initialize_posthog(enabled: bool = True) -> None:
15+
def initialize_posthog(*, enabled: bool = True) -> None:
1616
"""Enable or disable PostHog.
1717
1818
:param enabled: Whether to enable PostHog.

codeflash/telemetry/sentry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from sentry_sdk.integrations.logging import LoggingIntegration
55

66

7-
def init_sentry(enabled: bool = False, exclude_errors: bool = False) -> None:
7+
def init_sentry(*, enabled: bool = False, exclude_errors: bool = False) -> None:
88
if enabled:
99
sentry_logging = LoggingIntegration(
1010
level=logging.INFO, # Capture info and above as breadcrumbs

codeflash/tracer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ def main(args: Namespace | None = None) -> ArgumentParser:
227227

228228
args = process_pyproject_config(args)
229229
args.previous_checkpoint_functions = None
230-
init_sentry(not args.disable_telemetry, exclude_errors=True)
231-
posthog_cf.initialize_posthog(not args.disable_telemetry)
230+
init_sentry(enabled=not args.disable_telemetry, exclude_errors=True)
231+
posthog_cf.initialize_posthog(enabled=not args.disable_telemetry)
232232

233233
from codeflash.optimization import optimizer
234234

codeflash/tracing/tracing_new_process.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def __init__(
7676
config: dict,
7777
result_pickle_file_path: Path,
7878
functions: list[str] | None = None,
79+
*,
7980
disable: bool = False,
8081
project_root: Path | None = None,
8182
max_function_count: int = 256,

0 commit comments

Comments
 (0)