Search in sources :

Example 1 with AsyncPredictFn

use of com.spotify.zoltar.PredictFns.AsyncPredictFn in project zoltar by spotify.

the class PredictorTest method empty.

@Test
public void empty() throws InterruptedException, ExecutionException, TimeoutException {
    final Duration wait = Duration.ofSeconds(1);
    final ExtractFn<Object, Object> extractFn = inputs -> Collections.emptyList();
    final AsyncPredictFn<DummyModel, Object, Object, Object> predictFn = (model, vectors) -> CompletableFuture.completedFuture(Collections.emptyList());
    final ModelLoader<DummyModel> loader = ModelLoader.lift(DummyModel::new);
    DefaultPredictorBuilder.create(loader, extractFn, predictFn).predictor().predict().toCompletableFuture().get(wait.toMillis(), TimeUnit.MILLISECONDS);
}
Also used : SingleExtractFn(com.spotify.zoltar.FeatureExtractFns.SingleExtractFn) PredictFn(com.spotify.zoltar.PredictFns.PredictFn) Assert.assertTrue(org.junit.Assert.assertTrue) TimeoutException(java.util.concurrent.TimeoutException) CompletableFuture(java.util.concurrent.CompletableFuture) Test(org.junit.Test) AsyncPredictFn(com.spotify.zoltar.PredictFns.AsyncPredictFn) Collectors(java.util.stream.Collectors) Assert.assertThat(org.junit.Assert.assertThat) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Duration(java.time.Duration) Is.is(org.hamcrest.core.Is.is) ExtractFn(com.spotify.zoltar.FeatureExtractFns.ExtractFn) Assert.fail(org.junit.Assert.fail) Collections(java.util.Collections) Duration(java.time.Duration) Test(org.junit.Test)

Aggregations

ExtractFn (com.spotify.zoltar.FeatureExtractFns.ExtractFn)1 SingleExtractFn (com.spotify.zoltar.FeatureExtractFns.SingleExtractFn)1 AsyncPredictFn (com.spotify.zoltar.PredictFns.AsyncPredictFn)1 PredictFn (com.spotify.zoltar.PredictFns.PredictFn)1 Duration (java.time.Duration)1 Collections (java.util.Collections)1 List (java.util.List)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeUnit (java.util.concurrent.TimeUnit)1 TimeoutException (java.util.concurrent.TimeoutException)1 Collectors (java.util.stream.Collectors)1 Is.is (org.hamcrest.core.Is.is)1 Assert.assertThat (org.junit.Assert.assertThat)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Assert.fail (org.junit.Assert.fail)1 Test (org.junit.Test)1