[ARVADOS] updated: 32e495e4c4f1ca194841769fcae22741d1e9549c
git at public.curoverse.com
git at public.curoverse.com
Mon Aug 17 10:32:50 EDT 2015
Summary of changes:
via 32e495e4c4f1ca194841769fcae22741d1e9549c (commit)
via b1faa1ee089c86fb9fb14bc93448d715d713a32f (commit)
from 9d9cb6334db6d7c6b81d3640fc0237ba2121a988 (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 32e495e4c4f1ca194841769fcae22741d1e9549c
Merge: b1faa1e 9d9cb63
Author: Bryan Cosca <bcosc at curoverse.com>
Date: Mon Aug 17 10:32:30 2015 -0400
Merge branch '6600-pysdk-api-retries' of git.curoverse.com:arvados into 6600-pysdk-api-retries
commit b1faa1ee089c86fb9fb14bc93448d715d713a32f
Author: Bryan Cosca <bcosc at curoverse.com>
Date: Mon Aug 17 10:20:33 2015 -0400
recovering from corrupt files
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