diff options
author | Arne Juul <arnej@yahooinc.com> | 2022-12-12 12:19:54 +0000 |
---|---|---|
committer | Arne Juul <arnej@yahooinc.com> | 2022-12-12 13:19:07 +0000 |
commit | d6e2c1f4392a790480de48798a8c16a016bbc216 (patch) | |
tree | b6f48ff05e0f9aae0d939fe84e87948fd5240730 /model-integration/src/main/java | |
parent | 7963cdb18d24626efaa187a0956f495f2a430649 (diff) |
trying to make an OnnxEvaluator with empty path would fail
Diffstat (limited to 'model-integration/src/main/java')
-rw-r--r-- | model-integration/src/main/java/ai/vespa/modelintegration/evaluator/OnnxEvaluator.java | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/model-integration/src/main/java/ai/vespa/modelintegration/evaluator/OnnxEvaluator.java b/model-integration/src/main/java/ai/vespa/modelintegration/evaluator/OnnxEvaluator.java index bdcceddb04f..125707c9aaa 100644 --- a/model-integration/src/main/java/ai/vespa/modelintegration/evaluator/OnnxEvaluator.java +++ b/model-integration/src/main/java/ai/vespa/modelintegration/evaluator/OnnxEvaluator.java @@ -37,6 +37,9 @@ public class OnnxEvaluator { environment = OrtEnvironment.getEnvironment(); session = environment.createSession(modelPath, options.getOptions()); } catch (OrtException e) { + if (e.getCode() == OrtException.OrtErrorCode.ORT_NO_SUCHFILE) { + throw new IllegalArgumentException("No such file: "+modelPath); + } throw new RuntimeException("ONNX Runtime exception", e); } } @@ -101,6 +104,11 @@ public class OnnxEvaluator { try { new OnnxEvaluator(modelPath); return true; + } catch (IllegalArgumentException e) { + if (e.getMessage().equals("No such file: ")) { + return true; + } + return false; } catch (UnsatisfiedLinkError | RuntimeException | NoClassDefFoundError e) { return false; } |