Archive for December, 2008

Simple Python code for Amazon EC2

Back in October I started playing with Amazon’s elastic compute cloud.  My basic goal was to do some distributed computing with Python.  Thanks to Amazon’s documentation and helpful writeups by some early adopters, I was able to get my environment setup and to get my head around the various command line incantations.  I quickly grew tired of repeatedly having to input the image and instance IDs on the command line.

I wanted a pythonic way of starting up instances, querying their status, and doing simple things like running a command on all of my instances.  I figured a pythonic EC2 framework would make it easier for me to interface with whatever distributed computing framework I chose.  Also, I like python.

I wrote a class, EC2Controller, that uses Amazon’s Ec2.py module to simplify several common operations.  I’ve posted the code to a Google Code project, ec2python, which can be found at http://code.google.com/p/ec2python/.  I suspect some or all of the functionality is implemented in the boto project, but I haven’t taken the time to investigate.

Here’s an example of how I use EC2Controller from ipython:

In [1]: import EC2Controller as EC2

In [2]: ec2 = EC2.EC2Controller(cluster_size=2, verbose=True)

In [3]: ec2.getInstances()
Out[3]: []

In [4]: ec2.startCluster()
startCluster.  Query for the current instances.
Starting 2 instances...

In [5]: ec2.getInstances()
Out[5]:
[
EC2Instance( instance ID: i-d73389be
             state:       pending
             image:       ami-ee2eca87
             public  DNS:
             private DNS:  ),

EC2Instance( instance ID: i-d63389bf
             state:       pending
             image:       ami-ee2eca87
             public  DNS:
             private DNS:  )]

In [6]: ec2.waitUntilAllAreRunning()
Out[6]: True

In [7]: ec2.getInstances()
Out[7]:
[
EC2Instance( instance ID: i-d73389be
             state:       running
             image:       ami-ee2eca87
             public  DNS: ec2-75-101-212-146.compute-1.amazonaws.com
             private DNS: domU-12-31-39-00-54-E1.compute-1.internal ),

EC2Instance( instance ID: i-d63389bf
             state:       running
             image:       ami-ee2eca87
             public  DNS: ec2-174-129-150-216.compute-1.amazonaws.com
             private DNS: domU-12-31-39-00-B0-67.compute-1.internal )]

In [8]: ec2.stopCluster()
stopCluster.  Query for the current instances.
Terminate these instances: '['i-d73389be', 'i-d63389bf']'

I hope somebody finds the code useful.

Comments (2)

Malcolm Gladwell’s Outliers

Enticed by the buzz, I read Malcolm Gladwell’s Outliers.  In this short book, Gladwell gives his perspective on several events that are significantly outside the norm.  He moves from hockey stars to billionaires to pilots to math students.  Using these examples, he asserts that most people overlook the fortuitous timing and hard work that underlies the exceptional results.

On it’s own, this thesis isn’t new or exciting.  I know several wildly successful people who needed both good timing and hard work to make their fortunes.  And whether they made their millions on the internet, at the poker table, or on Wall Street, those people will happily admit that they needed luck and hard work.  Come to think of it, I don’t know anybody (successful or not) who doesn’t recognize the need to combine good timing with hard work in order to succeed.  In that sense, I don’t know who Gladwell is targeting.

That said, I did enjoy the book because I learned something.  Gladwell supported his argument with facts that were new to me.  I didn’t know most hockey players are born in the first few months of the year.  I didn’t know about the cultural conventions between a Korean Captain and First Officer.  I enjoyed reading statistics on the disparate effect summer vacation has on rich and poor grade school students.  What’s better, Gladwell does a good job of linking all of his examples together.  The story flows.

I think Gladwell’s argument works best in the broad cases of hockey players or math students.  It’s overly simplistic when applied to successful individuals like Bill Joy.  Sure, Bill Joy was born at the right time and worked tirelessly.  If he were born a few years earlier or later, he certainly wouldn’t have achieved the same success.  Even so, Bill Joy is a special genius.  When you hear him talk or see his work, you know there’s no way to hold him back.  He possesses a special mind perfectly tuned for his time and place in history.  I wish Gladwell gave such special individual talent more credance.

Leave a Comment

A few suggested features for TVs

The holidays are prime time to watch people without technical acumen wrestle with new toys.  Working from some of these observations, I have some suggestions for typical TV setups.  The average person who buys a new TV has nothing more than a TV connected to a cable box, plus a couple other auxiliary devices such as a DVD player or game system.

First, all televisions should have a “just show me something” button.  I’ve seen several people with nothing more than a cable box hooked up to their TV be absolutely bamboozeld by an accidental switch of inputs.  They’ll say “I don’t know, the screen’s blank.”  Perhaps they might add in “should I be on channel 3?”  (What a great old frequency modulation chestnut.)  When the screen is blank, their mind freezes.

People in this situation need a hail mary option.  They need a big emergency button on their remote, similar to the hazard light button in cars.  In the worst case the TV will tune over to a DVD player, but at least there’s a picture which should be sufficiently calming to restart their facilities for rational thought.

Second, the TV should have an undo button with a large buffer.  When a user presses a button that causes trouble, he or she typically has no idea how to revert the change.  It seems simple enough to add a souped up “last channel” button that will step backward through a large number of changes, including input changes.

Finally, it should be possible to lock in a known good state.  I suppose this combines undo with the emergency button.  This would allow a user to reset the tv, including input settings and channel to whatever worked well for them last.

Leave a Comment

Follow

Get every new post delivered to your Inbox.