12
12
using Microsoft . ML . TestFramework ;
13
13
using Microsoft . ML . TestFramework . Attributes ;
14
14
using Microsoft . ML . TestFrameworkCommon ;
15
+ using Microsoft . ML . TestFrameworkCommon . Attributes ;
15
16
using Xunit ;
16
17
using Xunit . Abstractions ;
17
18
using static Microsoft . ML . DataOperationsCatalog ;
@@ -375,8 +376,6 @@ public void AutoFitWithPresplittedData()
375
376
}
376
377
377
378
[ LightGBMFact ]
378
- //Skipping test temporarily. This test will be re-enabled once the cause of failures has been determined
379
- [ Trait ( "Category" , "SkipInCI" ) ]
380
379
public void AutoFitMaxExperimentTimeTest ( )
381
380
{
382
381
// A single binary classification experiment takes less than 5 seconds.
@@ -398,8 +397,30 @@ public void AutoFitMaxExperimentTimeTest()
398
397
// can increase the run time of unit tests, and may not produce multiple runs.
399
398
if ( experiment . RunDetails . Select ( r => r . Exception == null ) . Count ( ) > 1 && experiment . RunDetails . Last ( ) . Exception != null )
400
399
{
401
- Assert . True ( experiment . RunDetails . Last ( ) . Exception . Message . Contains ( "Operation was canceled" ) ,
402
- "Training process was not successfully canceled after maximum experiment time was reached." ) ;
400
+ var expectedExceptionMessage = "Operation was canceled" ;
401
+ var lastException = experiment . RunDetails . Last ( ) . Exception ;
402
+ var containsMessage = lastException . Message . Contains ( expectedExceptionMessage ) ;
403
+
404
+ if ( lastException is AggregateException lastAggregateException )
405
+ {
406
+ // Sometimes multiple threads might throw the same "Operation was cancelled"
407
+ // exception and all of them are grouped inside an AggregateException
408
+ // Must check that all exceptions are the expected one.
409
+ containsMessage = true ;
410
+ foreach ( var ex in lastAggregateException . Flatten ( ) . InnerExceptions )
411
+ {
412
+ if ( ! ex . Message . Contains ( expectedExceptionMessage ) )
413
+ {
414
+ containsMessage = false ;
415
+ }
416
+ }
417
+ }
418
+
419
+
420
+ Assert . True ( containsMessage ,
421
+ $ "Did not obtain '{ expectedExceptionMessage } ' error." +
422
+ $ "Obtained unexpected error of type { lastException . GetType ( ) } with message: { lastException . Message } ") ;
423
+
403
424
// Ensure that the best found model can still run after maximum experiment time was reached.
404
425
IDataView predictions = experiment . BestRun . Model . Transform ( trainData ) ;
405
426
}
0 commit comments