summaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-08-24 13:59:39 +0200
committerJon Bratseth <bratseth@gmail.com>2022-08-24 13:59:39 +0200
commit6e0094d2b126f72295bcecb854d3f5b56b7df02c (patch)
treeb19cf79a241fda37bfa042bc6a6467cf4d55f236 /config-model
parentdd32f335484c133cf47ac354f8709c61c9d58bd3 (diff)
Cleanup
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/xml/EmbedderConfigTransformer.java24
1 files changed, 10 insertions, 14 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 576399333df..51ca2efcdd5 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
@@ -38,12 +38,15 @@ public class EmbedderConfigTransformer {
* @return a new XML element containting the &lt;component ...&gt; configuration
*/
public static Element transform(DeployState deployState, Element embedder) {
+ String embedderId = XML.attribute("id", embedder).orElseThrow(); // Required by schema
+ String embedderClass = XML.attribute("class", embedder).orElse(embedderId);
+
Element component = XML.getDocumentBuilder().newDocument().createElement("component");
- component.setAttribute("id", embedder.getAttribute("id"));
- component.setAttribute("class", embedderClassFrom(embedder));
- component.setAttribute("bundle", embedder.hasAttribute("bundle") ? embedder.getAttribute("bundle") : "model-integration");
+ component.setAttribute("id", embedderId);
+ component.setAttribute("class", embedderClass);
+ component.setAttribute("bundle", XML.attribute("bundle", embedder).orElse("model-integration"));
- String configDef = embedderConfigFrom(embedder);
+ String configDef = embedderConfigFrom(embedder, embedderClass);
if ( ! configDef.isEmpty()) {
Element config = component.getOwnerDocument().createElement("config");
config.setAttribute("name", configDef);
@@ -84,12 +87,12 @@ public class EmbedderConfigTransformer {
parent.appendChild(element);
}
- private static String embedderConfigFrom(Element spec) {
- String explicitDefinition = spec.getAttribute("def");
+ private static String embedderConfigFrom(Element embedder, String embedderClass) {
+ String explicitDefinition = embedder.getAttribute("def");
if ( ! explicitDefinition.isEmpty()) return explicitDefinition;
// Implicit from class name
- return switch (embedderClassFrom(spec)) {
+ return switch (embedderClass) {
case "ai.vespa.embedding.BertBaseEmbedder" -> "embedding.bert-base-embedder";
default -> "";
};
@@ -105,11 +108,4 @@ public class EmbedderConfigTransformer {
throw new IllegalArgumentException("Unknown model id '" + id + "'");
}
- private static String embedderClassFrom(Element spec) {
- if (spec.hasAttribute("class"))
- return spec.getAttribute("class");
- return spec.getAttribute("id");
- }
-
-
}