Skip to content

Commit 40d2fe1

Browse files
Rong Rong (AI Infra)facebook-github-bot
Rong Rong (AI Infra)
authored andcommitted
correct filename issue for test_cpp_extensions_aot (pytorch#60604)
Summary: Using file copy to make actual ninja vs. no_ninja suffixed python test files. This is to trick xmlrunner to report test cases in the correct folder. Pull Request resolved: pytorch#60604 Test Plan: - CI reports correctly into the corresponding folders - If download the test statistics, calculate shards now doesn't need custom logic to handle `test_cpp_extensions_aot` CI result shown it is working properly: https://github.com/pytorch/pytorch/pull/60604/checks?check_run_id=2900038654 vs https://github.com/pytorch/pytorch/pull/60604/checks?check_run_id=2900038673 Reviewed By: albanD Differential Revision: D29349562 Pulled By: walterddr fbshipit-source-id: e86e6bc0db288a2a57bea3c5f8edf03be1773944
1 parent 9cab894 commit 40d2fe1

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

test/run_test.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,8 @@ def calculate_job_times(reports: List["Report"]) -> Dict[str, float]:
436436
new_avg = (curr_avg * curr_count + test_file['total_seconds']) / new_count
437437
jobs_to_times[name] = (new_avg, new_count)
438438

439+
# This is no longer needed after https://github.com/pytorch/pytorch/pull/60604,
440+
# TODO remove this once viable/strict move pass the merged commit.
439441
# if there's 'test_cpp_extensions_aot' entry in jobs_to_times, add 'test_cpp_extensions_aot_ninja'
440442
# and 'test_cpp_extensions_aot_no_ninja' duplicate entries to ease future computation since
441443
# test_cpp_extensions_aot_no_ninja and test_cpp_extensions_aot_ninja are Python test jobs that
@@ -602,7 +604,7 @@ def test_cuda_primary_ctx(test_module, test_directory, options):
602604
return run_test(test_module, test_directory, options, extra_unittest_args=['--subprocess'])
603605

604606

605-
def _test_cpp_extensions_aot(test_module, test_directory, options, use_ninja):
607+
def _test_cpp_extensions_aot(test_directory, options, use_ninja):
606608
if use_ninja:
607609
try:
608610
cpp_extension.verify_ninja_availability()
@@ -632,6 +634,9 @@ def _test_cpp_extensions_aot(test_module, test_directory, options, use_ninja):
632634

633635
# "install" the test modules and run tests
634636
python_path = os.environ.get('PYTHONPATH', '')
637+
from shutil import copyfile
638+
test_module = 'test_cpp_extensions_aot' + ('_ninja' if use_ninja else '_no_ninja')
639+
copyfile(test_directory + '/test_cpp_extensions_aot.py', test_directory + '/' + test_module + '.py')
635640
try:
636641
cpp_extensions = os.path.join(test_directory, 'cpp_extensions')
637642
install_directory = ''
@@ -646,16 +651,16 @@ def _test_cpp_extensions_aot(test_module, test_directory, options, use_ninja):
646651
return run_test(test_module, test_directory, options)
647652
finally:
648653
os.environ['PYTHONPATH'] = python_path
654+
if os.path.exists(test_directory + '/' + test_module + '.py'):
655+
os.remove(test_directory + '/' + test_module + '.py')
649656

650657

651658
def test_cpp_extensions_aot_ninja(test_module, test_directory, options):
652-
return _test_cpp_extensions_aot('test_cpp_extensions_aot', test_directory,
653-
options, use_ninja=True)
659+
return _test_cpp_extensions_aot(test_directory, options, use_ninja=True)
654660

655661

656662
def test_cpp_extensions_aot_no_ninja(test_module, test_directory, options):
657-
return _test_cpp_extensions_aot('test_cpp_extensions_aot',
658-
test_directory, options, use_ninja=False)
663+
return _test_cpp_extensions_aot(test_directory, options, use_ninja=False)
659664

660665

661666
def test_distributed(test_module, test_directory, options):

0 commit comments

Comments
 (0)