use of io.seldon.protos.DeploymentProtos.SeldonDeployment in project seldon-core by SeldonIO.
the class SeldonDeploymentValidationTest method testDefaulting.
@Test
public void testDefaulting() throws IOException, SeldonDeploymentException {
SeldonDeploymentOperator op = new SeldonDeploymentOperatorImpl(getClusterManagerprops());
String jsonStr = readFile("src/test/resources/model_simple.json", StandardCharsets.UTF_8);
SeldonDeployment mlDep = SeldonDeploymentUtils.jsonToSeldonDeployment(jsonStr);
SeldonDeployment mlDep2 = op.defaulting(mlDep);
op.validate(mlDep2);
}
use of io.seldon.protos.DeploymentProtos.SeldonDeployment in project seldon-core by SeldonIO.
the class SeldonDeploymentValidationTest method testBadGraph.
@Test(expected = SeldonDeploymentException.class)
public void testBadGraph() throws IOException, SeldonDeploymentException {
SeldonDeploymentOperator op = new SeldonDeploymentOperatorImpl(getClusterManagerprops());
String jsonStr = readFile("src/test/resources/model_invalid_graph.json", StandardCharsets.UTF_8);
SeldonDeployment mlDep = SeldonDeploymentUtils.jsonToSeldonDeployment(jsonStr);
SeldonDeployment mlDep2 = op.defaulting(mlDep);
op.validate(mlDep2);
}
use of io.seldon.protos.DeploymentProtos.SeldonDeployment in project seldon-core by SeldonIO.
the class SeldonDeploymentValidationTest method testNoMethod.
@Test(expected = SeldonDeploymentException.class)
public void testNoMethod() throws IOException, SeldonDeploymentException {
SeldonDeploymentOperator op = new SeldonDeploymentOperatorImpl(getClusterManagerprops());
String jsonStr = readFile("src/test/resources/model_invalid_no_method.json", StandardCharsets.UTF_8);
SeldonDeployment mlDep = SeldonDeploymentUtils.jsonToSeldonDeployment(jsonStr);
SeldonDeployment mlDep2 = op.defaulting(mlDep);
op.validate(mlDep2);
}
use of io.seldon.protos.DeploymentProtos.SeldonDeployment in project seldon-core by SeldonIO.
the class SeldonDeploymentOperatorImpl method createResources.
@Override
public DeploymentResources createResources(SeldonDeployment mlDep) throws SeldonDeploymentException {
OwnerReference ownerRef = getOwnerReference(mlDep);
List<Deployment> deployments = new ArrayList<>();
// for each predictor Create/replace deployment
String serviceLabel = mlDep.getSpec().getName();
for (PredictorSpec p : mlDep.getSpec().getPredictorsList()) {
String depName = getKubernetesDeploymentName(mlDep.getSpec().getName(), p.getName());
PodTemplateSpec.Builder podSpecBuilder = PodTemplateSpec.newBuilder(p.getComponentSpec());
podSpecBuilder.getSpecBuilder().addContainers(createEngineContainer(mlDep, p)).setTerminationGracePeriodSeconds(20);
podSpecBuilder.getMetadataBuilder().putAnnotations("prometheus.io/path", "/prometheus").putAnnotations("prometheus.io/port", "" + clusterManagerProperites.getEngineContainerPort()).putAnnotations("prometheus.io/scrape", "true");
Deployment deployment = V1beta1Extensions.Deployment.newBuilder().setMetadata(ObjectMeta.newBuilder().setName(depName).putLabels(SeldonDeploymentOperatorImpl.LABEL_SELDON_APP, serviceLabel).putLabels(Constants.LABEL_SELDON_ID, mlDep.getSpec().getName()).putLabels("app", depName).putLabels("version", // FIXME
"v1").putLabels(SeldonDeploymentOperatorImpl.LABEL_SELDON_TYPE_KEY, SeldonDeploymentOperatorImpl.LABEL_SELDON_TYPE_VAL).addOwnerReferences(ownerRef)).setSpec(DeploymentSpec.newBuilder().setTemplate(podSpecBuilder.build()).setStrategy(DeploymentStrategy.newBuilder().setRollingUpdate(RollingUpdateDeployment.newBuilder().setMaxUnavailable(IntOrString.newBuilder().setType(1).setStrVal("10%")))).setReplicas(p.getReplicas())).build();
deployments.add(deployment);
}
final String serviceName = mlDep.getSpec().getName();
Service s = Service.newBuilder().setMetadata(ObjectMeta.newBuilder().setName(serviceName).putLabels(SeldonDeploymentOperatorImpl.LABEL_SELDON_APP, serviceLabel).putLabels("seldon-deployment-id", mlDep.getSpec().getName()).addOwnerReferences(ownerRef).putAnnotations("getambassador.io/config", getAmbassadorAnnotation(mlDep, serviceName))).setSpec(ServiceSpec.newBuilder().addPorts(ServicePort.newBuilder().setProtocol("TCP").setPort(clusterManagerProperites.getEngineContainerPort()).setTargetPort(IntOrString.newBuilder().setIntVal(clusterManagerProperites.getEngineContainerPort())).setName("http")).addPorts(ServicePort.newBuilder().setProtocol("TCP").setPort(clusterManagerProperites.getEngineGrpcContainerPort()).setTargetPort(IntOrString.newBuilder().setIntVal(clusterManagerProperites.getEngineGrpcContainerPort())).setName("grpc")).setType("ClusterIP").putSelector(SeldonDeploymentOperatorImpl.LABEL_SELDON_APP, serviceLabel)).build();
// Create service for deployment
return new DeploymentResources(deployments, s);
}
use of io.seldon.protos.DeploymentProtos.SeldonDeployment in project seldon-core by SeldonIO.
the class SeldonDeploymentStatusUpdateImpl method updateStatus.
@Override
public void updateStatus(String mlDepName, String depName, Integer replicas, Integer replicasAvailable) {
if (replicas == null || replicas == 0)
removeStatus(mlDepName, depName);
else {
logger.info(String.format("UPDATE %s : %s %d %d", mlDepName, depName, replicas, replicasAvailable));
SeldonDeployment mlDep = crdHandler.getSeldonDeployment(mlDepName);
if (mlDep != null) {
SeldonDeployment.Builder mlBuilder = SeldonDeployment.newBuilder(mlDep);
boolean changed = false;
for (PredictorStatus.Builder b : mlBuilder.getStatusBuilder().getPredictorStatusBuilderList()) {
if (b.getName().equals(depName)) {
update(b, replicas, replicasAvailable);
changed = true;
break;
}
}
if (!changed) {
PredictorStatus.Builder b = PredictorStatus.newBuilder().setName(depName);
update(b, replicas, replicasAvailable);
mlBuilder.getStatusBuilder().addPredictorStatus(b);
}
crdHandler.updateSeldonDeployment(mlBuilder.build());
} else
logger.error("Can't find seldondeployment " + mlDepName + " to update " + depName);
}
}
Aggregations