mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Revert "[BE][Easy] enable postponed annotations in tools
(#129375)"
This reverts commit 59eb2897f1745f513edb6c63065ffad481c4c8d0. Reverted https://github.com/pytorch/pytorch/pull/129375 on behalf of https://github.com/huydhn due to Sorry for reverting your change but I need to revert to cleanly revert https://github.com/pytorch/pytorch/pull/129374, please do a rebase and reland this ([comment](https://github.com/pytorch/pytorch/pull/129375#issuecomment-2197800541))
This commit is contained in:
@ -1,9 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import time
|
||||
from typing import Any, TYPE_CHECKING
|
||||
from typing import Any, Dict, List, Set, Tuple
|
||||
|
||||
from ..util.setting import (
|
||||
CompilerType,
|
||||
@ -18,6 +16,7 @@ from ..util.utils import (
|
||||
print_time,
|
||||
related_to_test_list,
|
||||
)
|
||||
from .parser.coverage_record import CoverageRecord
|
||||
from .parser.gcov_coverage_parser import GcovCoverageParser
|
||||
from .parser.llvm_coverage_parser import LlvmCoverageParser
|
||||
from .print_report import (
|
||||
@ -27,20 +26,16 @@ from .print_report import (
|
||||
)
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .parser.coverage_record import CoverageRecord
|
||||
|
||||
|
||||
# coverage_records: Dict[str, LineInfo] = {}
|
||||
covered_lines: dict[str, set[int]] = {}
|
||||
uncovered_lines: dict[str, set[int]] = {}
|
||||
covered_lines: Dict[str, Set[int]] = {}
|
||||
uncovered_lines: Dict[str, Set[int]] = {}
|
||||
tests_type: TestStatusType = {"success": set(), "partial": set(), "fail": set()}
|
||||
|
||||
|
||||
def transform_file_name(
|
||||
file_path: str, interested_folders: list[str], platform: TestPlatform
|
||||
file_path: str, interested_folders: List[str], platform: TestPlatform
|
||||
) -> str:
|
||||
remove_patterns: set[str] = {".DEFAULT.cpp", ".AVX.cpp", ".AVX2.cpp"}
|
||||
remove_patterns: Set[str] = {".DEFAULT.cpp", ".AVX.cpp", ".AVX2.cpp"}
|
||||
for pattern in remove_patterns:
|
||||
file_path = file_path.replace(pattern, "")
|
||||
# if user has specified interested folder
|
||||
@ -59,7 +54,7 @@ def transform_file_name(
|
||||
|
||||
|
||||
def is_intrested_file(
|
||||
file_path: str, interested_folders: list[str], platform: TestPlatform
|
||||
file_path: str, interested_folders: List[str], platform: TestPlatform
|
||||
) -> bool:
|
||||
ignored_patterns = ["cuda", "aten/gen_aten", "aten/aten_", "build/"]
|
||||
if any(pattern in file_path for pattern in ignored_patterns):
|
||||
@ -82,7 +77,7 @@ def is_intrested_file(
|
||||
return True
|
||||
|
||||
|
||||
def get_json_obj(json_file: str) -> tuple[Any, int]:
|
||||
def get_json_obj(json_file: str) -> Tuple[Any, int]:
|
||||
"""
|
||||
Sometimes at the start of file llvm/gcov will complains "fail to find coverage data",
|
||||
then we need to skip these lines
|
||||
@ -107,7 +102,7 @@ def get_json_obj(json_file: str) -> tuple[Any, int]:
|
||||
return None, 2
|
||||
|
||||
|
||||
def parse_json(json_file: str, platform: TestPlatform) -> list[CoverageRecord]:
|
||||
def parse_json(json_file: str, platform: TestPlatform) -> List[CoverageRecord]:
|
||||
print("start parse:", json_file)
|
||||
json_obj, read_status = get_json_obj(json_file)
|
||||
if read_status == 0:
|
||||
@ -122,7 +117,7 @@ def parse_json(json_file: str, platform: TestPlatform) -> list[CoverageRecord]:
|
||||
|
||||
cov_type = detect_compiler_type(platform)
|
||||
|
||||
coverage_records: list[CoverageRecord] = []
|
||||
coverage_records: List[CoverageRecord] = []
|
||||
if cov_type == CompilerType.CLANG:
|
||||
coverage_records = LlvmCoverageParser(json_obj).parse("fbcode")
|
||||
# print(coverage_records)
|
||||
@ -133,7 +128,7 @@ def parse_json(json_file: str, platform: TestPlatform) -> list[CoverageRecord]:
|
||||
|
||||
|
||||
def parse_jsons(
|
||||
test_list: TestList, interested_folders: list[str], platform: TestPlatform
|
||||
test_list: TestList, interested_folders: List[str], platform: TestPlatform
|
||||
) -> None:
|
||||
g = os.walk(JSON_FOLDER_BASE_DIR)
|
||||
|
||||
@ -157,8 +152,8 @@ def parse_jsons(
|
||||
|
||||
|
||||
def update_coverage(
|
||||
coverage_records: list[CoverageRecord],
|
||||
interested_folders: list[str],
|
||||
coverage_records: List[CoverageRecord],
|
||||
interested_folders: List[str],
|
||||
platform: TestPlatform,
|
||||
) -> None:
|
||||
for item in coverage_records:
|
||||
@ -192,8 +187,8 @@ def update_set() -> None:
|
||||
|
||||
def summarize_jsons(
|
||||
test_list: TestList,
|
||||
interested_folders: list[str],
|
||||
coverage_only: list[str],
|
||||
interested_folders: List[str],
|
||||
coverage_only: List[str],
|
||||
platform: TestPlatform,
|
||||
) -> None:
|
||||
start_time = time.time()
|
||||
|
Reference in New Issue
Block a user