Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if framework != 'custom' and default_model_uri:
default_model_spec = EndpointSpec(framework, default_model_uri)
elif framework == 'custom' and default_custom_model_spec:
default_model_spec = customEndpointSpec(default_custom_model_spec)
# Create Canary deployment if canary model uri is provided.
if framework != 'custom' and canary_model_uri:
canary_model_spec = EndpointSpec(framework, canary_model_uri)
kfsvc = InferenceService(metadata, default_model_spec, canary_model_spec, canary_model_traffic)
elif framework == 'custom' and canary_custom_model_spec:
canary_model_spec = customEndpointSpec(canary_custom_model_spec)
kfsvc = InferenceService(metadata, default_model_spec, canary_model_spec, canary_model_traffic)
else:
kfsvc = InferenceService(metadata, default_model_spec)
KFServing = KFServingClient()
if action == 'create':
KFServing.create(kfsvc, watch=True, timeout_seconds=120)
elif action == 'update':
KFServing.patch(model_name, kfsvc)
elif action == 'rollout':
KFServing.rollout_canary(model_name, canary=canary_model_spec, percent=canary_model_traffic, namespace=namespace, watch=True, timeout_seconds=120)
elif action == 'promote':
KFServing.promote(model_name, namespace=namespace, watch=True, timeout_seconds=120)
elif action == 'delete':
KFServing.delete(model_name, namespace=namespace)
else:
raise("Error: No matching action: " + action)
model_status = KFServing.get(model_name, namespace=namespace)
return model_status