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,11 +1,10 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import functools
|
||||
import random
|
||||
import sys
|
||||
import unittest
|
||||
from collections import defaultdict
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Tuple
|
||||
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[2]
|
||||
@ -19,12 +18,12 @@ except ModuleNotFoundError:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def gen_class_times(test_times: dict[str, float]) -> dict[str, dict[str, float]]:
|
||||
def gen_class_times(test_times: Dict[str, float]) -> Dict[str, Dict[str, float]]:
|
||||
return {k: {"class1": v} for k, v in test_times.items()}
|
||||
|
||||
|
||||
class TestCalculateShards(unittest.TestCase):
|
||||
tests: list[TestRun] = [
|
||||
tests: List[TestRun] = [
|
||||
TestRun("super_long_test"),
|
||||
TestRun("long_test1"),
|
||||
TestRun("long_test2"),
|
||||
@ -38,7 +37,7 @@ class TestCalculateShards(unittest.TestCase):
|
||||
TestRun("short_test5"),
|
||||
]
|
||||
|
||||
test_times: dict[str, float] = {
|
||||
test_times: Dict[str, float] = {
|
||||
"super_long_test": 55,
|
||||
"long_test1": 22,
|
||||
"long_test2": 18,
|
||||
@ -52,7 +51,7 @@ class TestCalculateShards(unittest.TestCase):
|
||||
"short_test5": 0.01,
|
||||
}
|
||||
|
||||
test_class_times: dict[str, dict[str, float]] = {
|
||||
test_class_times: Dict[str, Dict[str, float]] = {
|
||||
"super_long_test": {"class1": 55},
|
||||
"long_test1": {"class1": 1, "class2": 21},
|
||||
"long_test2": {"class1": 10, "class2": 8},
|
||||
@ -68,8 +67,8 @@ class TestCalculateShards(unittest.TestCase):
|
||||
|
||||
def assert_shards_equal(
|
||||
self,
|
||||
expected_shards: list[tuple[float, list[ShardedTest]]],
|
||||
actual_shards: list[tuple[float, list[ShardedTest]]],
|
||||
expected_shards: List[Tuple[float, List[ShardedTest]]],
|
||||
actual_shards: List[Tuple[float, List[ShardedTest]]],
|
||||
) -> None:
|
||||
for expected, actual in zip(expected_shards, actual_shards):
|
||||
self.assertAlmostEqual(expected[0], actual[0])
|
||||
@ -365,7 +364,7 @@ class TestCalculateShards(unittest.TestCase):
|
||||
)
|
||||
|
||||
def test_split_shards(self) -> None:
|
||||
test_times: dict[str, float] = {"test1": THRESHOLD, "test2": THRESHOLD}
|
||||
test_times: Dict[str, float] = {"test1": THRESHOLD, "test2": THRESHOLD}
|
||||
expected_shards = [
|
||||
(600.0, [ShardedTest(test="test1", shard=1, num_shards=1, time=THRESHOLD)]),
|
||||
(600.0, [ShardedTest(test="test2", shard=1, num_shards=1, time=THRESHOLD)]),
|
||||
@ -440,7 +439,7 @@ class TestCalculateShards(unittest.TestCase):
|
||||
tests = [TestRun(x) for x in test_names]
|
||||
serial = [x for x in test_names if random.randint(0, 1) == 0]
|
||||
has_times = [x for x in test_names if random.randint(0, 1) == 0]
|
||||
random_times: dict[str, float] = {
|
||||
random_times: Dict[str, float] = {
|
||||
i: random.randint(0, THRESHOLD * 10) for i in has_times
|
||||
}
|
||||
sort_by_time = random.randint(0, 1) == 0
|
||||
@ -458,7 +457,7 @@ class TestCalculateShards(unittest.TestCase):
|
||||
max_diff = max(times) - min(times)
|
||||
self.assertTrue(max_diff <= THRESHOLD + (num_tests - len(has_times)) * 60)
|
||||
|
||||
all_sharded_tests: dict[str, list[ShardedTest]] = defaultdict(list)
|
||||
all_sharded_tests: Dict[str, List[ShardedTest]] = defaultdict(list)
|
||||
for _, sharded_tests in shards:
|
||||
for sharded_test in sharded_tests:
|
||||
all_sharded_tests[sharded_test.name].append(sharded_test)
|
||||
|
Reference in New Issue
Block a user