Skip to content

Commit

Permalink
Merge pull request #26919 from vespa-engine/bratseth/ignore-path
Browse files Browse the repository at this point in the history
Ignore path on hosted when model-id is set
  • Loading branch information
bratseth authored Apr 30, 2023
2 parents 7edb75e + 00b862b commit 8806fa5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,15 @@ public static void resolveModelIds(Element component, boolean hosted) {
/** Expands a model config value into regular config values. */
private static void transformModelValue(Element value, boolean hosted) {
if ( ! value.hasAttribute("model-id")) return;
if (hosted)

if (hosted) {
value.setAttribute("url", modelIdToUrl(value.getTagName(), value.getAttribute("model-id")));
else if ( ! value.hasAttribute("url") && ! value.hasAttribute("path"))
value.removeAttribute("path");
}
else if ( ! value.hasAttribute("url") && ! value.hasAttribute("path")) {
throw new IllegalArgumentException(value.getTagName() + " is configured with only a 'model-id'. " +
"Add a 'path' or 'url' to deploy this outside Vespa Cloud");
}
}

private static String modelIdToUrl(String valueName, String modelId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void testBundledEmbedder_hosted() throws IOException, SAXException {
String input = "<component id='test' class='" + BUNDLED_EMBEDDER_CLASS + "' bundle='model-integration'>" +
" <config name='" + BUNDLED_EMBEDDER_CONFIG + "'>" +
" <transformerModel model-id='minilm-l6-v2' />" +
" <tokenizerVocab model-id='bert-base-uncased' />" +
" <tokenizerVocab model-id='bert-base-uncased' path='ignored.txt'/>" +
" </config>" +
"</component>";
String component = "<component id='test' class='" + BUNDLED_EMBEDDER_CLASS + "' bundle='model-integration'>" +
Expand Down

0 comments on commit 8806fa5

Please sign in to comment.