diff options
author | Jon Bratseth <bratseth@gmail.com> | 2022-08-24 12:22:36 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2022-08-24 12:22:36 +0200 |
commit | 69c3cfc1828aab9d759126df90667067e88490cb (patch) | |
tree | 6f7a2c7626f6aa92aaa01e6d2f46dec5a6971b1c /config-model | |
parent | 750442815177bf4f1ed6ff375ab5c0160a065090 (diff) |
Test model id lookup
Diffstat (limited to 'config-model')
3 files changed, 23 insertions, 26 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/EmbedderConfigTransformer.java b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/EmbedderConfigTransformer.java index 068ed2ee11f..576399333df 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/EmbedderConfigTransformer.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/EmbedderConfigTransformer.java @@ -74,7 +74,7 @@ public class EmbedderConfigTransformer { addChild(value.getTagName() + "Path", dummyPath, config); } else { - addChild(value.getTagName(), value.getTextContent(), config); + addChild(value.getTagName(), XML.getValue(value), config); } } @@ -97,8 +97,6 @@ public class EmbedderConfigTransformer { private static String modelIdToUrl(String id) { switch (id) { - case "test-model-id": - return "test-model-url"; case "minilm-l6-v2": return "https://data.vespa.oath.cloud/onnx_models/sentence_all_MiniLM_L6_v2.onnx"; case "bert-base-uncased": diff --git a/config-model/src/test/cfg/application/embed/services.xml b/config-model/src/test/cfg/application/embed/services.xml index 9a05337f954..eac6e62860e 100644 --- a/config-model/src/test/cfg/application/embed/services.xml +++ b/config-model/src/test/cfg/application/embed/services.xml @@ -11,7 +11,7 @@ <embedder id="transformer" class="ai.vespa.embedding.BertBaseEmbedder"> <!-- model specifics --> - <transformerModel id="test-model-id" url="test-model-url"/> + <transformerModel id="minilm-l6-v2" url="test-model-url"/> <tokenizerVocab path="files/vocab.txt"/> <!-- tunable parameters: number of threads etc --> diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/EmbedderTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/EmbedderTestCase.java index 27d7470acac..74fd00b2ebd 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/EmbedderTestCase.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/EmbedderTestCase.java @@ -70,9 +70,9 @@ public class EmbedderTestCase { String component = "<component id='test' class='" + PREDEFINED_EMBEDDER_CLASS + "' bundle='model-integration'>" + " <config name='" + PREDEFINED_EMBEDDER_CONFIG + "'>" + " <transformerModelUrl>my-model-url</transformerModelUrl>" + - " <transformerModelPath></transformerModelPath>" + + " <transformerModelPath>services.xml</transformerModelPath>" + " <tokenizerVocabUrl>my-vocab-url</tokenizerVocabUrl>" + - " <tokenizerVocabPath></tokenizerVocabPath>" + + " <tokenizerVocabPath>services.xml</tokenizerVocabPath>" + " </config>" + "</component>"; assertTransform(embedder, component, false); @@ -96,17 +96,17 @@ public class EmbedderTestCase { } @Test - void testPredefinedEmbedConfigCloud() throws IOException, SAXException { + void testPredefinedEmbedderCloud() throws IOException, SAXException { String embedder = "<embedder id='test' class='" + PREDEFINED_EMBEDDER_CLASS + "'>" + - " <transformerModel id='test-model-id' />" + - " <tokenizerVocab id='test-model-id' />" + + " <transformerModel id='minilm-l6-v2' />" + + " <tokenizerVocab id='bert-base-uncased' />" + "</embedder>"; String component = "<component id='test' class='" + PREDEFINED_EMBEDDER_CLASS + "' bundle='model-integration'>" + " <config name='" + PREDEFINED_EMBEDDER_CONFIG + "'>" + - " <transformerModelUrl>test-model-url</transformerModelUrl>" + - " <transformerModelPath></transformerModelPath>" + - " <tokenizerVocabUrl>test-model-url</tokenizerVocabUrl>" + - " <tokenizerVocabPath></tokenizerVocabPath>" + + " <transformerModelUrl>https://data.vespa.oath.cloud/onnx_models/sentence_all_MiniLM_L6_v2.onnx</transformerModelUrl>" + + " <transformerModelPath>services.xml</transformerModelPath>" + + " <tokenizerVocabUrl>https://data.vespa.oath.cloud/onnx_models/bert-base-uncased-vocab.txt</tokenizerVocabUrl>" + + " <tokenizerVocabPath>services.xml</tokenizerVocabPath>" + " </config>" + "</component>"; assertTransform(embedder, component, true); @@ -115,15 +115,15 @@ public class EmbedderTestCase { @Test void testCustomEmbedderWithPredefinedConfigCloud() throws IOException, SAXException { String embedder = "<embedder id='test' class='ApplicationSpecificEmbedder' def='" + PREDEFINED_EMBEDDER_CONFIG + "'>" + - " <transformerModel id='test-model-id' />" + - " <tokenizerVocab id='test-model-id' />" + + " <transformerModel id='minilm-l6-v2' />" + + " <tokenizerVocab id='bert-base-uncased' />" + "</embedder>"; String component = "<component id='test' class='ApplicationSpecificEmbedder' bundle='model-integration'>" + " <config name='" + PREDEFINED_EMBEDDER_CONFIG + "'>" + - " <transformerModelUrl>test-model-url</transformerModelUrl>" + - " <transformerModelPath></transformerModelPath>" + - " <tokenizerVocabUrl>test-model-url</tokenizerVocabUrl>" + - " <tokenizerVocabPath></tokenizerVocabPath>" + + " <transformerModelUrl>https://data.vespa.oath.cloud/onnx_models/sentence_all_MiniLM_L6_v2.onnx</transformerModelUrl>" + + " <transformerModelPath>services.xml</transformerModelPath>" + + " <tokenizerVocabUrl>https://data.vespa.oath.cloud/onnx_models/bert-base-uncased-vocab.txt</tokenizerVocabUrl>" + + " <tokenizerVocabPath>services.xml</tokenizerVocabPath>" + " </config>" + "</component>"; assertTransform(embedder, component, true); @@ -139,7 +139,7 @@ public class EmbedderTestCase { } @Test - void testApplicationWithEmbedConfig() throws Exception { + void testApplicationWithEmbedder() throws Exception { final String emptyPathFileName = "services.xml"; Path applicationDir = Path.fromString("src/test/cfg/application/embed/"); @@ -160,7 +160,7 @@ public class EmbedderTestCase { } @Test - void testApplicationWithGenericEmbedConfig() throws Exception { + void testApplicationWithGenericEmbedder() throws Exception { Path applicationDir = Path.fromString("src/test/cfg/application/embed_generic/"); VespaModel model = loadModel(applicationDir, false); ApplicationContainerCluster containerCluster = model.getContainerClusters().get("container"); @@ -182,17 +182,16 @@ public class EmbedderTestCase { assertTransform(embedder, component, false); } - private void assertTransform(String embedder, String component, boolean hosted) throws IOException, SAXException { - Element emb = createElement(embedder); - Element cmp = createElement(component); - Element trans = EmbedderConfigTransformer.transform(createEmptyDeployState(hosted), emb); - assertSpec(cmp, trans); + private void assertTransform(String embedder, String expectedComponent, boolean hosted) throws IOException, SAXException { + assertSpec(createElement(expectedComponent), + EmbedderConfigTransformer.transform(createEmptyDeployState(hosted), createElement(embedder))); } private void assertSpec(Element e1, Element e2) { assertEquals(e1.getTagName(), e2.getTagName()); assertAttributes(e1, e2); assertAttributes(e2, e1); + assertEquals(XML.getValue(e1).trim(), XML.getValue(e2).trim(), "Content of " + e1.getTagName() + "' is identical"); assertChildren(e1, e2); } |