def test_load_include(): from lttngcluster.api import TraceExperimentOptions import tempfile from os.path import join from shutil import rmtree content = { 'recipe_a.yaml': '''a: a\nb: b''', 'recipe_b.yaml': '''import: recipe_a\nb: x\nz: z''', 'recipe_c.yaml': '''import: recipe_b\nb: y\nc: c''', } exp = { 'a': 'a', 'b': 'y', 'c': 'c', 'z': 'z', 'name': 'recipe_c' } d = tempfile.mkdtemp() for k, v in content.items(): with file(join(d, k), 'w+') as f: f.write(v) opts = TraceExperimentOptions() try: opts.load_path(join(d, 'recipe_c.yaml')) finally: rmtree(d) print(exp) print(opts) assert opts == exp
def cmd_trace_one(args, recipe): err = RecipeErrorCollection() opts = TraceExperimentOptions(**TraceExperimentOptions.default_options) opts.load_path(recipe) klass = registry.get_experiment(opts['experiment']) klass.set_options(opts) klass.validate(err) if len(err) > 0: pprint.pprint(opts) recipe_errors_show(recipe, err) raise Exception('validation error') if args.verbose: print('recipe:') pprint.pprint(opts) runner = TraceRunnerDefault() runner.set_dry_run(args.dry_run) runner.run(klass)
def recipe_verify(recipe, err): opts = TraceExperimentOptions(**TraceExperimentOptions.default_options) opts.load_path(recipe) klass = registry.get_experiment(opts['experiment']) klass.set_options(opts) klass.validate(err)