Cloud Foundry logo in white on a blue background
blog single gear
App Dev

100-day Challenge #023: Running IPython Notebook on Cloud Foundry

Translator’s note: This is the 7th article of the series “Cloud Foundry 100-day Challenge selection”. “#023” in the title means that it is 23rd (published on July 06, 2015) in the original Japanese series.

Original Author: Takehiko AMANO  (Twitter)  (blog)

The 23rd topic of “Cloud Foundry 100-Day Challenge” is IPython Notebook.

Recently, we are increasingly hearing buzzes about a job called “data scientist”, and phrases like “Baye’s theorem” seem to be thrown around more and more.

The R language, Python, etc. are being used for scientific computing, and I had been interested in SciPy for some time. Although I have been thinking that it would be a useful tool in building my career, I have been procrastinating. I have been hearing that IPython Notebook is being used increasingly, especially among data scientists. Although the way to operate IPython with Bluemix is widely known (see link), it has always seemed quite complicate. However, I found an easier way to do it, so I would like to share my findings with you.

Basic Information

  • Official site
  • Source code (buildpack)
  • References


Deploying Application

1. No retrieval of source

This method requires only the buildpack. How wonderful it is to be able to deploy an application only with the buildpack.

2. Deploying the application

Since the buildpack to be used does not seem to include mathematical modules by default, enter additional modules in the requirements.txt file.

$ cat requirements.txt

Having done that, let’s start deployment on Cloud Foundry. Here, I have used Bluemix.

$ cf push amntip -b -m 512M

requested state: started
instances: 1/1
usage: 512M x 1 instances
last uploaded: Wed Jul 1 07:14:35 UTC 2015
stack: lucid64

     state     since                    cpu    memory           disk
#0   running   2015-07-01 04:17:11 PM   0.0%   119.3M of 512M   254.4M of 1G

Cloud Foundry’s buildpack is utilized to build the operating environment, and it is common for the user to provide source files and binary on top of that.

However, we can also install the application itself, like I did here. The compile script of the buildpack is the script that installs the software, but in taking a look at the buildpack’s compile script in this example, I see that it isn’t too complicated. It is written just as if a user would normally write installation scripts. This is the type of freedom that is characteristic of Cloud Foundry. In a way, it could be easier than writing Docker scripts.

And now, let us try it out.

Checking Application Behavior

Let’s start with the usual greeting, “Hello World”!. Please push the New button and select Python 2 from the drop-down.

Enter print "Hello" to the In section, and let it run.

… then I got a Hello output.

Now let’s also try plotting; Please enter and run the following command.

%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 3*np.pi, 500)
plt.plot(x, np.sin(x**2))
plt.title('A simple chirp');

… and the following output should be displayed.

On the presentation slides (Translator’s note: slide #14) in the link under the References section, Mr. Ian Huston mentions there are the following benefits for data scientists:

– Easy to get web apps up and running
– Create and bind to your favourite data services
– Don’t get locked in to one cloud provider
– Python is officially supported

There definitely is a benefit in, for example, being able to get your hands on IPython’s operating environment in a matter of minutes when you want to run a few calculations.


It should be noted that we were only able to run the application in this occasion, and that we could not get too far into testing the application in various ways. The difficulty of learning a skillset is really hitting home, but as they say, the journey of a thousand miles begins with a single step. I now have an environment that is easy to operate, so I will find the time to hone my skills.



The Environment Used in This Post

  • cf-release Bluemix (v210)
  • IPython Notebook buildpack