NYUCCL / psiTurk

An open platform for science on Amazon Mechanical Turk.
https://psiturk.org
MIT License
277 stars 140 forks source link

Figure out why `hit extend` is throwing an exception #72

Closed jbmartin closed 10 years ago

jbmartin commented 10 years ago

Adding workers to an active HIT throws an exception and doesn't fail gracefully. Looking at the exception it appears that AMT isn't recognizing the HIT ID provided by hit list active.

[psiTurk server:off mode:live HITs:1]$ hit extend [hitid] --assignments 2
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/cmd2-0.6.7-py2.7.egg/cmd2.py", line 782, in onecmd_plus_hooks
    stop = self.onecmd(statement)
  File "/Library/Python/2.7/site-packages/cmd2-0.6.7-py2.7.egg/cmd2.py", line 865, in onecmd
    stop = func(statement)
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PsiTurk-1.0.5dev-py2.7.egg/psiturk/psiturk_shell.py", line 76, in fn
    return func(self, opt)
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PsiTurk-1.0.5dev-py2.7.egg/psiturk/psiturk_shell.py", line 1031, in do_hit
    self.hit_extend(arg['<HITid>'], arg['--assignments'], arg['--expiration'])
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PsiTurk-1.0.5dev-py2.7.egg/psiturk/psiturk_shell.py", line 266, in hit_extend
    self.amt_services.extend_hit(hitID, assignments, time)
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PsiTurk-1.0.5dev-py2.7.egg/psiturk/amt_services.py", line 436, in extend_hit
    self.mtc.extend_hit(hitid, assignments_increment=int(assignments_increment or 0))
  File "/Library/Python/2.7/site-packages/boto/mturk/connection.py", line 545, in extend_hit
    return self._process_request('ExtendHIT', params)
  File "/Library/Python/2.7/site-packages/boto/mturk/connection.py", line 821, in _process_request
    return self._process_response(response, marker_elems)
  File "/Library/Python/2.7/site-packages/boto/mturk/connection.py", line 836, in _process_response
    raise MTurkRequestError(response.status, response.reason, body)
MTurkRequestError: MTurkRequestError: 200 OK
<?xml version="1.0"?>
<ExtendHITResponse><OperationRequest><RequestId>c31824a2-eae7-4339-be49-3e11e82252a3</RequestId></OperationRequest><ExtendHITResult><Request><IsValid>False</IsValid><Errors><Error><Code>AWS.MechanicalTurk.HITDoesNotExist</Code><Message>Hit ['***'] does not exist. (1390264567697)</Message><Data><Key>HITId</Key><Value>['***']</Value></Data><Data><Key>HITId</Key><Value>['***']</Value></Data></Error></Errors></Request></ExtendHITResult></ExtendHITResponse>
MTurkRequestError: 200 OK
<?xml version="1.0"?>
<ExtendHITResponse><OperationRequest><RequestId>c31824a2-eae7-4339-be49-3e11e82252a3</RequestId></OperationRequest><ExtendHITResult><Request><IsValid>False</IsValid><Errors><Error><Code>AWS.MechanicalTurk.HITDoesNotExist</Code><Message>Hit ['***'] does not exist. (1390264567697)</Message><Data><Key>HITId</Key><Value>['***']</Value></Data><Data><Key>HITId</Key><Value>['***']</Value></Data></Error></Errors></Request></ExtendHITResult></ExtendHITResponse>

*Note, HIT IDs have been obfuscated.

jbmartin commented 10 years ago

Commit 2b7bb6bda73ed6a2d506ffff7530ec45b4b72862 closes #72

jbmartin commented 10 years ago

The patch above only works with a single HIT, but probably a good idea to generalize it to any number of HITS.