Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(404)

Side by Side Diff: recipe_engine/run.py

Issue 2882563002: Revert of include Package proto into Result proto (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « recipe_engine/result_pb2.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 The LUCI Authors. All rights reserved. 1 # Copyright 2016 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 """Entry point for fully-annotated builds. 5 """Entry point for fully-annotated builds.
6 6
7 This script is part of the effort to move all builds to annotator-based 7 This script is part of the effort to move all builds to annotator-based
8 systems. Any builder configured to use the AnnotatorFactory.BaseFactory() 8 systems. Any builder configured to use the AnnotatorFactory.BaseFactory()
9 found in scripts/master/factory/annotator_factory.py executes a single 9 found in scripts/master/factory/annotator_factory.py executes a single
10 AddAnnotatedScript step. That step (found in annotator_commands.py) calls 10 AddAnnotatedScript step. That step (found in annotator_commands.py) calls
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 engine, 149 engine,
150 recipe_test_api.DisabledTestData()) 150 recipe_test_api.DisabledTestData())
151 151
152 s.add_step_text('running recipe: "%s"' % recipe) 152 s.add_step_text('running recipe: "%s"' % recipe)
153 except (loader.LoaderError, ImportError, AssertionError) as e: 153 except (loader.LoaderError, ImportError, AssertionError) as e:
154 for line in str(e).splitlines(): 154 for line in str(e).splitlines():
155 s.add_step_text(line) 155 s.add_step_text(line)
156 s.set_step_status('EXCEPTION') 156 s.set_step_status('EXCEPTION')
157 if engine_flags and engine_flags.use_result_proto: 157 if engine_flags and engine_flags.use_result_proto:
158 return result_pb2.Result( 158 return result_pb2.Result(
159 recipe_package=universe_view.universe.config_file.read(),
160 failure=result_pb2.Failure( 159 failure=result_pb2.Failure(
161 human_reason=str(e), 160 human_reason=str(e),
162 exception=result_pb2.Exception( 161 exception=result_pb2.Exception(
163 traceback=traceback.format_exc().splitlines() 162 traceback=traceback.format_exc().splitlines()
164 ))) 163 )))
165 return RecipeResult({ 164 return RecipeResult({
166 'status_code': 2, 165 'status_code': 2,
167 'reason': str(e), 166 'reason': str(e),
168 }) 167 })
169 168
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 self._get_client('paths')._initialize_with_recipe_api(api) 301 self._get_client('paths')._initialize_with_recipe_api(api)
303 302
304 # TODO(martiniss): Remove this once we've transitioned to the new results 303 # TODO(martiniss): Remove this once we've transitioned to the new results
305 # format 304 # format
306 if self._engine_flags and self._engine_flags.use_result_proto: 305 if self._engine_flags and self._engine_flags.use_result_proto:
307 logging.info("Using new result proto logic") 306 logging.info("Using new result proto logic")
308 return self._new_run(recipe_script, api, properties) 307 return self._new_run(recipe_script, api, properties)
309 return self._old_run(recipe_script, api, properties) 308 return self._old_run(recipe_script, api, properties)
310 309
311 def _new_run(self, recipe_script, api, properties): 310 def _new_run(self, recipe_script, api, properties):
312 result = result_pb2.Result( 311 result = None
313 recipe_package=self.universe.config_file.read(),
314 )
315 312
316 with self._step_runner.run_context(): 313 with self._step_runner.run_context():
317 try: 314 try:
318 try: 315 try:
319 recipe_result = recipe_script.run(api, properties) 316 recipe_result = recipe_script.run(api, properties)
320 result.json_result = json.dumps(recipe_result) 317 result = result_pb2.Result(json_result=json.dumps(recipe_result))
321 finally: 318 finally:
322 self._close_through_level(0) 319 self._close_through_level(0)
323 except recipe_api.StepFailure as f: 320 except recipe_api.StepFailure as f:
324 result.failure.human_reason = f.reason 321 result = result_pb2.Result(
325 result.failure.failure.step = f.name 322 failure=result_pb2.Failure(
323 human_reason=f.reason,
324 failure=result_pb2.StepFailure(
325 step=f.name
326 )))
326 327
327 except types.StepDataAttributeError as ex: 328 except types.StepDataAttributeError as ex:
328 result.failure.human_reason = ex.message 329 result = result_pb2.Result(
329 result.failure.step_data.step = f.name 330 failure=result_pb2.Failure(
331 human_reason=ex.message,
332 step_data=result_pb2.StepData(
333 step=f.name
334 )))
330 335
331 # Let the step runner run_context decide what to do. 336 # Let the step runner run_context decide what to do.
332 raise 337 raise
333 338
334 except subprocess42.TimeoutExpired as ex: 339 except subprocess42.TimeoutExpired as ex:
335 result.failure.human_reason = "Step time out: %r" % ex 340 result = result_pb2.Result(
336 result.failure.timeout.timeout_s = ex.timeout 341 failure=result_pb2.Failure(
342 human_reason="Step time out: %r" % ex,
343 timeout= result_pb2.Timeout(
344 timeout_s=ex.timeout
345 )))
337 346
338 except Exception as ex: 347 except Exception as ex:
339 result.failure.human_reason = "Uncaught Exception: %r" % ex 348 result = result_pb2.Result(
340 result.failure.exception.traceback[:] = ( 349 failure=result_pb2.Failure(
341 traceback.format_exc().splitlines()) 350 human_reason="Uncaught Exception: %r" % ex,
351 exception=result_pb2.Exception(
352 traceback=traceback.format_exc().splitlines()
353 )))
342 354
343 # Let the step runner run_context decide what to do. 355 # Let the step runner run_context decide what to do.
344 raise 356 raise
345 357
346 return result 358 return result
347 359
348 def _old_run(self, recipe_script, api, properties): 360 def _old_run(self, recipe_script, api, properties):
349 with self._step_runner.run_context(): 361 with self._step_runner.run_context():
350 try: 362 try:
351 try: 363 try:
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 results.append( 427 results.append(
416 loader._invoke_with_properties( 428 loader._invoke_with_properties(
417 run_recipe, properties, recipe_script.PROPERTIES, 429 run_recipe, properties, recipe_script.PROPERTIES,
418 properties.keys())) 430 properties.keys()))
419 except TypeError as e: 431 except TypeError as e:
420 raise TypeError( 432 raise TypeError(
421 "Got %r while trying to call recipe %s with properties %r" % ( 433 "Got %r while trying to call recipe %s with properties %r" % (
422 e, recipe, properties)) 434 e, recipe, properties))
423 435
424 return results 436 return results
OLDNEW
« no previous file with comments | « recipe_engine/result_pb2.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698