Skip to content

Commit

Permalink
fix: should not return failed code on model already loaded (#913)
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan authored Jul 25, 2024
1 parent 5caef68 commit 2004d9e
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions cortex-js/src/usecases/models/models.usecases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ export class ModelsUsecases {

return engine
.loadModel(model, loadModelSettings)
.catch((e) => {
// Skip model already loaded error
if (e.code === AxiosError.ERR_BAD_REQUEST) return;
else throw e;
})
.then(() => {
this.activeModelStatuses[modelId] = {
model: modelId,
Expand Down Expand Up @@ -226,13 +231,6 @@ export class ModelsUsecases {
metadata: {},
};
this.eventEmitter.emit('model.event', modelEvent);
if (e.code === AxiosError.ERR_BAD_REQUEST) {
loadingModelSpinner.succeed('Model loaded');
return {
message: 'Model already loaded',
modelId,
};
}
loadingModelSpinner.fail('Model loading failed');
await this.telemetryUseCases.createCrashReport(
e,
Expand Down

0 comments on commit 2004d9e

Please sign in to comment.