Taxi demo with Ad API
This document contains the steps required to configure, build and deploy coupon service (Ad Service) into GAE
-
Make sure Java 8 is installed and JAVA_HOME is set in environment
-
Make sure maven is installed and added in PATH
-
Make sure gcloud is installed and project is set to **"**billion-taxi-rides"
-
Open terminal or command prompt and execute "**git clone ****https://github.com/springml/nycity_taxi_ad_ap**i"
-
cd nycity_taxi_ad_api/nycity_taxi_ad_api_java
-
To build coupon service execute "mvn clean package"
-
To run coupon service locally execute "java -jar target/nycity-taxi-ad-api-1.0.0.jar"
-
To deploy coupon service into GAE execute "mvn appengine:deploy". Rest service can be accessed using https://coupon-service-dot-billion-taxi-rides.appspot.com/getCoupon
-
By default service is set to **coupon-service. **You can change it in /nycity_taxi_ad_api/nycity_taxi_ad_api_java/src/main/appengine/app.yaml
-
Additional configurations related to GAE environment has to be done in /nycity_taxi_ad_api/nycity_taxi_ad_api_java/src/main/appengine/app.yaml
-
By default coupon-service uses CloudML from **billion-taxi-rides. **This can be changed by providing the CloudML REST url in **cloudML.predict.rest.url **property in /nycity_taxi_ad_api/nycity_taxi_ad_api_java/src/main/resources/application.properties
-
For any changes in coupon discount mapping, edit the file present in /nycity_taxi_ad_api/nycity_taxi_ad_api_java/src/main/resources/coupon-discount.properties
**Note:- **Any changes in configuration will be reflected only when the app is rebuilt and redeployed in to GAE.
-
Install and open any REST client like Postman or Advanced REST Client…
-
Use the POST method
-
Use the URL https://coupon-service-dot-billion-taxi-rides.appspot.com/getCoupon. Please make sure to change the service is same as you’ve provided in app.yaml
-
Add the "Content-Type" header with “application/json” as value
-
Use the below json content as body
{
-
"passenger_count":2,*
-
"tpep_pickup_datetime":"2015-01-04 20:06:55",*
-
"pickup_latitude":"40.751056671142578",*
-
"pickup_longitude":"-73.994209289550781",*
-
"dropoff_latitude":"40.749996185302734",*
-
"dropoff_longitude":"-73.97900390625"*
}
- On executing the above request you will get a response like below
{
-
"couponId": 9,*
-
"discount": "12%"*
}
-
Login into Google Cloud Console and select Google Compute Engine from the menu
-
Click on the "SSH" dropdown adjacent to “coupon-service-injector” VM and click “Open in browser window”
-
In terminal switch to root user using sudo su -
-
cd nycity_taxi_ad_api/injector/
-
Edit config_without_docker.sh if you need to increase the speed or change any other configuration
-
Execute source config_without_docker.sh
-
Execute *go run .go
-
Login into Google Cloud Console and select Google Compute Engine from the menu
-
Click on the "SSH" dropdown adjacent to “ coupon-service-simulator” VM and click “Open in browser window”
-
In terminal switch to root user using sudo su -
-
cd dataflow/nycity_taxi_ad_api/coupon_service_simulator/
-
Execute mvn clean compile exec:java -Dexec.mainClass=com.springml.coupon.service.simulator.CouponServiceGDF -e -Dexec.args="--project=billion-taxi-rides --stagingLocation=gs://sml/staging --runner=DataflowPipelineRunner --streaming=true --numWorkers=20 --zone=us-west1-b --couponServiceUrl=https://demo5-test.apigee.net/v1/coupon --apiKey=API_KEY"
-
Login into Google Cloud Console and select Google Compute Engine from the menu
-
Click on the "SSH" dropdown adjacent to “ coupon-service-simulator” VM and click “Open in browser window”
-
In terminal switch to root user using sudo su -
-
cd scheduler-demo/nycity_taxi_ad_api/nycity_taxi_ad_scheduler/
-
Execute java -jar target/nycity-taxi-ad-scheduler-1.0-SNAPSHOT.jar
We have to start injector and dataflow.
To start dataflow follow below steps
-
Start sml-tax-dataflow compute-engine and ssh into it
-
sudo su -
-
cd work/dataflow_nyc_taxis_next17_visupipe/dataflow/
-
mvn clean compile exec:java -Dexec.mainClass=com.springml.TaxiGDF -e -Dexec.args="--project=billion-taxi-rides --sinkProject=billion-taxi-rides --stagingLocation=gs://billion-taxi-rides/df-staging/ --runner=DataflowPipelineRunner --streaming=true --numWorkers=1 --zone=us-west1-b"
-
Check whether the stop successfully started by navigating to https://console.cloud.google.com/dataflow?project=billion-taxi-rides
To start injector follow below steps
-
Start next17keynote-injector compute-engine and ssh into it
-
sudo su -
-
cd nycity_taxi_ad_api/injector/
-
source config_without_docker.bash
-
go run *.go
SpringML contact: mayank.sharma@springml.com
Google Contact : alankho@google.com
Link to Presentation : https://docs.google.com/presentation/d/1Yc7eZ-CkHmsyxWAOHHGFt5q_llA5nyYv1vWlvbjeA_g/edit#slide=id.g2072fb2c8a_0_0
Link to Demo Script : https://docs.google.com/document/d/1xvFpnJTPJKtdI2JSr6RHzQDviPnfEcA-oNa5Tr_QaS8/edit#