def create_pbs_job_content(self, module, case): """ Method creates pbs start script which will be passed to some qsub command :type case: scripts.config.yaml_config.ConfigCase :type module: scripts.pbs.modules.pbs_tarkil_cesnet_cz :rtype : str """ import pkgutil command = strings.replace_placeholders( runtest_command, python=sys.executable, script=pkgutil.get_loader('runtest').filename, yaml=case.file, limits="-n {case.proc} -m {case.memory_limit} -t {case.time_limit}".format(case=case), args="" if not self.rest else Command.to_string(self.rest), dump_output=case.fs.dump_output, log_file=case.fs.job_output ) template = strings.replace_placeholders( module.template, command=command, dump_output=case.fs.dump_output ) return template
def _run(self): # start executor self.executor.start() wait_for(self.executor, 'process') if self.executor.broken: printf.error('Could not start command "{}": {}', Command.to_string(self.executor.command), self.executor.exception) self.returncode = RC(self.executor.returncode) # if process is not broken, propagate start event self.on_process_start(self) while self.executor.is_running(): self.on_process_update(self) if self._short_sleep: time.sleep(0.01) else: self.sleeper.sleep() # get return code rc = getattr(self.executor, 'returncode', None) self.returncode = RC(rc if self.custom_error is None or str(rc) == "0" else self.custom_error) # reverse return code if death test is set if self.case and self.case.death_test is not None: self.returncode = RC( self.case.death_test.reverse_return_code(self.returncode)) self.returncode.reversed = self.case.death_test.value != self.case.death_test.FALSE # propagate on_complete event self.on_process_complete(self)
def create_pbs_job_content(module, case): """ :type case: scripts.config.yaml_config.ConfigCase :type module: scripts.pbs.modules.pbs_tarkil_cesnet_cz :rtype : str """ import pkgutil command = PBSModule.format( runtest_command, python=sys.executable, script=pkgutil.get_loader('runtest').filename, yaml=case.file, limits="-n {case.proc} -m {case.memory_limit} -t {case.time_limit}".format(case=case), args="" if not arg_rest else Command.to_string(arg_rest), json_output=case.fs.json_output ) template = PBSModule.format( module.template, command=command, json_output=case.fs.json_output ) return template
def create_pbs_job_content(self, module, case): """ :type case: scripts.config.yaml_config.ConfigCase :type module: scripts.pbs.modules.pbs_tarkil_cesnet_cz :rtype : str """ import pkgutil command = strings.replace_placeholders( exec_parallel_command, python=sys.executable, script=pkgutil.get_loader('exec_parallel').filename, limits="-n {case.proc} -m {case.memory_limit} -t {case.time_limit}".format(case=case), args="" if not self.rest else Command.to_string(self.rest), dump_output=case.fs.dump_output, log_file=case.fs.job_output ) template = strings.replace_placeholders( module.template, command=command, dump_output=case.fs.dump_output # TODO remove ) return template
def create_pbs_job_content(self, module, case): """ Method creates pbs start script which will be passed to some qsub command :type case: scripts.yamlc.yaml_config.ConfigCase :type module: scripts.pbs.modules.pbs_tarkil_cesnet_cz :rtype : str """ import pkgutil command = strings.replace_placeholders( runtest_command, python=sys.executable, script=pkgutil.get_loader('runtest').path, yaml=case.file, random_output_dir='' if not self.arg_options.random_output_dir else '--random-output-dir ' + str(self.arg_options.random_output_dir), limits="-n {case.proc} -m {case.memory_limit} -t {case.time_limit}" .format(case=case), args="" if not self.arg_options.rest else Command.to_string( self.arg_options.rest), dump_output=case.fs.dump_output, save_to_db='' if not self.arg_options.save_to_db else '--save-to-db', status_file='' if not self.arg_options.status_file else '--status-file', log_file=case.fs.job_output) template = strings.replace_placeholders( module.template, command=command, dump_output=case.fs.dump_output) return template
def create_pbs_job_content(self, module, case): """ Method creates pbs start script which will be passed to some qsub command :type case: scripts.config.yaml_config.ConfigCase :type module: scripts.pbs.modules.pbs_tarkil_cesnet_cz :rtype : str """ import pkgutil command = strings.replace_placeholders( runtest_command, python=sys.executable, script=pkgutil.get_loader('runtest').filename, yaml=case.file, limits="-n {case.proc} -m {case.memory_limit} -t {case.time_limit}".format(case=case), args="" if not self.arg_options.rest else Command.to_string(self.arg_options.rest), dump_output=case.fs.dump_output, log_file=case.fs.job_output ) template = strings.replace_placeholders( module.template, command=command, dump_output=case.fs.dump_output ) return template
def create_pbs_job_content(self, module, case): """ :type case: scripts.config.yaml_config.ConfigCase :type module: scripts.pbs.modules.pbs_tarkil_cesnet_cz :rtype : str """ import pkgutil command = strings.replace_placeholders( exec_parallel_command, python=sys.executable, script=pkgutil.get_loader('exec_parallel').filename, limits="-n {case.proc} -m {case.memory_limit} -t {case.time_limit}" .format(case=case), args="" if not self.arg_options.rest else Command.to_string( self.arg_options.rest), dump_output=case.fs.dump_output, log_file=case.fs.job_output) template = strings.replace_placeholders( module.template, command=command, dump_output=case.fs.dump_output # TODO remove ) return template
def on_complete(self, pypy=None): # print either error that command failed or on_complete info id exists if self.pypy.returncode > 0: Printer.err('Error! Command ({process.pid}) ended with {process.returncode}'. format(process=self.pypy.executor.process)) Printer.err(Command.to_string(self.pypy.executor.command)) elif self.end_fmt: Printer.out(self.end_fmt.format(**dict(self=self))) if not self.pypy.progress: Printer.separator() output = self.pypy.executor.output.read() if output: Printer.out(output)
def _run(self): # start executor self.executor.start() wait_for(self.executor, 'process') if self.executor.broken: Printer.all.err('Could not start command "{}": {}', Command.to_string(self.executor.command), self.executor.exception) self.returncode = self.executor.returncode # if process is not broken, propagate start event self.on_process_start(self) while self.executor.is_running(): self.on_process_update(self) self.sleeper.sleep() # get return code rc = getattr(self.executor, 'returncode', None) self.returncode = rc if self.custom_error is None or str(rc) == "0" else self.custom_error # propagate on_complete event self.on_process_complete(self)
def escaped_command(self): return Command.to_string(self.command)
def __init__(self, pypy): super(InfoMonitor, self).__init__(pypy) self.command_str = Command.to_string(self.pypy.executor.command) self.start_fmt = 'Executing {self.command_str}' self.end_fmt = 'Command ({self.pypy.executor.process.pid}) ended with {self.pypy.returncode}'