File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
src/Microsoft.ML.AutoML/AutoMLExperiment
test/Microsoft.ML.AutoML.Tests Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -252,11 +252,16 @@ public async Task<TrialResult> RunAsync(CancellationToken ct = default)
252252 monitor ? . ReportRunningTrial ( trialSettings ) ;
253253 var stopTrialManager = new CancellationTokenStopTrainingManager ( trialCancellationTokenSource . Token , null ) ;
254254 aggregateTrainingStopManager . AddTrainingStopManager ( stopTrialManager ) ;
255+ void handler ( object o , EventArgs e )
256+ {
257+ trialCancellationTokenSource . Cancel ( ) ;
258+ }
255259 try
256260 {
257261 using ( var performanceMonitor = serviceProvider . GetService < IPerformanceMonitor > ( ) )
258262 using ( var runner = serviceProvider . GetRequiredService < ITrialRunner > ( ) )
259263 {
264+ aggregateTrainingStopManager . OnStopTraining += handler ;
260265 performanceMonitor . PerformanceMetricsUpdated += ( o , metrics ) =>
261266 {
262267 performanceMonitor . OnPerformanceMetricsUpdatedHandler ( trialSettings , metrics , trialCancellationTokenSource ) ;
@@ -329,7 +334,7 @@ Abandoning Trial {trialSettings.TrialId} and continue training.
329334 }
330335 finally
331336 {
332- aggregateTrainingStopManager . RemoveTrainingStopManagerIfExist ( stopTrialManager ) ;
337+ aggregateTrainingStopManager . OnStopTraining -= handler ;
333338 }
334339 }
335340
Original file line number Diff line number Diff line change @@ -39,16 +39,18 @@ public async Task AutoMLExperiment_throw_timeout_exception_when_ct_is_canceled_a
3939 {
4040 var channel = serviceProvider . GetService < IChannel > ( ) ;
4141 var settings = serviceProvider . GetService < AutoMLExperiment . AutoMLExperimentSettings > ( ) ;
42- return new DummyTrialRunner ( settings , 5 , channel ) ;
42+ return new DummyTrialRunner ( settings , 50 , channel ) ;
4343 } )
4444 . SetTuner < RandomSearchTuner > ( ) ;
4545
4646 var cts = new CancellationTokenSource ( ) ;
4747
4848 context . Log += ( o , e ) =>
4949 {
50+ this . Output . WriteLine ( e . RawMessage ) ;
5051 if ( e . RawMessage . Contains ( "Update Running Trial" ) )
5152 {
53+ this . Output . WriteLine ( e . RawMessage ) ;
5254 cts . Cancel ( ) ;
5355 }
5456 } ;
You can’t perform that action at this time.
0 commit comments