def do_launch(self, line): """Main commands: Ask for editing the parameters and then execute the code (NLO or aMC@(N)LO) """ old_cwd = os.getcwd() argss = self.split_arg(line) # check argument validity and normalise argument (options, argss) = _launch_parser.parse_args(argss) options = options.__dict__ self.check_launch(argss, options) if not os.path.isdir(os.path.join(os.getcwd(), argss[0], 'Events')): self.do_switch('ML5') return mg_interface.MadGraphCmd.do_launch(self,line) # if self.options['automatic_html_opening']: # misc.open_file(os.path.join(os.getcwd(), argss[0], 'crossx.html')) # self.options['automatic_html_opening'] = False if options['interactive']: if hasattr(self, 'do_shell'): ME = run_interface.aMCatNLOCmdShell(me_dir=argss[0], options=self.options) else: ME = run_interface.aMCatNLOCmd(me_dir=argss[0],options=self.options) ME.pass_in_web_mode() # transfer interactive configuration config_line = [l for l in self.history if l.strip().startswith('set')] for line in config_line: ME.exec_cmd(line) stop = self.define_child_cmd_interface(ME) return stop ext_program = launch_ext.aMCatNLOLauncher(argss[0], self, run_mode=argss[1], **options) ext_program.run()
def launch_program(self): """launch the main program""" # Check for number of cores if multicore mode mode = str(self.cluster) nb_node = 1 if mode == "2": import multiprocessing max_node = multiprocessing.cpu_count() if max_node == 1: logger.warning( 'Only one core is detected on your computer! Pass in single machine' ) self.cluster = 0 self.launch_program() return elif max_node == 2: nb_node = 2 elif not self.force: nb_node = self.ask('How many cores do you want to use?', max_node, range(2, max_node + 1)) else: nb_node = max_node import madgraph.interface.amcatnlo_run_interface as run_int if hasattr(self, 'shell') and self.shell: usecmd = run_int.aMCatNLOCmdShell(me_dir=self.running_dir, options=self.cmd_int.options) else: usecmd = run_int.aMCatNLOCmd(me_dir=self.running_dir, options=self.cmd_int.options) #Check if some configuration were overwritten by a command. If so use it set_cmd = [ l for l in self.cmd_int.history if l.strip().startswith('set') ] all_options = usecmd.options_configuration.keys( ) + usecmd.options_madgraph.keys() + usecmd.options_madevent.keys() for line in set_cmd: arg = line.split() if arg[1] not in all_options: continue misc.sprint(line) try: usecmd.exec_cmd(line) except Exception, error: misc.sprint('Command %s fails with msg: %s'%(str(line), \ str(error))) pass
def launch_program(self): """launch the main program""" # Check for number of cores if multicore mode mode = str(self.cluster) nb_node = 1 if mode == "2": import multiprocessing max_node = multiprocessing.cpu_count() if max_node == 1: logger.warning('Only one core is detected on your computer! Pass in single machine') self.cluster = 0 self.launch_program() return elif max_node == 2: nb_node = 2 elif not self.force: nb_node = self.ask('How many cores do you want to use?', max_node, range(2,max_node+1)) else: nb_node=max_node import madgraph.interface.amcatnlo_run_interface as run_int if hasattr(self, 'shell'): usecmd = run_int.aMCatNLOCmdShell(me_dir=self.running_dir, options = self.cmd_int.options) else: usecmd = run_int.aMCatNLOCmd(me_dir=self.running_dir, options = self.cmd_int.options) #Check if some configuration were overwritten by a command. If so use it set_cmd = [l for l in self.cmd_int.history if l.strip().startswith('set')] all_options = usecmd.options_configuration.keys() + usecmd.options_madgraph.keys() + usecmd.options_madevent.keys() for line in set_cmd: arg = line.split() if arg[1] not in all_options: continue misc.sprint(line) try: usecmd.exec_cmd(line) except Exception, error: misc.sprint('Command %s fails with msg: %s'%(str(line), \ str(error))) pass
def launch_program(self): """launch the main program""" # Check for number of cores if multicore mode mode = str(self.cluster) nb_node = 1 if mode == "2": import multiprocessing max_node = multiprocessing.cpu_count() if max_node == 1: logger.warning( 'Only one core is detected on your computer! Pass in single machine' ) self.cluster = 0 self.launch_program() return elif max_node == 2: nb_node = 2 elif not self.force: nb_node = self.ask('How many cores do you want to use?', max_node, list(range(2, max_node + 1))) else: nb_node = max_node import madgraph.interface.amcatnlo_run_interface as run_int if hasattr(self, 'shell') and self.shell: usecmd = run_int.aMCatNLOCmdShell(me_dir=self.running_dir, options=self.cmd_int.options) else: usecmd = run_int.aMCatNLOCmd(me_dir=self.running_dir, options=self.cmd_int.options) #Check if some configuration were overwritten by a command. If so use it set_cmd = [ l for l in self.cmd_int.history if l.strip().startswith('set') ] all_options = list(usecmd.options_configuration.keys()) + list( usecmd.options_madgraph.keys()) + list( usecmd.options_madevent.keys()) for line in set_cmd: arg = line.split() if arg[1] not in all_options: continue try: usecmd.exec_cmd(line) except Exception as error: misc.sprint('Command %s fails with msg: %s'%(str(line), \ str(error))) pass launch = self.cmd_int.define_child_cmd_interface(usecmd, interface=False) #launch.me_dir = self.running_dir option_line = ' '.join([' --%s' % opt for opt in self.options.keys() \ if self.options[opt] and not opt in ['cluster', 'multicore', 'name', 'appl_start_grid','shell']]) if self.options['name']: option_line += ' --name %s' % self.options['name'] if 'appl_start_grid' in self.options and self.options[ 'appl_start_grid']: option_line += ' --appl_start_grid %s' % self.options[ 'appl_start_grid'] command = 'launch ' + self.run_mode + ' ' + option_line if mode == "1": command += " -c" elif mode == "2": command += " -m" usecmd.nb_core = int(nb_node) try: os.remove('ME5_debug') except: pass launch.run_cmd(command) launch.run_cmd('quit')