diff --git a/examples/models/h2o_example/H2OModel.py b/examples/models/h2o_example/H2OModel.py index 8bea3ec596..db3a24be72 100644 --- a/examples/models/h2o_example/H2OModel.py +++ b/examples/models/h2o_example/H2OModel.py @@ -1,3 +1,4 @@ +from __future__ import print_function import numpy as np import h2o from h2o.frame import H2OFrame @@ -19,13 +20,13 @@ class H2OModel(): def __init__(self): - print 'Starting Java virtual machine' + print('Starting Java virtual machine') h2o.init(nthreads = -1, max_mem_size = 8) - print 'Machine started!' + print('Machine started!') - print 'Loading model from %s...' % MODEL_PATH + print('Loading model from %s...' % MODEL_PATH) self.model = h2o.load_model(MODEL_PATH) - print 'Model Loaded' + print('Model Loaded') def predict(self,X,feature_names): return _from_frame(self.model.predict(_to_frame(X,feature_names))) diff --git a/examples/models/sigmoid_predictor/SigmoidPredictor.py b/examples/models/sigmoid_predictor/SigmoidPredictor.py index 9691bb122b..dcedfe5ee9 100644 --- a/examples/models/sigmoid_predictor/SigmoidPredictor.py +++ b/examples/models/sigmoid_predictor/SigmoidPredictor.py @@ -1,3 +1,4 @@ +from __future__ import print_function import numpy as np from sklearn.neural_network import MLPClassifier @@ -15,6 +16,6 @@ def __init__(self): self.ffnn = MLPClassifier() self.ffnn.fit(X,y) - print "Class", self, "variables", dir(self) + print("Class", self, "variables", dir(self)) def predict(self,X,features_names): return self.ffnn.predict_proba(X) diff --git a/kafka/tests/src/read_predictions.py b/kafka/tests/src/read_predictions.py index 7f3f546544..c480e11d63 100644 --- a/kafka/tests/src/read_predictions.py +++ b/kafka/tests/src/read_predictions.py @@ -1,3 +1,4 @@ +from __future__ import print_function import os import sys, getopt, argparse import logging @@ -24,7 +25,7 @@ consumer.assign([partition]) consumer.seek(partition, 0) for msg in consumer: - print msg + print(msg) message = ppb.PredictionRequestResponseDef() message.ParseFromString(msg.value) - print message + print(message) diff --git a/util/loadtester/scripts/predict_rest_locust.py b/util/loadtester/scripts/predict_rest_locust.py index af611f83fd..578296f62d 100644 --- a/util/loadtester/scripts/predict_rest_locust.py +++ b/util/loadtester/scripts/predict_rest_locust.py @@ -1,3 +1,4 @@ +from __future__ import print_function from locust.stats import RequestStats from locust import HttpLocust, TaskSet, task, events import os @@ -43,9 +44,9 @@ def parse_arguments(): args, unknown = parser.parse_known_args() #args = parser.parse_args() opts = vars(args) - print args + print(args) if args.slave: - print "Sleeping 10 secs hack" + print("Sleeping 10 secs hack") time.sleep(10) connect_to_master(args.master_host,args.master_port) return args.host, args.clients, args.hatch_rate @@ -54,12 +55,12 @@ def parse_arguments(): rsrc = resource.RLIMIT_NOFILE soft, hard = resource.getrlimit(rsrc) -print 'RLIMIT_NOFILE soft limit starts as :', soft +print('RLIMIT_NOFILE soft limit starts as :', soft) #resource.setrlimit(rsrc, (65535, hard)) #limit to one kilobyte soft, hard = resource.getrlimit(rsrc) -print 'RLIMIT_NOFILE soft limit changed to :', soft +print('RLIMIT_NOFILE soft limit changed to :', soft) def getEnviron(key,default): if key in os.environ: @@ -72,19 +73,19 @@ class SeldonJsLocust(TaskSet): def get_token(self): - print "Getting access token" + print("Getting access token") r = self.client.request("POST","/oauth/token",headers={"Accept":"application/json"},data={"grant_type":"client_credentials"},auth=(self.oauth_key,self.oauth_secret)) if r.status_code == 200: j = json.loads(r.content) self.access_token = j["access_token"] - print "got access token "+self.access_token + print("got access token "+self.access_token) else: - print "failed to get access token" + print("failed to get access token") sys.exit(1) def on_start(self): - print "on_start" + print("on_start") self.oauth_enabled = getEnviron('OAUTH_ENABLED',"true") self.oauth_key = getEnviron('OAUTH_KEY',"key") self.oauth_secret = getEnviron('OAUTH_SECRET',"secret") @@ -109,7 +110,7 @@ def sendFeedback(self,response): else: self.routeRewards[route] = 0.5 rewardProba = self.routeRewards[route] - print route,rewardProba + print(route,rewardProba) if random()>rewardProba: j = {"response":response,"reward":1.0} else: @@ -117,12 +118,12 @@ def sendFeedback(self,response): jStr = json.dumps(j) r = self.client.request("POST",self.path_prefix+"/api/v0.1/feedback",headers={"Content-Type":"application/json","Accept":"application/json","Authorization":"Bearer "+self.access_token},name="feedback",data=jStr) if not r.status_code == 200: - print "Failed feedback request "+str(r.status_code) + print("Failed feedback request "+str(r.status_code)) if r.status_code == 401: if self.oauth_enabled == "true": self.get_token() else: - print r.headers + print(r.headers) r.raise_for_status() @@ -138,12 +139,12 @@ def getPrediction(self): j = json.loads(r.content) self.sendFeedback(j) else: - print "Failed prediction request "+str(r.status_code) + print("Failed prediction request "+str(r.status_code)) if r.status_code == 401: if self.oauth_enabled == "true": self.get_token() else: - print r.headers + print(r.headers) r.raise_for_status() class WebsiteUser(HttpLocust):