Sunday, December 13, 2009

Amazon Mechanical Turk Perl Library Error

I've been playing with Amazon Mechanical Turk for a project, and I think it's really, really powerful.  So far, I've done a bunch of research and some tests using the Requester UI, but have not yet dug into the API.  But, over the past few days, I've finally started my research and experimenation using the API directly.  However, my very first time trying to use the modules that Amazon published, I got a big error:

t/01-ListOperations.t ..................... Can't locate object method "new" via package "Net::Amazon::MechanicalTurk::Transport::RESTTransport" at /Users/dviner/.cpan/build/Net-Amazon-MechanicalTurk-1.01-1kIAvQ/blib/lib/Net/Amazon/MechanicalTurk/ line 21.

This error message was repeated a few dozen times.  Also, in searching for the problem, I found this StackOverflow issue: Perl module Net::Amazon::MechanicalTurk failing tests.

I find it pretty amazing that Amazon hasn't fixed this problem.  But, after doing a bunch of searching and sniffing around, I couldn't find any solution at all.

So, I made one of my own.  Here's a short patch that will allow the Net::Amazon::MechanicalTurk module pass all it's tests.  Most will be skipped with the message:

skipped: Configure Amazon AWS Authentication to enable tests against Mechanical Turk Sandbox

If you want to try to get those to verify, you must make a file named in the current directory.  In that file, you must list your access key and secret key as well as the turk service URL and API version you are using.  Here are the sample contents:

access_key: your-access-key
secret_key: your-secret-key
service_version: 2008-08-02

Note that even with this file in place, several of the tests still fail.  I'm not an expert on the Turk API (yet), so I'm not sure how to fix the other errors that occur.

But hopefully this patch will help people.  Feel free to contact me if you find additional changes that should be made to the library.


brian d foy said...

I saw your patch and applied it along with patches in RT. There's now an unauthorized release of the module in my author directory (BDFOY). I'll work to make this an official release after I see the CPAN Testers reports.

boourns said...

Worked for me, thanks for the fix.

For the TL/DR crew:

Download and untar Net-Amazon-MechanicalTurk-1.01 and this patch, change to that directory then do:

patch -p1 < net-amazon-mechanicalturk.patch

Then manually install the module:

perl Makefile.PL
make test
sudo make install

Hope this helps!

vish said...

worked for me

Alan Mead said...

Any chance you could re-post the patch. I'm getting the same problems in 2016 but the patch seems to have gone away.