def run(self, args): def warn_invalid(msg): print("the configuration is invalid, the argument parser got the" " following error:") print(msg) sandbox = SandBox() sandbox.root_dir = args.sandbox try: cmd_line = sandbox.get_configuration()["cmd_line"] except (TypeError, KeyError) as msg: warn_invalid(msg) return argument_parser = main(get_argument_parser=True) def error(message): raise SandBoxError(message) argument_parser.error = error try: args = argument_parser.parse_args(cmd_line[2:]) except SandBoxError as msg: warn_invalid(msg) return for k, v in vars(args).items(): if k in self.keys: print("%s = %s" % (k, v))
def run(self, args): sandbox = SandBox() sandbox.root_dir = args.sandbox sandbox.create_dirs() if args.spec_git_url: g = GitRepository(sandbox.specs_dir) if e3.log.default_output_stream is not None: g.log_stream = e3.log.default_output_stream g.init() g.update(args.spec_git_url, args.spec_git_branch, force=True) sandbox.dump_configuration() sandbox.write_scripts()
def run(self, args): sandbox = SandBox() sandbox.root_dir = args.sandbox sandbox.create_dirs() if args.spec_git_url: mkdir(sandbox.spec_dir) g = GitRepository(sandbox.spec_dir) if e3.log.default_output_stream is not None: g.log_stream = e3.log.default_output_stream g.init() g.update(args.spec_git_url, args.spec_git_branch, force=True) sandbox.dump_configuration() sandbox.write_scripts()
def run(self, args): sandbox = SandBox() sandbox.root_dir = args.sandbox cmd_line = sandbox.get_configuration()['cmd_line'] args_namespace = argparse.Namespace() args_namespace.python = cmd_line[0] argument_parser = main(get_argument_parser=True) def error(message): raise SandBoxError(message) argument_parser.error = error try: args = argument_parser.parse_args(cmd_line[2:]) except SandBoxError as msg: print('the configuration is invalid, the argument parser got the' 'following error:') print(msg) for k, v in vars(args).iteritems(): if k in self.keys: print('%s = %s' % (k, v))
def run(self, args): sandbox = SandBox() sandbox.root_dir = args.sandbox if args.specs_dir: sandbox.specs_dir = args.specs_dir if args.create_sandbox: sandbox.create_dirs() if args.create_sandbox and args.spec_git_url: mkdir(sandbox.specs_dir) g = GitRepository(sandbox.specs_dir) if e3.log.default_output_stream is not None: g.log_stream = e3.log.default_output_stream g.init() g.update(args.spec_git_url, args.spec_git_branch, force=True) sandbox.dump_configuration() sandbox.write_scripts() asr = AnodSpecRepository(sandbox.specs_dir) check_api_version(asr.api_version) # Load plan content if needed if args.plan: if not os.path.isfile(args.plan): raise SandBoxError("plan file %s does not exist" % args.plan, origin="SandBoxExec.run") with open(args.plan, "r") as plan_fd: plan_content = ["def main_entry_point():"] plan_content += [ " %s" % line for line in plan_fd.read().splitlines() ] plan_content = "\n".join(plan_content) env = BaseEnv() cm = PlanContext(server=env) store = None resolver = getattr( AnodContext, str(args.resolver), AnodContext.always_create_source_resolver, ) logger.debug("Using resolver %s", resolver.__name__) # Declare available actions and their signature def anod_action(module, build=None, host=None, target=None, qualifier=None): pass # all: no cover for a in ("anod_install", "anod_build", "anod_test"): cm.register_action(a, anod_action) # Load the plan and execute plan = Plan(data={}) plan.load_chunk(plan_content) actions = cm.execute(plan, "main_entry_point") ac = AnodContext(asr, default_env=env) for action in actions: ac.add_anod_action( action.module, action, action.action.replace("anod_", "", 1), action.qualifier, ) # Check if machine plan is locally schedulable action_list = ac.schedule(resolver) e = ElectrolytJobFactory(sandbox, asr, store, dry_run=args.dry_run) e.run(action_list)
def create_anod_sandbox(sbx_dir: str, spec_dir: str) -> SandBox: sbx = SandBox() sbx.root_dir = sbx_dir sbx.specs_dir = spec_dir return sbx