Python 3 support
Project: http://git-wip-us.apache.org/repos/asf/incubator-predictionio-template-ecom-recommender/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-predictionio-template-ecom-recommender/commit/b755c31f Tree: http://git-wip-us.apache.org/repos/asf/incubator-predictionio-template-ecom-recommender/tree/b755c31f Diff: http://git-wip-us.apache.org/repos/asf/incubator-predictionio-template-ecom-recommender/diff/b755c31f Branch: refs/heads/master Commit: b755c31fa4b896ff219fca74361f6d22081c5d18 Parents: 6ef7c9b Author: Shinsuke Sugaya <[email protected]> Authored: Tue Jun 6 19:27:05 2017 +0900 Committer: Shinsuke Sugaya <[email protected]> Committed: Tue Jun 6 19:27:05 2017 +0900 ---------------------------------------------------------------------- data/import_eventserver.py | 16 ++++++++-------- data/send_query.py | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-predictionio-template-ecom-recommender/blob/b755c31f/data/import_eventserver.py ---------------------------------------------------------------------- diff --git a/data/import_eventserver.py b/data/import_eventserver.py index 5c49837..e8010ca 100644 --- a/data/import_eventserver.py +++ b/data/import_eventserver.py @@ -11,13 +11,13 @@ SEED = 3 def import_events(client): random.seed(SEED) count = 0 - print client.get_status() - print "Importing data..." + print(client.get_status()) + print("Importing data...") # generate 10 users, with user ids u1,u2,....,u10 user_ids = ["u%s" % i for i in range(1, 11)] for user_id in user_ids: - print "Set user", user_id + print("Set user", user_id) client.create_event( event="$set", entity_type="user", @@ -30,7 +30,7 @@ def import_events(client): categories = ["c%s" % i for i in range(1, 7)] item_ids = ["i%s" % i for i in range(1, 51)] for item_id in item_ids: - print "Set item", item_id + print("Set item", item_id) client.create_event( event="$set", entity_type="item", @@ -44,7 +44,7 @@ def import_events(client): # each user randomly viewed 10 items for user_id in user_ids: for viewed_item in random.sample(item_ids, 10): - print "User", user_id ,"views item", viewed_item + print("User", user_id ,"views item", viewed_item) client.create_event( event="view", entity_type="user", @@ -55,7 +55,7 @@ def import_events(client): count += 1 # randomly buy some of the viewed items if random.choice([True, False]): - print "User", user_id ,"buys item", viewed_item + print("User", user_id ,"buys item", viewed_item) client.create_event( event="buy", entity_type="user", @@ -65,7 +65,7 @@ def import_events(client): ) count += 1 - print "%s events are imported." % count + print("%s events are imported." % count) if __name__ == '__main__': parser = argparse.ArgumentParser( @@ -74,7 +74,7 @@ if __name__ == '__main__': parser.add_argument('--url', default="http://localhost:7070") args = parser.parse_args() - print args + print(args) client = predictionio.EventClient( access_key=args.access_key, http://git-wip-us.apache.org/repos/asf/incubator-predictionio-template-ecom-recommender/blob/b755c31f/data/send_query.py ---------------------------------------------------------------------- diff --git a/data/send_query.py b/data/send_query.py index b0eb651..df7f624 100644 --- a/data/send_query.py +++ b/data/send_query.py @@ -4,4 +4,4 @@ Send sample query to prediction engine import predictionio engine_client = predictionio.EngineClient(url="http://localhost:8000") -print engine_client.send_query({"user": "u1", "num": 4}) +print(engine_client.send_query({"user": "u1", "num": 4}))
