Example #1
0
    def deploy_spec(self, model_spec: ModelSpec):
        self._create_api_client()
        env_api = EnvironmentApi(self.api_client)
        user = env_api.read_user()

        print(user)

        # TODO: Use KubernetesSpec().spec
        sd = SeldonDeployment(
            kind="SeldonDeployment",
            api_version="machinelearning.seldon.io/v1",
            metadata=ObjectMeta(
                name=model_spec.model_details.name,
                namespace=model_spec.runtime_options.namespace,  # type: ignore
            ),
            spec=SeldonDeploymentSpec(predictors=[
                PredictorSpec(
                    graph=PredictiveUnit(
                        implementation=KubernetesSpec.Implementations[
                            model_spec.model_details.platform],
                        model_uri=model_spec.model_details.uri,
                        name="model",
                    ),
                    name="default",
                    replicas=model_spec.runtime_options.
                    replicas,  # type: ignore
                )
            ]),
        )

        dep_instance = SeldonDeploymentsApi(self.api_client)
        dep_instance.create_seldon_deployment(
            model_spec.runtime_options.namespace, sd)  # type: ignore
Example #2
0
 def undeploy_spec(self, model_spec: ModelSpec):
     self._create_api_client()
     dep_instance = SeldonDeploymentsApi(self.api_client)
     dep_instance.delete_seldon_deployment(
         model_spec.model_details.name,
         model_spec.runtime_options.k8s_options.namespace,
         _preload_content=False)
Example #3
0
 def deploy(self, model_details: ModelDetails):
     # TODO: Use KubernetesSpec().spec
     sd = SeldonDeployment(
         kind="SeldonDeployment",
         api_version="machinelearning.seldon.io/v1",
         metadata=ObjectMeta(
             name=model_details.name, namespace=self._k8s_options.namespace
         ),
         spec=SeldonDeploymentSpec(
             predictors=[
                 PredictorSpec(
                     graph=PredictiveUnit(
                         implementation=KubernetesSpec.Implementations[
                             model_details.platform
                         ],
                         model_uri=model_details.uri,
                         name="model",
                     ),
                     name="default",
                     replicas=self._k8s_options.replicas,
                 )
             ]
         ),
     )
     api_client = self._get_api_client()
     dep_instance = SeldonDeploymentsApi(api_client)
     created = dep_instance.create_seldon_deployment(self._k8s_options.namespace, sd)
Example #4
0
 def wait_ready(self, model_details: ModelDetails, timeout_secs=None) -> bool:
     ready = False
     t0 = time.time()
     api_client = self._get_api_client()
     dep_instance = SeldonDeploymentsApi(api_client)
     while not ready:
         sdep: SeldonDeployment = dep_instance.read_seldon_deployment(
             model_details.name, self._k8s_options.namespace
         )
         sdep_dict = sdep.to_dict()
         ready = sdep_dict["status"]["state"] == "Available"
         if timeout_secs is not None:
             t1 = time.time()
             if t1 - t0 > timeout_secs:
                 return ready
     return ready
Example #5
0
 def wait_ready_spec(self,
                     model_spec: ModelSpec,
                     timeout_secs=None) -> bool:
     self._create_api_client()
     ready = False
     t0 = time.time()
     dep_instance = SeldonDeploymentsApi(self.api_client)
     while not ready:
         sdep: SeldonDeployment = dep_instance.read_seldon_deployment(
             model_spec.model_details.name,
             model_spec.runtime_options.k8s_options.namespace)
         sdep_dict = sdep.to_dict()
         ready = sdep_dict["status"]["state"] == "Available"
         if timeout_secs is not None:
             t1 = time.time()
             if t1 - t0 > timeout_secs:
                 return ready
     return ready
Example #6
0
 def undeploy(self, model_details: ModelDetails):
     api_client = self._get_api_client()
     dep_instance = SeldonDeploymentsApi(api_client)
     dep_instance.delete_seldon_deployment(model_details.name,
                                           self._k8s_options.namespace,
                                           _preload_content=False)