Skip to content
Permalink
Browse files

adding action as an input, and pinning versions

  • Loading branch information...
animeshsingh committed Aug 22, 2019
1 parent caa9d6d commit 23e34fcf186bd090b3e7cf1492b4dd24f2e67dfa
@@ -1,11 +1,11 @@
name: Kubeflow - Serve Model using KFServing
description: Serve Models using Kubeflow KFServing
inputs:
- {name: Action, type: String, default: 'create', description: 'Action to execute on KFServing'}
- {name: Model Name, type: String, default: '', description: 'Name to give to the deployed model'}
- {name: Default Model URI, type: String, description: 'Path of the S3 or GCS compatible directory containing default model.'}
- {name: Canary Model URI, type: String, default: '', description: 'Optional Path of the S3 or GCS compatible directory containing canary model.'}
- {name: Canary Model Traffic Percentage, type: String, default: '0', description: 'Optional Traffic to be sent to default model'}
- {name: PVC name, type: String, default: '', description: 'Optional PersistentVolumeClaim to use.'}
- {name: Namespace, type: String, default: 'kubeflow', description: 'Kubernetes namespace where the KFServing service is deployed.'}
- {name: Framework, type: String, default: 'tensorflow', description: 'Machine Learning Framework for Model Serving.'}
outputs:
@@ -16,11 +16,11 @@ implementation:
command: ['python']
args: [
-u, kfservingdeployer.py,
--action, {inputValue: Action},
--model-name, {inputValue: Model Name},
--default-model-uri, {inputValue: Default Model URI},
--canary-model-uri, {inputValue: Canary Model URI},
--canary-model-traffic, {inputValue: Canary Model Traffic Percentage},
--pvc-name, {inputValue: PVC name},
--namespace, {inputValue: Namespace},
--framework, {inputValue: Framework},
--output_path, {outputPath: Endpoint URI}
@@ -1,6 +1,6 @@
FROM python:3.6-slim

RUN pip install kubernetes kfserving requests
RUN pip install kubernetes==9.0.0 kfserving==0.1.1 requests==2.22.0

ENV APP_HOME /app
COPY src $APP_HOME
@@ -50,16 +50,17 @@ def ModelSpec(framework, model_uri):

if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--action', type=str, help='Action to execute on KFServing', default='create')
parser.add_argument('--model-name', type=str, help='Name to give to the deployed model', default="")
parser.add_argument('--default-model-uri', type=str, help='Path of the S3, GCS or PVC directory containing default model.')
parser.add_argument('--canary-model-uri', type=str, help='Optional path of the S3, GCS or PVC directory containing canary model.', default="")
parser.add_argument('--canary-model-traffic', type=str, help='Optional Traffic to be sent to the default model', default='0')
parser.add_argument('--pvc-name', type=str, help='Optional PersistentVolumeClaim to use.', default="")
parser.add_argument('--namespace', type=str, help='Kubernetes namespace where the KFServing service is deployed.', default='kubeflow')
parser.add_argument('--framework', type=str, help='Model Serving Framework', default='tensorflow')
parser.add_argument('--output_path', type=str, help='Path to store URI output')
args = parser.parse_args()

action = args.action.lower()
model_name = args.model_name
default_model_uri = args.default_model_uri
canary_model_uri = args.canary_model_uri
@@ -87,14 +88,15 @@ def ModelSpec(framework, model_uri):
metadata=metadata,
spec=V1alpha1KFServiceSpec(default=default_model_spec))
KFServing = KFServingClient()
#TODO: Implement patch update once #277 issue is resolved
try:
KFServing.get(model_name, namespace=namespace)
KFServing.delete(model_name, namespace=namespace)
KFServing.create(kfsvc)
# KFServing.patch(model_name, kfsvc)
except:

if action == 'create':
KFServing.create(kfsvc)
elif action == 'update':
KFServing.patch(model_name, kfsvc)
elif action == 'delete':
return V1alpha1ModelSpec(sklearn=V1alpha1SKLearnSpec(model_uri=model_uri))
else:
raise("Error: No matching action: " + action)

model_status = KFServing.get(model_name, namespace=namespace)
print(model_status)
@@ -22,25 +22,25 @@
description='A pipeline for kfserving.'
)
def kfservingPipeline(
action = 'create',
model_name='tensorflow-sample',
default_model_uri='gs://kfserving-samples/models/tensorflow/flowers',
canary_model_uri='gs://kfserving-samples/models/tensorflow/flowers',
canary_model_traffic_percentage='10',
pvc_name='',
namespace='kubeflow',
framework='tensorflow'
):

# define workflow
kfserving = kfserving_op(model_name=model_name,
kfserving = kfserving_op(action = action,
model_name=model_name,
default_model_uri=default_model_uri,
canary_model_uri=canary_model_uri,
canary_model_traffic_percentage=canary_model_traffic_percentage,
pvc_name=pvc_name,
namespace=namespace,
framework=framework)


if __name__ == '__main__':
import kfp.compiler as compiler
compiler.Compiler().compile(kfservingPipeline, __file__ + '.tar.gz')

0 comments on commit 23e34fc

Please sign in to comment.
You can’t perform that action at this time.