Skip to content

Commit 889ca52

Browse files
committed
remove TestsCache usage
1 parent ca8a77d commit 889ca52

File tree

3 files changed

+3
-33
lines changed

3 files changed

+3
-33
lines changed

codeflash/discovery/discover_unit_tests.py

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def filter_test_files_by_imports(
297297
else:
298298
logger.debug(f"Skipping {test_file} - no relevant imports found")
299299

300-
logger.info(f"Import filter: Processing {len(filtered_map)}/{len(file_to_test_map)} test files")
300+
logger.debug(f"Import filter: Processing {len(filtered_map)}/{len(file_to_test_map)} test files")
301301
return filtered_map, import_results
302302

303303

@@ -491,27 +491,12 @@ def process_test_files(
491491

492492
function_to_test_map = defaultdict(set)
493493
jedi_project = jedi.Project(path=project_root_path)
494-
tests_cache = TestsCache()
495494

496495
with test_files_progress_bar(total=len(file_to_test_map), description="Processing test files") as (
497496
progress,
498497
task_id,
499498
):
500499
for test_file, functions in file_to_test_map.items():
501-
file_hash = TestsCache.compute_file_hash(test_file)
502-
cached_tests = tests_cache.get_tests_for_file(str(test_file), file_hash)
503-
if cached_tests:
504-
self_cur = tests_cache.cur
505-
self_cur.execute(
506-
"SELECT qualified_name_with_modules_from_root FROM discovered_tests WHERE file_path = ? AND file_hash = ?",
507-
(str(test_file), file_hash),
508-
)
509-
qualified_names = [row[0] for row in self_cur.fetchall()]
510-
for cached, qualified_name in zip(cached_tests, qualified_names):
511-
function_to_test_map[qualified_name].add(cached)
512-
progress.advance(task_id)
513-
continue
514-
515500
try:
516501
script = jedi.Script(path=test_file, project=jedi_project)
517502
test_functions = set()
@@ -636,18 +621,6 @@ def process_test_files(
636621
)
637622
qualified_name_with_modules_from_root = f"{module_name_from_file_path(definition[0].module_path, project_root_path)}.{full_name_without_module_prefix}"
638623

639-
tests_cache.insert_test(
640-
file_path=str(test_file),
641-
file_hash=file_hash,
642-
qualified_name_with_modules_from_root=qualified_name_with_modules_from_root,
643-
function_name=scope,
644-
test_class=scope_test_class,
645-
test_function=scope_test_function,
646-
test_type=test_type,
647-
line_number=name.line,
648-
col_number=name.column,
649-
)
650-
651624
function_to_test_map[qualified_name_with_modules_from_root].add(
652625
FunctionCalledInTest(
653626
tests_in_file=TestsInFile(
@@ -662,5 +635,4 @@ def process_test_files(
662635

663636
progress.advance(task_id)
664637

665-
tests_cache.close()
666638
return {function: list(tests) for function, tests in function_to_test_map.items()}

codeflash/optimization/optimizer.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,7 @@ def run(self) -> None:
162162

163163
console.rule()
164164
start_time = time.time()
165-
function_to_tests: dict[str, list[FunctionCalledInTest]] = discover_unit_tests(
166-
self.test_cfg, file_to_funcs_to_optimize=file_to_funcs_to_optimize
167-
)
165+
function_to_tests = discover_unit_tests(self.test_cfg, file_to_funcs_to_optimize=file_to_funcs_to_optimize)
168166
num_discovered_tests: int = sum([len(value) for value in function_to_tests.values()])
169167
console.rule()
170168
logger.info(

tests/test_static_analysis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import ast
1+
import ast
22
from pathlib import Path
33

44
from codeflash.code_utils.static_analysis import (

0 commit comments

Comments
 (0)