From 764bb6c8be54fb94e0652d919286d8e4121faed4 Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Fri, 13 May 2022 15:39:11 +0200 Subject: No functional changes --- .../searchdefinition/derived/RankProfileList.java | 23 +++++++++++++++------- .../expressiontransforms/OnnxModelTransformer.java | 6 +++--- .../java/com/yahoo/vespa/model/VespaModel.java | 2 +- 3 files changed, 20 insertions(+), 11 deletions(-) (limited to 'config-model/src/main/java') 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 constantsFromSchema, DeployState deployState) { Map 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 source, Map 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 3) throw new IllegalArgumentException("An " + featureName + " feature can have at most 3 arguments."); @@ -84,7 +84,7 @@ public class OnnxModelTransformer extends ExpressionTransformer