Bluemix, Watson, DevOps and more


How to build an application with Watson services on IBM Bluemix DevOps Services and deploy it on IBM Bluemix. The example application is up and running at https://um-java-ddc.mybluemix.net/demo.

The application shows how to use Watson services to analyse English text ( 100 words or more) to profile the text’s author. I had a blast comparing the results of texts I wrote 10 years ago with texts I wrote last year.

watson_personality_insights

To familiarize myself with the process I have started from a video tutorial made by Patrick Mueller for an application using the Personality Insights Watson service . You can find the slides for the tutorial here: http://pmuellr.github.io/slides/2015/02-java-intro-with-watson/#1

NOTE: Patrick’s tutorial and code uses the term User Modelling which is the former name of the Personality Insights service. There are also some slight changes in the API URL’s which required an update of the original code.

In this article I will basically annotate Patrick’s slides with my experience following his tutorial.

Setup

  1. Login/create an account on https://hub.jazz.net
  2. Use the Explore menu and search for um-java. You can use atrick’s kellydeployer|um-java project or you can use my fork dragos.cojocari|um-java-ddc.bluemix_UM_java
  3. Click “Fork the project” and select that you want to create a Bluemix project. Note that if you do not have a Bluemix account it will take around 2 days to have it created for you.

Code changes

  1. The first thing to do is to change the value of the host name in the manifest.yml file. The name must be unique since the host name is used in the app’s URL once deployed on Bluemix: http://<hostname&gt;.mybluemix.net

    Choose Edit Code from the main menu, select the manifest.yml from the root folder of the project and provide a unique value for the host name.

    um_manifest_yml

  2. Once you’ve completed the changes you must commit and push them to the code repository otherwise they will be ignored at build time.um_commit_changes
  3. (optional) If you have forked from Patrick’s project you also need to edit the DemoServlet.java file to use the new name of the Watson service. You can use my version of DemoServlet.java available here.

Build Pipeline

You are now ready to build and deploy. For this you need to create a pipeline which will handle these actions automatically. The build stage is responsible to create the war file from your source code.  The deploy stage will take the result of the build stage and deploy it on Bluemix.

You can run the build and deploy manually but that is not necessary. The build stage will be automatically triggered each time you push code changes and the deploy stage will be automatically triggered each time there is a new build.

  1. Click “Build&Deploy” to add a Build stage.  You can leave all options to their default values but you should provide a meaningful name for the stage.
  2. As part of the newly create stage add an Ant build job. Leave all options as generated with the exception of the “Working directory” property which needs to be cleared as with the default “Output” value the build will fail with an error that looks like this.
    Base artifact directory /home/jenkins/workspace/a99b5791-d7f4-54ee-6b7f-35775a122cc4/6273d3b5-4a26-40ce-9c7d-5360fa4a1c8d/output does not exist

    Credit for solving this goes to https://developer.ibm.com/answers/questions/163790/watson-user-modeling-java-boilerplate-does-not-bui.html

    um_build_stage

  3. The last piece is to setup the deployment of the application. Add a Deploy stage to the pipeline and create a deploy job for it. You do not need to change any of the values generated for you, just make sure that the value of the “Application name” property matches the value of the “name” ( not the host but the name) property in manifest.yml.um_deploy_stage

Test your application

You now have everything in place to run the application. Go to the “Build&Deploy” and make a request to start the build stage. Observe how the deploy stage is automatically triggered once the build stage completes successfully.  If the deployment succeeds you will see the URL of your application listed right there in the dashboard.

To test the automated build&deploy process you need to make a change in any of the source files. The easiest change to make is to the static text in index.jsp. Update some of the static text, commit and push the changes and then switch to the Build&Deploy tab to see the build running already.

um_pipeline

Conclusion

I hope this article demonstrates how easy it is to build applications on Bluemix using Bluemix services as the building blocks. There are many more interesting services available on Bluemix including an experimental RPE service. You can find the RPE service in the “Labs” section of the catalog (https://console.ng.bluemix.net/catalog/labs) and an example using the service is available on Github: https://github.com/dgaas/dgaas.example

rpe_bluemix_service

 

 

Advertisements

Author: Dragos Cojocari

Architect for Rational Publishing Engine

1 thought on “Bluemix, Watson, DevOps and more”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s