Search in sources :

Example 11 with SeldonDeployment

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);
}
Also used : SeldonDeployment(io.seldon.protos.DeploymentProtos.SeldonDeployment) AppTest(io.seldon.clustermanager.AppTest) Test(org.junit.Test)

Example 12 with SeldonDeployment

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);
}
Also used : SeldonDeployment(io.seldon.protos.DeploymentProtos.SeldonDeployment) AppTest(io.seldon.clustermanager.AppTest) Test(org.junit.Test)

Example 13 with SeldonDeployment

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);
}
Also used : SeldonDeployment(io.seldon.protos.DeploymentProtos.SeldonDeployment) AppTest(io.seldon.clustermanager.AppTest) Test(org.junit.Test)

Example 14 with SeldonDeployment

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);
}
Also used : V1OwnerReference(io.kubernetes.client.models.V1OwnerReference) OwnerReference(io.kubernetes.client.proto.Meta.OwnerReference) PodTemplateSpec(io.kubernetes.client.proto.V1.PodTemplateSpec) ArrayList(java.util.ArrayList) SeldonDeployment(io.seldon.protos.DeploymentProtos.SeldonDeployment) Deployment(io.kubernetes.client.proto.V1beta1Extensions.Deployment) RollingUpdateDeployment(io.kubernetes.client.proto.V1beta1Extensions.RollingUpdateDeployment) Service(io.kubernetes.client.proto.V1.Service) IntOrString(io.kubernetes.client.proto.IntStr.IntOrString) PredictorSpec(io.seldon.protos.DeploymentProtos.PredictorSpec)

Example 15 with SeldonDeployment

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);
    }
}
Also used : PredictorStatus(io.seldon.protos.DeploymentProtos.PredictorStatus) SeldonDeployment(io.seldon.protos.DeploymentProtos.SeldonDeployment)

Aggregations

SeldonDeployment (io.seldon.protos.DeploymentProtos.SeldonDeployment)15 AppTest (io.seldon.clustermanager.AppTest)5 Test (org.junit.Test)5 IntOrString (io.kubernetes.client.proto.IntStr.IntOrString)3 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)2 ApiException (io.kubernetes.client.ApiException)2 Deployment (io.kubernetes.client.proto.V1beta1Extensions.Deployment)2 PredictorSpec (io.seldon.protos.DeploymentProtos.PredictorSpec)2 PredictorStatus (io.seldon.protos.DeploymentProtos.PredictorStatus)2 IOException (java.io.IOException)2 ApiClient (io.kubernetes.client.ApiClient)1 ProtoClient (io.kubernetes.client.ProtoClient)1 CustomObjectsApi (io.kubernetes.client.apis.CustomObjectsApi)1 ExtensionsV1beta1Deployment (io.kubernetes.client.models.ExtensionsV1beta1Deployment)1 ExtensionsV1beta1DeploymentList (io.kubernetes.client.models.ExtensionsV1beta1DeploymentList)1 V1OwnerReference (io.kubernetes.client.models.V1OwnerReference)1 DeleteOptions (io.kubernetes.client.proto.Meta.DeleteOptions)1 ObjectMeta (io.kubernetes.client.proto.Meta.ObjectMeta)1 OwnerReference (io.kubernetes.client.proto.Meta.OwnerReference)1 V1 (io.kubernetes.client.proto.V1)1