2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/21e3d69f6495/ Changeset: 21e3d69f6495 User: davebgx Date: 2014-10-23 14:34:17+00:00 Summary: Add optional display of stdout/stderr to the jobs API return value, defaulting to not displayed. Rework the test API interactor to wait for jobs instead of histories and get the stdout and stderr from the API. Affected #: 3 files diff -r 1f82617c06887e82e01175d24e45576da1e6ed92 -r 21e3d69f64953a848f5fcbfe4c4213c3a8d3c37b lib/galaxy/webapps/galaxy/api/jobs.py --- a/lib/galaxy/webapps/galaxy/api/jobs.py +++ b/lib/galaxy/webapps/galaxy/api/jobs.py @@ -93,7 +93,11 @@ :returns: dictionary containing full description of job data """ job = self.__get_job( trans, id ) - return self.encode_all_ids( trans, job.to_dict( 'element' ), True ) + job_dict = self.encode_all_ids( trans, job.to_dict( 'element' ), True ) + full_output = util.asbool( kwd.get( 'full', 'false' ) ) + if full_output: + job_dict.update( dict( stderr=job.stderr, stdout=job.stdout ) ) + return job_dict @expose_api def inputs( self, trans, id, **kwd ): diff -r 1f82617c06887e82e01175d24e45576da1e6ed92 -r 21e3d69f64953a848f5fcbfe4c4213c3a8d3c37b test/base/interactor.py --- a/test/base/interactor.py +++ b/test/base/interactor.py @@ -54,11 +54,12 @@ self.api_key = self.__get_user_key( twill_test_case.user_api_key, twill_test_case.master_api_key, test_user=test_user ) self.uploads = {} - def verify_output( self, history_id, output_data, output_testdef, shed_tool_id, maxseconds ): + def verify_output( self, history_id, jobs, output_data, output_testdef, shed_tool_id, maxseconds ): outfile = output_testdef.outfile attributes = output_testdef.attributes name = output_testdef.name - self.wait_for_history( history_id, maxseconds ) + for job in jobs: + self.wait_for_job( job[ 'id' ], maxseconds ) hid = self.__output_id( output_data ) fetcher = self.__dataset_fetcher( history_id ) ## TODO: Twill version verifys dataset is 'ok' in here. @@ -114,10 +115,17 @@ def wait_for_history( self, history_id, maxseconds ): self.twill_test_case.wait_for( lambda: not self.__history_ready( history_id ), maxseconds=maxseconds) - def get_job_stream( self, history_id, output_data, stream ): - hid = self.__output_id( output_data ) - data = self._dataset_provenance( history_id, hid ) - return data.get( stream, '' ) + def wait_for_job( self, job_id, maxseconds ): + self.twill_test_case.wait_for( lambda: not self.__job_ready( job_id ), maxseconds=maxseconds) + + def get_job_stdio( self, job_id, stream ): + job_stdio = self.__get_job_stdio( job_id ).json() + + def __get_job( self, job_id ): + return self._get( 'jobs/%s' % job_id ) + + def __get_job_stdio( self, job_id ): + return self._get( 'jobs/%s?full=true' % job_id ) def new_history( self ): history_json = self._post( "histories", {"name": "test_history"} ).json() @@ -204,7 +212,7 @@ datasets = self.__submit_tool( history_id, tool_id=testdef.tool.id, tool_input=inputs_tree ) datasets_object = datasets.json() try: - return self.__dictify_outputs( datasets_object ) + return self.__dictify_outputs( datasets_object ), datasets_object[ 'jobs' ] except KeyError: raise Exception( datasets_object[ 'message' ] ) @@ -261,6 +269,22 @@ pass return wait + def __wait_for_job( self, job_id ): + def wait(): + while not self.__job_ready( job_id ): + pass + return wait + + def __job_ready( self, job_id ): + job_json = self._get( "jobs/%s" % job_id ).json() + state = job_json[ 'state' ] + try: + return self._state_ready( state, error_msg="Job in error state." ) + except Exception: + if VERBOSE_ERRORS: + self._summarize_job_errors( history_id ) + raise + def __history_ready( self, history_id ): history_json = self._get( "histories/%s" % history_id ).json() state = history_json[ 'state' ] diff -r 1f82617c06887e82e01175d24e45576da1e6ed92 -r 21e3d69f64953a848f5fcbfe4c4213c3a8d3c37b test/functional/test_toolbox.py --- a/test/functional/test_toolbox.py +++ b/test/functional/test_toolbox.py @@ -29,10 +29,10 @@ stage_data_in_history( galaxy_interactor, testdef.test_data(), test_history, shed_tool_id ) - data_list = galaxy_interactor.run_tool( testdef, test_history ) + data_list, jobs = galaxy_interactor.run_tool( testdef, test_history ) self.assertTrue( data_list ) - self._verify_outputs( testdef, test_history, shed_tool_id, data_list, galaxy_interactor ) + self._verify_outputs( testdef, test_history, jobs, shed_tool_id, data_list, galaxy_interactor ) galaxy_interactor.delete_history( test_history ) @@ -47,7 +47,7 @@ else: raise Exception( "Test parse failure" ) - def _verify_outputs( self, testdef, history, shed_tool_id, data_list, galaxy_interactor ): + def _verify_outputs( self, testdef, history, jobs, shed_tool_id, data_list, galaxy_interactor ): maxseconds = testdef.maxseconds if testdef.num_outputs is not None: expected = testdef.num_outputs @@ -72,11 +72,13 @@ output_data = data_list[ len(data_list) - len(testdef.outputs) + output_index ] self.assertTrue( output_data is not None ) try: - galaxy_interactor.verify_output( history, output_data, output_testdef=output_testdef, shed_tool_id=shed_tool_id, maxseconds=maxseconds ) + galaxy_interactor.verify_output( history, jobs, output_data, output_testdef=output_testdef, shed_tool_id=shed_tool_id, maxseconds=maxseconds ) except Exception: - for stream in ['stdout', 'stderr']: - stream_output = galaxy_interactor.get_job_stream( history, output_data, stream=stream ) - print >>sys.stderr, self._format_stream( stream_output, stream=stream, format=True ) + for job in jobs: + job_stdio = galaxy_interactor.get_job_stdio( job[ 'id' ] ) + for stream in ['stdout', 'stderr']: + if stream in job_stdio: + print >>sys.stderr, self._format_stream( job_stdio[ stream ], stream=stream, format=True ) raise https://bitbucket.org/galaxy/galaxy-central/commits/ae33952d52dc/ Changeset: ae33952d52dc User: davebgx Date: 2014-10-23 14:35:43+00:00 Summary: Merge stable into default. Affected #: 1 file diff -r 21e3d69f64953a848f5fcbfe4c4213c3a8d3c37b -r ae33952d52dcf4f682b317aaf01dcaa4d79d79b9 .hgtags --- a/.hgtags +++ b/.hgtags @@ -20,4 +20,4 @@ ca45b78adb4152fc6e7395514d46eba6b7d0b838 release_2014.08.11 548ab24667d6206780237bd807f7d857a484c461 latest_2014.08.11 2092948937ac30ef82f71463a235c66d34987088 release_2014.10.06 -a7b2aabb27ffe5cc3216774ab01b18f13b4fc941 latest_2014.10.06 +9bc08bc7f393362ee7e6cf1d04bb9d8cee68f2d8 latest_2014.10.06 Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.