use of com.netflix.titus.runtime.connector.prediction.JobRuntimePrediction in project titus-control-plane by Netflix.
the class JobRuntimePredictionSanitizer method isValid.
private static boolean isValid(JobRuntimePredictions predictions) {
if (CollectionsExt.isNullOrEmpty(predictions.getPredictions())) {
return false;
}
// higher quality predictions are always expected to be longer, and no zeroes allowed
double lastSeen = 0.0;
for (JobRuntimePrediction prediction : predictions.getPredictions()) {
double current = prediction.getRuntimeInSeconds();
if (current <= 0.0 || current < lastSeen) {
return false;
}
lastSeen = current;
}
return true;
}
use of com.netflix.titus.runtime.connector.prediction.JobRuntimePrediction in project titus-control-plane by Netflix.
the class JobRuntimePredictionSanitizerTest method higherQualityPredictionsMustBeLonger.
@Test
public void higherQualityPredictionsMustBeLonger() {
JobRuntimePredictionClient client = mock(JobRuntimePredictionClient.class);
JobRuntimePredictions predictions = new JobRuntimePredictions("v1", modelId, new TreeSet<>(Arrays.asList(new JobRuntimePrediction(0.05, 5.1), new JobRuntimePrediction(0.25, 4.0), new JobRuntimePrediction(0.35, 4.1), new JobRuntimePrediction(0.90, 4.0))));
when(client.getRuntimePredictions(any())).thenReturn(Mono.just(predictions));
AdmissionSanitizer<JobDescriptor> sanitizer = new JobRuntimePredictionSanitizer(client, JobRuntimePredictionSelectors.best(), config, TitusRuntimes.test());
StepVerifier.create(sanitizer.sanitizeAndApply(jobDescriptor)).assertNext(result -> assertThat(((JobDescriptor<?>) result).getAttributes()).containsEntry(JOB_ATTRIBUTES_SANITIZATION_SKIPPED_RUNTIME_PREDICTION, "true").containsEntry(JOB_ATTRIBUTES_RUNTIME_PREDICTION_MODEL_ID, modelId).containsEntry(JOB_ATTRIBUTES_RUNTIME_PREDICTION_VERSION, "v1").containsEntry(JOB_ATTRIBUTES_RUNTIME_PREDICTION_AVAILABLE, "0.05=5.1;0.25=4.0;0.35=4.1;0.9=4.0")).verifyComplete();
}
use of com.netflix.titus.runtime.connector.prediction.JobRuntimePrediction in project titus-control-plane by Netflix.
the class JobRuntimePredictionSanitizerTest method setup.
@Before
public void setup() {
jobDescriptor = JobDescriptorGenerator.oneTaskBatchJobDescriptor();
modelId = UUID.randomUUID().toString();
config = mock(JobRuntimePredictionConfiguration.class);
when(config.getMaxOpportunisticRuntimeLimitMs()).thenReturn(300_000L);
client = mock(JobRuntimePredictionClient.class);
JobRuntimePredictions predictions = new JobRuntimePredictions("v1", modelId, new TreeSet<>(Arrays.asList(new JobRuntimePrediction(0.05, 5.5), new JobRuntimePrediction(0.25, 6.0), new JobRuntimePrediction(0.90, 20.1))));
when(client.getRuntimePredictions(jobDescriptor)).thenReturn(Mono.just(predictions));
}
use of com.netflix.titus.runtime.connector.prediction.JobRuntimePrediction in project titus-control-plane by Netflix.
the class JobRuntimePredictionSanitizerTest method zeroedPredictionsCauseSanitizationToBeSkipped.
@Test
public void zeroedPredictionsCauseSanitizationToBeSkipped() {
JobRuntimePredictionClient client = mock(JobRuntimePredictionClient.class);
JobRuntimePredictions predictions = new JobRuntimePredictions("v1", modelId, new TreeSet<>(Arrays.asList(new JobRuntimePrediction(0.05, 0.0), new JobRuntimePrediction(0.25, 6.0), new JobRuntimePrediction(0.90, 21.2))));
when(client.getRuntimePredictions(any())).thenReturn(Mono.just(predictions));
AdmissionSanitizer<JobDescriptor> sanitizer = new JobRuntimePredictionSanitizer(client, JobRuntimePredictionSelectors.best(), config, TitusRuntimes.test());
StepVerifier.create(sanitizer.sanitizeAndApply(jobDescriptor)).assertNext(result -> assertThat(((JobDescriptor<?>) result).getAttributes()).containsEntry(JOB_ATTRIBUTES_SANITIZATION_SKIPPED_RUNTIME_PREDICTION, "true").containsEntry(JOB_ATTRIBUTES_RUNTIME_PREDICTION_MODEL_ID, modelId).containsEntry(JOB_ATTRIBUTES_RUNTIME_PREDICTION_VERSION, "v1").containsEntry(JOB_ATTRIBUTES_RUNTIME_PREDICTION_AVAILABLE, "0.05=0.0;0.25=6.0;0.9=21.2")).verifyComplete();
}
use of com.netflix.titus.runtime.connector.prediction.JobRuntimePrediction in project titus-control-plane by Netflix.
the class JobRuntimePredictionSanitizerTest method predictionsAreCappedToRuntimeLimit.
@Test
public void predictionsAreCappedToRuntimeLimit() {
JobRuntimePredictionClient client = mock(JobRuntimePredictionClient.class);
JobRuntimePredictions predictions = new JobRuntimePredictions("v1", modelId, new TreeSet<>(Arrays.asList(new JobRuntimePrediction(0.05, 10.1), new JobRuntimePrediction(0.25, 30.2), new JobRuntimePrediction(0.90, 90.5))));
when(client.getRuntimePredictions(any())).thenReturn(Mono.just(predictions));
AdmissionSanitizer<JobDescriptor> sanitizer = new JobRuntimePredictionSanitizer(client, JobRuntimePredictionSelectors.best(), config, TitusRuntimes.test());
StepVerifier.create(sanitizer.sanitizeAndApply(jobDescriptor)).assertNext(result -> assertThat(((JobDescriptor<?>) result).getAttributes()).containsEntry(JOB_ATTRIBUTES_RUNTIME_PREDICTION_SEC, "60.0").containsEntry(JOB_ATTRIBUTES_RUNTIME_PREDICTION_CONFIDENCE, "1.0").containsEntry(JOB_ATTRIBUTES_RUNTIME_PREDICTION_MODEL_ID, modelId).containsEntry(JOB_ATTRIBUTES_RUNTIME_PREDICTION_VERSION, "v1").containsEntry(JOB_ATTRIBUTES_RUNTIME_PREDICTION_AVAILABLE, "0.05=10.1;0.25=30.2;0.9=90.5")).verifyComplete();
}
Aggregations