From 50c92f5b6f3319b5f59dd5d30792e51f83de3d2b Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Wed, 29 Aug 2018 19:39:56 +0200 Subject: Revert "Merge pull request #6722 from vespa-engine/revert-6713-bratseth/generate-rank-profiles-for-all-models-part-10" This reverts commit 6958f2a641eaad0c61249e7bca887a1405e17d02, reversing changes made to 06323aff51bf054d64ef2bea001917a22433717f. --- .../integration/ml/ImportedModel.java | 24 +++++++++++----------- .../integration/ml/ImportedModels.java | 18 +++++++++++----- 2 files changed, 25 insertions(+), 17 deletions(-) (limited to 'searchlib') diff --git a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/ImportedModel.java b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/ImportedModel.java index 6716993e1dd..f7fe91cb56f 100644 --- a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/ImportedModel.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/ImportedModel.java @@ -98,33 +98,33 @@ public class ImportedModel { void requiredMacro(String name, TensorType type) { requiredMacros.put(name, type); } /** - * Returns all the outputs of this by name. The names consist of one to three parts - * separated by dot, where the first part is the model name, the second is the signature name + * Returns all the output expressions of this indexed by name. The names consist of one or two parts + * separated by dot, where the first part is the signature name * if signatures are used, or the expression name if signatures are not used and there are multiple - * expressions, and the third is the output name if signature names are used. + * expressions, and the second is the output name if signature names are used. */ public List> outputExpressions() { - List> names = new ArrayList<>(); + List> expressions = new ArrayList<>(); for (Map.Entry signatureEntry : signatures().entrySet()) { for (Map.Entry outputEntry : signatureEntry.getValue().outputs().entrySet()) - names.add(new Pair<>(signatureEntry.getKey() + "." + outputEntry.getKey(), - expressions().get(outputEntry.getValue()))); + expressions.add(new Pair<>(signatureEntry.getKey() + "." + outputEntry.getKey(), + expressions().get(outputEntry.getValue()))); if (signatureEntry.getValue().outputs().isEmpty()) // fallback: Signature without outputs - names.add(new Pair<>(signatureEntry.getKey(), - expressions().get(signatureEntry.getKey()))); + expressions.add(new Pair<>(signatureEntry.getKey(), + expressions().get(signatureEntry.getKey()))); } if (signatures().isEmpty()) { // fallback for models without signatures if (expressions().size() == 1) { - Map.Entry singleEntry = expressions.entrySet().iterator().next(); - names.add(new Pair<>(singleEntry.getKey(), singleEntry.getValue())); + Map.Entry singleEntry = this.expressions.entrySet().iterator().next(); + expressions.add(new Pair<>(singleEntry.getKey(), singleEntry.getValue())); } else { for (Map.Entry expressionEntry : expressions().entrySet()) { - names.add(new Pair<>(expressionEntry.getKey(), expressionEntry.getValue())); + expressions.add(new Pair<>(expressionEntry.getKey(), expressionEntry.getValue())); } } } - return names; + return expressions; } /** diff --git a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/ImportedModels.java b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/ImportedModels.java index b1714b49256..32d33622a33 100644 --- a/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/ImportedModels.java +++ b/searchlib/src/main/java/com/yahoo/searchlib/rankingexpression/integration/ml/ImportedModels.java @@ -10,7 +10,9 @@ import java.util.Collection; import java.util.Optional; /** - * All models imported from the models/ directory in the application package + * All models imported from the models/ directory in the application package. + * If this is empty it may be due to either not having any models in the application package, + * or this being created for a ZooKeeper application package, which does not have imported models. * * @author bratseth */ @@ -54,16 +56,22 @@ public class ImportedModels { } /** - * Returns the model at the given location in the application package (lazily loaded), + * Returns the model at the given location in the application package. * - * @param modelPath the full path to this model (file or directory, depending on model type) - * under the application package - * @throws IllegalArgumentException if the model cannot be loaded + * @param modelPath the path to this model (file or directory, depending on model type) + * under the application package, both from the root or relative to the + * models directory works + * @return the model at this path or null if none */ public ImportedModel get(File modelPath) { + System.out.println("Name from " + modelPath + ": " + toName(modelPath)); return importedModels.get(toName(modelPath)); } + public ImportedModel get(String modelName) { + return importedModels.get(modelName); + } + /** Returns an immutable collection of all the imported models */ public Collection all() { return importedModels.values(); -- cgit v1.2.3