# turn into predictions with open('submission.csv') as fh: lines = fh.readlines()[1:] # ignore first line preds = [line.strip().split(',')[1] for line in lines] return preds # pickle function and write to appropriate location s = six.StringIO() c = CloudPickler(s, 2) c.dump(libffm) serialized_prediction_function = s.getvalue() filepath = 'docker/lib/func.pkl' with open(filepath, 'w') as fh: fh.write(serialized_prediction_function) # refresh creds os.system('gcloud container clusters get-credentials redis-cluster') os.system('kubectl cluster-info') clipper_conn = ClipperConnection(KubernetesContainerManager(clipper_ip, useInternalIP=True)) clipper_conn.connect() # Build model and deploy to clipper version = int(time.time()) clipper_conn.build_and_deploy_model('ffm', version, 'strings', 'docker/lib', 'clipper/python-closure-container:develop', container_registry='ryanhoque') # Uncomment the following if first time #clipper_conn.link_model_to_app(app_name="testbed", model_name="ffm") # finally deploy new version of model to clipper (set version as timestamp) print('Successfully deployed model ffm version ' + str(version) + ' to Clipper.')
import sys sys.path.insert(0, '/Users/xunzhang/Desktop/2018/github/clipper/clipper_admin/') import tensorflow as tf from clipper_admin import ClipperConnection, DockerContainerManager from clipper_admin.deployers.tensorflow import deploy_tensorflow_model cur_dir = os.path.dirname(os.path.abspath(__file__)) app_name = "tf-lr-app" model_name = "tf-lr-model" if __name__ == "__main__": clipper_conn = ClipperConnection(DockerContainerManager()) clipper_conn.stop_all() clipper_conn.start_clipper() clipper_conn.register_application(name=app_name, input_type="integers", default_output="rabbit", slo_micros=100000) print(os.path.abspath("data")) clipper_conn.build_and_deploy_model( name=model_name, version=1, input_type="integers", model_data_path=os.path.abspath("data"), base_image="xunzhang/tf_lr_container:latest", num_replicas=1) clipper_conn.link_model_to_app(app_name, model_name) print(clipper_conn.get_clipper_logs())