summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-05-13 15:39:11 +0200
committerJon Bratseth <bratseth@gmail.com>2022-05-13 15:39:11 +0200
commit764bb6c8be54fb94e0652d919286d8e4121faed4 (patch)
tree8f14d7d5a6e0d2712119a19fdb8f73ed76866a2d
parent19490cfa6d60e35e83902b3e5d6803f8d0146af5 (diff)
No functional changes
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java23
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/OnnxModelTransformer.java6
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java2
-rw-r--r--model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/OnnxConstant.java2
-rw-r--r--model-integration/src/main/java/ai/vespa/rankingexpression/importer/tensorflow/TensorFlowImporter.java4
5 files changed, 23 insertions, 14 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java
index 770ca358ea4..4e718714ded 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java
@@ -2,6 +2,7 @@
package com.yahoo.searchdefinition.derived;
import ai.vespa.rankingexpression.importer.configmodelview.ImportedMlModels;
+import com.yahoo.config.application.api.DeployLogger;
import com.yahoo.config.model.api.ModelContext;
import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.search.query.profile.QueryProfileRegistry;
@@ -27,6 +28,7 @@ import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
+import java.util.logging.Level;
import java.util.logging.Logger;
/**
@@ -74,23 +76,30 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ
Map<Reference, RankProfile.Constant> constantsFromSchema,
DeployState deployState) {
Map<Reference, RankProfile.Constant> allFileConstants = new HashMap<>();
- addFileConstants(constantsFromSchema.values(), allFileConstants, schema != null ? schema.toString() : "[global]");
+ addFileConstants(constantsFromSchema.values(), allFileConstants, schema != null ? schema.toString() : "[global]", deployState.getDeployLogger());
for (var profile : deployState.rankProfileRegistry().rankProfilesOf(schema))
- addFileConstants(profile.constants().values(), allFileConstants, profile.toString());
+ addFileConstants(profile.constants().values(), allFileConstants, profile.toString(), deployState.getDeployLogger());
for (var profile : deployState.rankProfileRegistry().rankProfilesOf(null))
- addFileConstants(profile.constants().values(), allFileConstants, profile.toString());
+ addFileConstants(profile.constants().values(), allFileConstants, profile.toString(), deployState.getDeployLogger());
return new FileDistributedConstants(deployState.getFileRegistry(), allFileConstants.values());
}
private static void addFileConstants(Collection<RankProfile.Constant> source,
Map<Reference, RankProfile.Constant> destination,
- String sourceName) {
+ String sourceName,
+ DeployLogger logger) {
for (var constant : source) {
if (constant.valuePath().isEmpty()) continue;
var existing = destination.get(constant.name());
- if ( existing != null && ! constant.equals(existing))
- throw new IllegalArgumentException("Duplicate " + constant + " in " + sourceName +
- ": Value reference constants must be unique across all rank profiles");
+ if ( existing != null && ! constant.equals(existing)) {
+ String message = "Duplicate constants: " + sourceName + " have " + constant +
+ ", but we already have " + existing +
+ ": Value reference constants must be unique across all rank profiles and models";
+ if (! constant.type().equals(existing.type()))
+ throw new IllegalArgumentException(message);
+ else // different paths are allowed
+ logger.logApplicationPackage(Level.WARNING, message);
+ }
destination.put(constant.name(), constant);
}
}
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/OnnxModelTransformer.java b/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/OnnxModelTransformer.java
index 35ee9ddb9ed..71493df357c 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/OnnxModelTransformer.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/OnnxModelTransformer.java
@@ -61,7 +61,7 @@ public class OnnxModelTransformer extends ExpressionTransformer<RankProfileTrans
Arguments arguments = feature.getArguments();
if (arguments.isEmpty())
throw new IllegalArgumentException("An " + featureName + " feature must take an argument referring to a " +
- "onnx-model config or an ONNX file.");
+ "onnx-model config or an ONNX file.");
if (arguments.expressions().size() > 3)
throw new IllegalArgumentException("An " + featureName + " feature can have at most 3 arguments.");
@@ -84,7 +84,7 @@ public class OnnxModelTransformer extends ExpressionTransformer<RankProfileTrans
String output = getModelOutput(feature.reference(), defaultOutput);
if (! onnxModel.getOutputMap().containsValue(output)) {
throw new IllegalArgumentException(featureName + " argument '" + output +
- "' output not found in model '" + onnxModel.getFileName() + "'");
+ "' output not found in model '" + onnxModel.getFileName() + "'");
}
return new ReferenceNode("onnxModel", List.of(new ReferenceNode(modelConfigName)), output);
}
@@ -95,7 +95,7 @@ public class OnnxModelTransformer extends ExpressionTransformer<RankProfileTrans
if (expr instanceof ReferenceNode) { // refers to onnx-model config
return expr.toString();
}
- if (expr instanceof ConstantNode) { // refers to an file path
+ if (expr instanceof ConstantNode) { // refers to a file path
return asValidIdentifier(expr);
}
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java b/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java
index f79f3d9c82c..4662f68c31d 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java
@@ -323,7 +323,7 @@ public final class VespaModel extends AbstractConfigProducerRoot implements Seri
private OnnxModels onnxModelInfoFromSource(ImportedMlModel model, FileRegistry fileRegistry) {
OnnxModels onnxModels = new OnnxModels(fileRegistry, Optional.empty());
- if (model.modelType().equals(ImportedMlModel.ModelType.ONNX)) {
+ if (model.modelType() == ImportedMlModel.ModelType.ONNX) {
String path = model.source();
String applicationPath = this.applicationPackage.getFileReference(Path.fromString("")).toString();
if (path.startsWith(applicationPath)) {
diff --git a/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/OnnxConstant.java b/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/OnnxConstant.java
index 675e18da637..117d699c3a9 100644
--- a/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/OnnxConstant.java
+++ b/model-integration/src/main/java/ai/vespa/rankingexpression/importer/operations/OnnxConstant.java
@@ -84,7 +84,7 @@ public class OnnxConstant extends IntermediateOperation {
}
if (value.isEmpty()) {
throw new IllegalArgumentException("Node '" + name + "' of type " +
- "constant has missing or non-supported 'value' attribute");
+ "constant has missing or non-supported 'value' attribute");
}
return value.get();
}
diff --git a/model-integration/src/main/java/ai/vespa/rankingexpression/importer/tensorflow/TensorFlowImporter.java b/model-integration/src/main/java/ai/vespa/rankingexpression/importer/tensorflow/TensorFlowImporter.java
index cb1dede26d9..5316416c4dc 100644
--- a/model-integration/src/main/java/ai/vespa/rankingexpression/importer/tensorflow/TensorFlowImporter.java
+++ b/model-integration/src/main/java/ai/vespa/rankingexpression/importer/tensorflow/TensorFlowImporter.java
@@ -76,8 +76,8 @@ public class TensorFlowImporter extends ModelImporter {
log.fine("Conversion to ONNX with opset " + opset + " failed. Reason: " + res.getSecond());
outputOfLastConversionAttempt = res.getSecond();
}
- throw new IllegalArgumentException("Unable to convert TensorFlow model in '" + modelDir + "' to ONNX. " +
- "Reason: " + outputOfLastConversionAttempt);
+ throw new IllegalArgumentException("Unable to convert TensorFlow model in '" + modelDir + "' to ONNX: " +
+ outputOfLastConversionAttempt);
} catch (IOException e) {
throw new IllegalArgumentException("Conversion from TensorFlow to ONNX failed for '" + modelDir + "'");
} finally {