[ARVADOS] updated: 9d9cb6334db6d7c6b81d3640fc0237ba2121a988

git at public.curoverse.com git at public.curoverse.com
Sat Aug 15 19:44:19 EDT 2015


Summary of changes:
 sdk/python/arvados/__init__.py | 18 ++++++++++++++----
 sdk/python/tests/test_init.py  | 13 +++++++++----
 2 files changed, 23 insertions(+), 8 deletions(-)

       via  9d9cb6334db6d7c6b81d3640fc0237ba2121a988 (commit)
      from  c0aa6085ccfb5de315b834e9994dfbc1a6269a05 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 9d9cb6334db6d7c6b81d3640fc0237ba2121a988
Author: Bryan Cosca <bcosc at curoverse.com>
Date:   Sat Aug 15 19:32:29 2015 -0400

    6600: Can throw HttpError and ApiError in unit tests

diff --git a/sdk/python/arvados/__init__.py b/sdk/python/arvados/__init__.py
index ec065d9..f3a6da1 100644
--- a/sdk/python/arvados/__init__.py
+++ b/sdk/python/arvados/__init__.py
@@ -17,6 +17,7 @@ import zlib
 import fcntl
 import time
 import threading
+import arvados.retry as retry
 
 from .api import api, http_cache
 from .retry import retry_method
@@ -54,14 +55,23 @@ def task_set_output(self,s,api_client=None):
     output_retry_loop = RetryLoop(num_retries=2, backoff_start=1)
     for tries_left in output_retry_loop:
 	try:
-	    api_client.job_tasks().update(uuid=self['uuid'],
+	    result = api_client.job_tasks().update(uuid=self['uuid'],
         	                         body={
             					'output':s,
 				            	'success':True,
 				            	'progress':1.0
-			                 	}).execute(num_retries=num_retries)
-	except TemporaryError as error:
-	    logger.debug("Error in task_set_output api call: {} ({} tries left)".format(error,tries_left))
+			                 	}).execute()
+	except errors.ApiError as error:
+            print "ApiError threw {}".format(error)
+        except errors.HttpError as error:
+            print retry.check_http_response_success(error.status_code)
+            if retry.check_http_response_success(error.status_code) == True:
+                print "We are good because status code = {} is a success!".format(error.status_code)
+            elif retry.check_http_response_success(error.status_code) == None:
+                print "We can retry because status code = {}".format(error.status_code)
+            else:
+                print "What happened?? status code = {}".format(error.status_code)
+                raise
 	else:
 	    output_retry_loop.save_result(result)
     if output_retry_loop.success():
diff --git a/sdk/python/tests/test_init.py b/sdk/python/tests/test_init.py
index c4bb006..2e87f51 100644
--- a/sdk/python/tests/test_init.py
+++ b/sdk/python/tests/test_init.py
@@ -1,3 +1,5 @@
+#!/usr/bin/env python
+
 import mock
 import os
 import unittest
@@ -9,8 +11,11 @@ class TestSDK(unittest.TestCase):
 
     FAKE_HASH = '7idummyhashb0b1f1f03e4e6f69c4a4e+28243'
 
-    def test_task_set_output(self, mock_input=FAKE_HASH):#, num_retries=2):
-        mock_api = mock.MagicMock(name='mock_api_client')
-        mock_api.job_tasks().update().execute().side_effect = Exception('mock API DOWN')
-        arvados.task_set_output(s=mock_input,api_client=mock_api)#,num_retries=2)
+    def test_task_set_output(self, mock_input=FAKE_HASH):
+        mock_api = mock.MagicMock()
+	mock_api.job_tasks().update().execute.side_effect = arvados.errors.HttpError(status_code=200,reason="Exception('Mock_500')")
+        arvados.task_set_output({'uuid':'zzzzz-zzzzz-ehnr5qheh1atzzz'},s=mock_input,api_client=mock_api)
+
+
+
         # need a spy to make mock_api return down if retry_num = 1 and mock_api return up if retry_num = 2

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list