@@ -35,6 +35,8 @@ class Agent {
35
35
predictMemory : PredictMemory = { } ;
36
36
bestActionMemory : [ Action , string ] [ ] = [ ] ;
37
37
inputSize : number = 59 ;
38
+ isReplicating : boolean = false ;
39
+ isSaving : boolean = false ;
38
40
39
41
// For spinner purpose
40
42
spinner : Spinner ;
@@ -165,16 +167,22 @@ class Agent {
165
167
* Save model to model's directory
166
168
*/
167
169
async saveModel ( model : LayersModel ) {
170
+ this . isSaving = true ;
168
171
const modelfolder = < string > this . dataPaths ( "models" , model . name ) ;
169
172
mkdirp . sync ( modelfolder ) ;
170
173
await model . save ( `file://${ modelfolder } ` ) ;
171
174
this . loading ( `Model ${ model . name } saved!` ) ;
175
+ this . isSaving = false ;
172
176
}
173
177
174
178
/**
175
179
* Remove models from list
176
180
*/
177
181
async destroyModel ( model : LayersModel ) {
182
+ if ( this . isReplicating || this . isSaving ) {
183
+ return ;
184
+ }
185
+
178
186
const modelIndex = this . models . findIndex (
179
187
( item ) => item . name === model . name
180
188
) ;
@@ -281,6 +289,7 @@ class Agent {
281
289
* and the quota of modelsNumber was being removed
282
290
*/
283
291
async replicate ( ) {
292
+ this . isReplicating = true ;
284
293
let count = 0 ;
285
294
286
295
for ( let i = 0 ; i < this . modelsNumber ; i ++ ) {
@@ -297,6 +306,7 @@ class Agent {
297
306
}
298
307
299
308
this . loading ( `Replicating models` ) ?. succeed ( ) ;
309
+ this . isReplicating = false ;
300
310
}
301
311
302
312
/**
0 commit comments