[ARVADOS] updated: 044504806b4e96126dd88ee4c6dd418281b10b2e
git at public.curoverse.com
git at public.curoverse.com
Mon Aug 31 23:08:56 EDT 2015
Summary of changes:
sdk/python/arvados/__init__.py | 13 ++++++---
sdk/python/tests/test_one_task_per_input_retry.py | 32 +++++++++++++++++++----
2 files changed, 36 insertions(+), 9 deletions(-)
via 044504806b4e96126dd88ee4c6dd418281b10b2e (commit)
from de0f9e1bbec0af5b02872b97350cd9202655e4b5 (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 044504806b4e96126dd88ee4c6dd418281b10b2e
Author: Bryan Cosca <bcosc at curoverse.com>
Date: Mon Aug 31 23:08:49 2015 -0400
flailing need to mock a good cr to loop through
diff --git a/sdk/python/arvados/__init__.py b/sdk/python/arvados/__init__.py
index 1cfd1c9..d9d3c1e 100644
--- a/sdk/python/arvados/__init__.py
+++ b/sdk/python/arvados/__init__.py
@@ -222,7 +222,7 @@ class JobTask(object):
class job_setup():
@staticmethod
- def one_task_per_input_file(if_sequence=0, and_end_task=True, input_as_path=False, api_client=None, num_retries=None):
+ def one_task_per_input_file(if_sequence=0, and_end_task=True, input_as_path=False, api_client=None, num_retries=None, job_input=None, cr=None):
if if_sequence != current_task()['sequence']:
return
@@ -232,9 +232,14 @@ class job_setup():
if not num_retries:
num_retries = 2
- job_input = current_job()['script_parameters']['input']
- cr = CollectionReader(job_input, api_client=api_client)
- cr.normalize()
+ if not job_input:
+ job_input = current_job()['script_parameters']['input']
+ cr = CollectionReader(job_input, api_client=api_client)
+ cr.normalize()
+ #job_input = current_job()['script_parameters']['input']
+ #print job_input
+ #cr = CollectionReader(job_input, api_client=api_client)
+ #cr.normalize()
for s in cr.all_streams():
for f in s.all_files():
if input_as_path:
diff --git a/sdk/python/tests/test_one_task_per_input_retry.py b/sdk/python/tests/test_one_task_per_input_retry.py
index 5106b2c..edd74ec 100644
--- a/sdk/python/tests/test_one_task_per_input_retry.py
+++ b/sdk/python/tests/test_one_task_per_input_retry.py
@@ -7,6 +7,7 @@ import hashlib
import arvados
import arvados_testutil as tutil
+from test_collections import ArvadosCollectionsTest
@tutil.skip_sleep
class OneTaskPerInputTestCase(unittest.TestCase, tutil.ApiClientMock):
@@ -40,17 +41,38 @@ class OneTaskPerInputTestCase(unittest.TestCase, tutil.ApiClientMock):
except:
raise
+ def write_foo_bar_baz(self,api_client):
+ cw = arvados.CollectionWriter(api_client)
+ #self.assertEqual(cw.current_stream_name(), '.',
+ # 'current_stream_name() should be "." now')
+ cw.set_current_file_name('foo.txt')
+ cw.write('foo')
+ #self.assertEqual(cw.current_file_name(), 'foo.txt',
+ # 'current_file_name() should be foo.txt now')
+ cw.start_new_file('bar.txt')
+ cw.write('bar')
+ cw.start_new_stream('baz')
+ cw.write('baz')
+ cw.set_current_file_name('baz.txt')
+ #self.assertEqual(cw.manifest_text(),
+ # ". 3858f62230ac3c915f300c664312c63f+6 0:3:foo.txt 3:3:bar.txt\n" +
+ # "./baz 73feffa4b7f6bb68e44cf984c85f6e88+3 0:3:baz.txt\n",
+ # "wrong manifest: got {}".format(cw.manifest_text()))
+ cw.finish()
+ return cw.portable_data_hash()
def test_mock_retry_until_break(self):
api_client = mock.MagicMock()
api_client.job_tasks().create().execute.side_effect = [tutil.fake_httplib2_response(200)]
api_client.job_tasks().get().execute.side_effect = [tutil.fake_httplib2_response(200)]
- arvados.current_job() = Mock(return_value="foo")
api_client.jobs().get().execute.side_effect = [arvados.errors.ApiError(tutil.fake_httplib2_response(200), "{}")]
+ manifest = ". 3858f62230ac3c915f300c664312c63f+6 0:3:foo.txt 3:3:bar.txt\n"
+ foobarbaz = self.write_foo_bar_baz(api_client)
+ cr = arvados.CollectionReader(foobarbaz + '+Xzizzle', api_client)
with self.assertRaises(arvados.errors.ApiError) as err_check:
- arvados.current_job(api_client=api_client,num_retries=0)
+ arvados.job_setup.one_task_per_input_file(api_client=api_client,num_retries=0,job_input=manifest,cr=cr)
-class MockCurrentJob:
- def mock_current_job(self):
- arvados.current_job() = mock.Mock(return_value="foo")
+#class MockCurrentJob:
+# def mock_current_job(self):
+# arvados.current_job() = mock.Mock(return_value="foo")
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list