@@ -695,39 +695,63 @@ def addSkip(self, test, reason):
695
695
test_report_path = TEST_SAVE_XML + LOG_SUFFIX
696
696
test_report_path = os .path .join (test_report_path , test_filename )
697
697
if test_filename in PYTEST_FILES and not IS_SANDCASTLE :
698
- # exclude linux cuda tests because we run into memory issues when running in parallel
699
- import pytest
700
- os .environ ["NO_COLOR" ] = "1"
701
- os .environ ["USING_PYTEST" ] = "1"
702
- pytest_report_path = test_report_path .replace ('python-unittest' , 'python-pytest' )
703
- os .makedirs (pytest_report_path , exist_ok = True )
704
- # part of our xml parsing looks for grandparent folder names
705
- pytest_report_path_parallel = os .path .join (pytest_report_path , f"{ test_filename } -parallel.xml" )
706
- pytest_report_path_serial = os .path .join (pytest_report_path , f"{ test_filename } -serial.xml" )
707
- print (f'Test results will be stored in { pytest_report_path_parallel } ' )
708
- # mac slower on 4 proc than 3
709
- num_procs = 2
710
- exit_code = pytest .main (args = [inspect .getfile (sys ._getframe (1 )), f'-n={ num_procs } ' , '-vv' , '-x' , '-m=not serial' ,
711
- '--reruns=2' , '-rfEsX' , f'--junit-xml-reruns={ pytest_report_path_parallel } ' ])
712
- sanitize_pytest_xml (f'{ pytest_report_path_parallel } ' )
713
- # exitcode of 5 means no tests were found, which happens for some test configs
714
- if exit_code != 0 and exit_code != 5 :
715
- del os .environ ["USING_PYTEST" ]
716
- exit (exit_code )
717
-
718
- exit_code = pytest .main (args = [inspect .getfile (sys ._getframe (1 )), '-vv' , '-x' , '-m=serial' ,
719
- '--reruns=2' , '-rfEsX' , f'--junit-xml-reruns={ pytest_report_path_serial } ' ])
720
- sanitize_pytest_xml (f'{ pytest_report_path_serial } ' )
698
+ if os .environ ["SHARD_NUMBER" ] == "1" :
699
+ os .makedirs (test_report_path , exist_ok = True )
700
+ verbose = '--verbose' in argv or '-v' in argv
701
+ unittest .main (argv = argv , testRunner = xmlrunner .XMLTestRunner (
702
+ output = test_report_path ,
703
+ verbosity = 2 if verbose else 1 ,
704
+ resultclass = XMLTestResultVerbose ))
705
+ if os .environ ["SHARD_NUMBER" ] == "2" :
706
+ import pytest
707
+ os .environ ["NO_COLOR" ] = "1"
708
+ os .environ ["USING_PYTEST" ] = "1"
709
+ pytest_report_path = test_report_path .replace ('python-unittest' , 'python-pytest' )
710
+ os .makedirs (pytest_report_path , exist_ok = True )
711
+ # part of our xml parsing looks for grandparent folder names
712
+ pytest_report_path_parallel = os .path .join (pytest_report_path , f"{ test_filename } -parallel.xml" )
713
+ pytest_report_path_serial = os .path .join (pytest_report_path , f"{ test_filename } -serial.xml" )
714
+ print (f'Test results will be stored in { pytest_report_path_parallel } ' )
715
+ # mac slower on 4 proc than 3
716
+ num_procs = 2
717
+ exit_code = pytest .main (args = [inspect .getfile (sys ._getframe (1 )), f'-n={ num_procs } ' , '-vv' , '-x' , '-m=not serial' ,
718
+ '--reruns=2' , '-rfEsX' , f'--junit-xml-reruns={ pytest_report_path_parallel } ' ])
719
+ sanitize_pytest_xml (f'{ pytest_report_path_parallel } ' )
720
+ # exitcode of 5 means no tests were found, which happens for some test configs
721
+ if exit_code != 0 and exit_code != 5 :
722
+ del os .environ ["USING_PYTEST" ]
723
+ exit (exit_code )
724
+
725
+ exit_code = pytest .main (args = [inspect .getfile (sys ._getframe (1 )), '-vv' , '-x' , '-m=serial' ,
726
+ '--reruns=2' , '-rfEsX' , f'--junit-xml-reruns={ pytest_report_path_serial } ' ])
727
+ sanitize_pytest_xml (f'{ pytest_report_path_serial } ' )
721
728
722
- del os .environ ["USING_PYTEST" ]
723
- os .makedirs (test_report_path , exist_ok = True )
724
- verbose = '--verbose' in argv or '-v' in argv
725
- unittest .main (argv = argv , testRunner = xmlrunner .XMLTestRunner (
726
- output = test_report_path ,
727
- verbosity = 2 if verbose else 1 ,
728
- resultclass = XMLTestResultVerbose ))
729
+ del os .environ ["USING_PYTEST" ]
730
+ if os .environ ["SHARD_NUMBER" ] == "3" :
731
+ import pytest
732
+ os .environ ["NO_COLOR" ] = "1"
733
+ os .environ ["USING_PYTEST" ] = "1"
734
+ pytest_report_path = test_report_path .replace ('python-unittest' , 'python-pytest' )
735
+ os .makedirs (pytest_report_path , exist_ok = True )
736
+ # part of our xml parsing looks for grandparent folder names
737
+ pytest_report_path_parallel = os .path .join (pytest_report_path , f"{ test_filename } -parallel.xml" )
738
+ pytest_report_path_serial = os .path .join (pytest_report_path , f"{ test_filename } -serial.xml" )
739
+ print (f'Test results will be stored in { pytest_report_path_parallel } ' )
740
+ # mac slower on 4 proc than 3
741
+ num_procs = 3
742
+ exit_code = pytest .main (args = [inspect .getfile (sys ._getframe (1 )), f'-n={ num_procs } ' , '-vv' , '-x' , '-m=not serial' ,
743
+ '--reruns=2' , '-rfEsX' , f'--junit-xml-reruns={ pytest_report_path_parallel } ' ])
744
+ sanitize_pytest_xml (f'{ pytest_report_path_parallel } ' )
745
+ # exitcode of 5 means no tests were found, which happens for some test configs
746
+ if exit_code != 0 and exit_code != 5 :
747
+ del os .environ ["USING_PYTEST" ]
748
+ exit (exit_code )
749
+
750
+ exit_code = pytest .main (args = [inspect .getfile (sys ._getframe (1 )), '-vv' , '-x' , '-m=serial' ,
751
+ '--reruns=2' , '-rfEsX' , f'--junit-xml-reruns={ pytest_report_path_serial } ' ])
752
+ sanitize_pytest_xml (f'{ pytest_report_path_serial } ' )
729
753
730
- exit ( 0 if exit_code == 5 else exit_code )
754
+ del os . environ [ "USING_PYTEST" ]
731
755
else :
732
756
os .makedirs (test_report_path , exist_ok = True )
733
757
verbose = '--verbose' in argv or '-v' in argv
@@ -858,8 +882,8 @@ def _check_module_exists(name: str) -> bool:
858
882
859
883
if (
860
884
os .getenv ("USING_PYTEST" ) == "1"
861
- and "cuda" in os .environ ["BUILD_ENVIRONMENT" ]
862
885
and "linux" in os .environ ["BUILD_ENVIRONMENT" ]
886
+ and TEST_CUDA
863
887
):
864
888
torch .cuda .set_per_process_memory_fraction (0.35 )
865
889
0 commit comments