diff options
author | Jon Bratseth <bratseth@oath.com> | 2018-08-30 22:48:17 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@oath.com> | 2018-08-30 22:48:17 +0200 |
commit | 8a1c7bb53923ba9fa01c3c6ceba2046be0530d11 (patch) | |
tree | 24830adc8d42e2d9735eefeffa23ae3eb113f62a /config-model/src/test/java/com/yahoo/config/model | |
parent | 6250e2b6c78e5ee27690b5071f68ae510e8c113f (diff) |
Revert "Merge pull request #6742 from vespa-engine/revert-6732-bratseth/generate-rank-profiles-for-all-models-part-10-2"
This reverts commit a294ef166c59c795f9e6fd31fbd6914c502d559a, reversing
changes made to cef4c0f9d7c084f320e77abb2a93522acd7f3f53.
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 | 37 |
1 files changed, 32 insertions, 5 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 677a7615f04..c5fb4f575cf 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 @@ -2,10 +2,13 @@ package com.yahoo.config.model; import ai.vespa.models.evaluation.Model; import ai.vespa.models.evaluation.ModelsEvaluator; -import com.yahoo.config.model.application.provider.FilesApplicationPackage; +import com.yahoo.config.application.api.ApplicationPackage; +import com.yahoo.io.IOUtils; +import com.yahoo.path.Path; import com.yahoo.vespa.config.search.RankProfilesConfig; import com.yahoo.vespa.model.VespaModel; import com.yahoo.vespa.model.container.ContainerCluster; +import org.junit.After; import org.junit.Test; import org.xml.sax.SAXException; @@ -22,17 +25,41 @@ import static org.junit.Assert.assertTrue; */ public class ModelEvaluationTest { - private static final String TESTDIR = "src/test/cfg/application/"; + private static final Path appDir = Path.fromString("src/test/cfg/application/ml_serving"); + + @After + public void removeGeneratedModelFiles() { + IOUtils.recursiveDeleteDir(appDir.append(ApplicationPackage.MODELS_GENERATED_DIR).toFile()); + } @Test public void testMl_ServingApplication() throws SAXException, IOException { - ApplicationPackageTester tester = ApplicationPackageTester.create(TESTDIR + "ml_serving"); + 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")); @@ -40,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()); |