OLD | NEW |
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 from __future__ import print_function | 5 from __future__ import print_function |
6 | 6 |
7 import copy | 7 import copy |
8 import json | 8 import json |
9 import logging | 9 import logging |
10 import os | 10 import os |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 'picked_roll_details': picked_roll_details, | 261 'picked_roll_details': picked_roll_details, |
262 'rejected_candidates_count': len(rejected_candidates), | 262 'rejected_candidates_count': len(rejected_candidates), |
263 } | 263 } |
264 if verbose_json: | 264 if verbose_json: |
265 ret['rejected_candidate_specs'] = [ | 265 ret['rejected_candidate_specs'] = [ |
266 package_io.dump_obj(c.package_pb) for c in rejected_candidates] | 266 package_io.dump_obj(c.package_pb) for c in rejected_candidates] |
267 return ret | 267 return ret |
268 | 268 |
269 | 269 |
270 def add_subparser(parser): | 270 def add_subparser(parser): |
| 271 helpstr = 'Roll dependencies of a recipe package forward.' |
271 autoroll_p = parser.add_parser( | 272 autoroll_p = parser.add_parser( |
272 'autoroll', | 273 'autoroll', help=helpstr, description=helpstr) |
273 help='Roll dependencies of a recipe package forward (implies fetch)') | |
274 autoroll_p.add_argument( | 274 autoroll_p.add_argument( |
275 '--output-json', | 275 '--output-json', |
276 type=os.path.abspath, | 276 type=os.path.abspath, |
277 help='A json file to output information about the roll to.') | 277 help='A json file to output information about the roll to.') |
278 autoroll_p.add_argument( | 278 autoroll_p.add_argument( |
279 '--verbose-json', | 279 '--verbose-json', |
280 action='store_true', | 280 action='store_true', |
281 help=('Emit even more data in the output-json file. ' | 281 help=('Emit even more data in the output-json file. ' |
282 'Requires --output-json.')) | 282 'Requires --output-json.')) |
283 | 283 |
284 def postprocess_func(parser, args): | 284 def postprocess_func(parser, args): |
| 285 if args.no_fetch: |
| 286 parser.error('autoroll with --no-fetch does not make sense.') |
| 287 |
285 if args.verbose_json and not args.output_json: | 288 if args.verbose_json and not args.output_json: |
286 parser.error('--verbose-json passed without --output-json') | 289 parser.error('--verbose-json passed without --output-json') |
287 | 290 |
288 autoroll_p.set_defaults( | 291 autoroll_p.set_defaults( |
289 command='autoroll', func=main, postprocess_func=postprocess_func) | 292 command='autoroll', func=main, postprocess_func=postprocess_func) |
290 | 293 |
291 | 294 |
292 def main(_package_deps, args): | 295 def main(_package_deps, args): |
293 config_file = args.package | 296 config_file = args.package |
294 repo_root = package.InfraRepoConfig().from_recipes_cfg(config_file.path) | 297 repo_root = package.InfraRepoConfig().from_recipes_cfg(config_file.path) |
(...skipping 17 matching lines...) Expand all Loading... |
312 # Restore initial state. Since we could be running simulation tests | 315 # Restore initial state. Since we could be running simulation tests |
313 # on other revisions, re-run them now as well. | 316 # on other revisions, re-run them now as well. |
314 write_spec_to_disk(context, repo_cfg_block, config_file, package_pb) | 317 write_spec_to_disk(context, repo_cfg_block, config_file, package_pb) |
315 run_simulation_test(repo_root, package_spec.recipes_path, ['train']) | 318 run_simulation_test(repo_root, package_spec.recipes_path, ['train']) |
316 | 319 |
317 if args.output_json: | 320 if args.output_json: |
318 with open(args.output_json, 'w') as f: | 321 with open(args.output_json, 'w') as f: |
319 json.dump(results, f, sort_keys=True, indent=2) | 322 json.dump(results, f, sort_keys=True, indent=2) |
320 | 323 |
321 return 0 | 324 return 0 |
OLD | NEW |