diff options
author | Jon Bratseth <bratseth@oath.com> | 2018-08-30 13:20:35 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@oath.com> | 2018-08-30 13:20:35 +0200 |
commit | a9e0e05063e156eb1692346cdcbbf9a1c85483d2 (patch) | |
tree | 412c86ea39ce850ef6a8e3e2241948a686743d9e /config-model/src/test/java/com/yahoo/config/model | |
parent | 50c92f5b6f3319b5f59dd5d30792e51f83de3d2b (diff) |
Test reading stored global models
Also
- assign the proper name to ranking expressions in macros
- output more debug inof on generated macro collision
Diffstat (limited to 'config-model/src/test/java/com/yahoo/config/model')
-rw-r--r-- | config-model/src/test/java/com/yahoo/config/model/ModelEvaluationTest.java | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/config-model/src/test/java/com/yahoo/config/model/ModelEvaluationTest.java b/config-model/src/test/java/com/yahoo/config/model/ModelEvaluationTest.java index 8558ccc44bd..80b7c592733 100644 --- a/config-model/src/test/java/com/yahoo/config/model/ModelEvaluationTest.java +++ b/config-model/src/test/java/com/yahoo/config/model/ModelEvaluationTest.java @@ -3,7 +3,6 @@ package com.yahoo.config.model; import ai.vespa.models.evaluation.Model; import ai.vespa.models.evaluation.ModelsEvaluator; import com.yahoo.config.application.api.ApplicationPackage; -import com.yahoo.config.model.application.provider.FilesApplicationPackage; import com.yahoo.io.IOUtils; import com.yahoo.path.Path; import com.yahoo.vespa.config.search.RankProfilesConfig; @@ -26,22 +25,41 @@ import static org.junit.Assert.assertTrue; */ public class ModelEvaluationTest { - private static final String appDir = "src/test/cfg/application/ml_serving"; + private static final Path appDir = Path.fromString("src/test/cfg/application/ml_serving"); @After public void removeGeneratedModelFiles() { - IOUtils.recursiveDeleteDir(Path.fromString(appDir).append(ApplicationPackage.MODELS_GENERATED_DIR).toFile()); + IOUtils.recursiveDeleteDir(appDir.append(ApplicationPackage.MODELS_GENERATED_DIR).toFile()); } @Test public void testMl_ServingApplication() throws SAXException, IOException { - ApplicationPackageTester tester = ApplicationPackageTester.create(appDir); + ApplicationPackageTester tester = ApplicationPackageTester.create(appDir.toString()); VespaModel model = new VespaModel(tester.app()); + assertHasMlModels(model); + + // At this point the expression is stored - copy application to another location which do not have a models dir + Path storedAppDir = appDir.append("copy"); + try { + storedAppDir.toFile().mkdirs(); + IOUtils.copy(appDir.append("services.xml").toString(), storedAppDir.append("services.xml").toString()); + IOUtils.copyDirectory(appDir.append(ApplicationPackage.MODELS_GENERATED_DIR).toFile(), + storedAppDir.append(ApplicationPackage.MODELS_GENERATED_DIR).toFile()); + ApplicationPackageTester storedTester = ApplicationPackageTester.create(storedAppDir.toString()); + VespaModel storedModel = new VespaModel(storedTester.app()); + assertHasMlModels(storedModel); + } + finally { + IOUtils.recursiveDeleteDir(storedAppDir.toFile()); + } + } + + private void assertHasMlModels(VespaModel model) { ContainerCluster cluster = model.getContainerClusters().get("container"); RankProfilesConfig.Builder b = new RankProfilesConfig.Builder(); cluster.getConfig(b); RankProfilesConfig config = new RankProfilesConfig(b); - assertEquals(3, config.rankprofile().size()); + assertEquals(4, config.rankprofile().size()); Set<String> modelNames = config.rankprofile().stream().map(v -> v.name()).collect(Collectors.toSet()); assertTrue(modelNames.contains("xgboost_2_2")); assertTrue(modelNames.contains("mnist_softmax")); @@ -49,7 +67,7 @@ public class ModelEvaluationTest { ModelsEvaluator evaluator = new ModelsEvaluator(config); - assertEquals(3, evaluator.models().size()); + assertEquals(4, evaluator.models().size()); Model xgboost = evaluator.models().get("xgboost_2_2"); assertNotNull(xgboost); assertNotNull(xgboost.evaluatorOf()); |