@@ -154,18 +154,52 @@ public void TestClassifiers_Success()
154154 }
155155 catch ( Exception e )
156156 {
157- Assert . Fail ( e . Message ) ;
157+ Console . WriteLine ( "Failed to get classifier..." ) ;
158158 }
159159 autoEvent . WaitOne ( ) ;
160160
161161 Classifier updateClassifierResult = null ;
162- using ( FileStream positiveExamplesStream = File . OpenRead ( _localTurtlePositiveExamplesFilePath ) )
162+ var retrainRetries = 0 ;
163+ try
163164 {
164- Dictionary < string , Stream > positiveExamples = new Dictionary < string , Stream > ( ) ;
165- positiveExamples . Add ( _turtleClassname , positiveExamplesStream ) ;
166- UpdateClassifier updateClassifier = new UpdateClassifier ( createdClassifierId , positiveExamples ) ;
167- updateClassifierResult = _service . UpdateClassifier ( updateClassifier ) ;
165+ using ( FileStream positiveExamplesStream = File . OpenRead ( _localTurtlePositiveExamplesFilePath ) )
166+ {
167+ Dictionary < string , Stream > positiveExamples = new Dictionary < string , Stream > ( ) ;
168+ positiveExamples . Add ( _turtleClassname , positiveExamplesStream ) ;
169+ UpdateClassifier updateClassifier = new UpdateClassifier ( createdClassifierId , positiveExamples ) ;
170+ updateClassifierResult = _service . UpdateClassifier ( updateClassifier ) ;
171+ }
168172 }
173+ catch ( Exception e )
174+ {
175+ retrainRetries ++ ;
176+
177+ if ( retrainRetries < 3 )
178+ {
179+ Console . WriteLine ( "Retraining failed. Retrying..." ) ;
180+ using ( FileStream positiveExamplesStream = File . OpenRead ( _localTurtlePositiveExamplesFilePath ) )
181+ {
182+ Dictionary < string , Stream > positiveExamples = new Dictionary < string , Stream > ( ) ;
183+ positiveExamples . Add ( _turtleClassname , positiveExamplesStream ) ;
184+ UpdateClassifier updateClassifier = new UpdateClassifier ( createdClassifierId , positiveExamples ) ;
185+ updateClassifierResult = _service . UpdateClassifier ( updateClassifier ) ;
186+ }
187+ }
188+ else
189+ {
190+ Console . WriteLine ( "Retraining failed. Out of retries..." ) ;
191+ }
192+ }
193+
194+ try
195+ {
196+ IsClassifierReady ( createdClassifierId ) ;
197+ }
198+ catch ( Exception e )
199+ {
200+ Console . WriteLine ( "Failed to get classifier..." ) ;
201+ }
202+ autoEvent . WaitOne ( ) ;
169203
170204 var deleteClassifierResult = DeleteClassifier ( createdClassifierId ) ;
171205
@@ -200,7 +234,7 @@ private void IsClassifierReady(string classifierId)
200234 {
201235 Task . Factory . StartNew ( ( ) =>
202236 {
203- System . Threading . Thread . Sleep ( 1000 ) ;
237+ System . Threading . Thread . Sleep ( 10000 ) ;
204238 try
205239 {
206240 IsClassifierReady ( classifierId ) ;
0 commit comments