Replace the existing inference service :param name: existing inference service name :param inferenceservice: replacing inference service :param namespace: defaults to current or default namespace :param watch: True to watch the replaced service until timeout
(
self, name, inferenceservice, namespace=None, watch=False, timeout_seconds=600
)
| 269 | return outputs |
| 270 | |
| 271 | def replace( |
| 272 | self, name, inferenceservice, namespace=None, watch=False, timeout_seconds=600 |
| 273 | ): # pylint:disable=too-many-arguments,inconsistent-return-statements |
| 274 | """ |
| 275 | Replace the existing inference service |
| 276 | :param name: existing inference service name |
| 277 | :param inferenceservice: replacing inference service |
| 278 | :param namespace: defaults to current or default namespace |
| 279 | :param watch: True to watch the replaced service until timeout elapsed or status is ready |
| 280 | :param timeout_seconds: timeout seconds for watch, default to 600s |
| 281 | :return: replaced inference service |
| 282 | """ |
| 283 | |
| 284 | version = inferenceservice.api_version.split("/")[1] |
| 285 | |
| 286 | if namespace is None: |
| 287 | namespace = utils.get_isvc_namespace(inferenceservice) |
| 288 | |
| 289 | if inferenceservice.metadata.resource_version is None: |
| 290 | current_isvc = self.get(name, namespace=namespace) |
| 291 | current_resource_version = current_isvc["metadata"]["resourceVersion"] |
| 292 | inferenceservice.metadata.resource_version = current_resource_version |
| 293 | |
| 294 | try: |
| 295 | outputs = self.api_instance.replace_namespaced_custom_object( |
| 296 | constants.KSERVE_GROUP, |
| 297 | version, |
| 298 | namespace, |
| 299 | constants.KSERVE_PLURAL_INFERENCESERVICE, |
| 300 | name, |
| 301 | inferenceservice, |
| 302 | ) |
| 303 | except client.rest.ApiException as e: |
| 304 | raise RuntimeError( |
| 305 | "Exception when calling CustomObjectsApi->replace_namespaced_custom_object:\ |
| 306 | %s\n" |
| 307 | % e |
| 308 | ) |
| 309 | |
| 310 | if watch: |
| 311 | isvc_watch( |
| 312 | name=outputs["metadata"]["name"], |
| 313 | namespace=namespace, |
| 314 | timeout_seconds=timeout_seconds, |
| 315 | generation=outputs["metadata"]["generation"], |
| 316 | ) |
| 317 | else: |
| 318 | return outputs |
| 319 | |
| 320 | def delete(self, name, namespace=None, version=constants.KSERVE_V1BETA1_VERSION): |
| 321 | """ |