def main(argv): """ The main method for this moduler. """ if len(argv) != 2: print 'the config file must be specified.' sys.exit(1) logfile = os.path.join(os.getcwd(), 'brook-log-scheduler.txt') config_logging(logfile) start_time = time.time() logging.info('Job started at %s' % time.asctime()) configparser = ConfigFileParser(argv[1]) options = configparser.parser() logging.info('Parse config file options at %s' % time.asctime()) scheduler = BrookJobScheduler(options) logging.info('Initialize of scheduler success at %s' % time.asctime()) try: scheduler.start_jobs() scheduler.monitor_jobs() scheduler.quit_jobs() logging.info('Job finished at %s' % time.asctime()) logging.info('Job run for %.3f seconds' % (time.time() - start_time)) except KeyboardInterrupt: logging.info('Interrupted by CTRL-C') scheduler.kill_jobs() sys.exit(-1) except Exception: exc_type, exc_value, exc_traceback = sys.exc_info() mesg = ''.join( traceback.format_exception(exc_type, exc_value, exc_traceback)) logging.info('cache exception in brook_scheduler.py') logging.info(mesg) scheduler.kill_jobs() sys.exit(-1)
def main(argv): """ The main method for this moduler. """ if len(argv) != 2: print 'the config file must be specified.' sys.exit(1) logfile = os.path.join(os.getcwd(), 'brook-log-scheduler.txt') config_logging(logfile) start_time = time.time() logging.info('Job started at %s' %time.asctime()) configparser = ConfigFileParser(argv[1]) options = configparser.parser() logging.info('Parse config file options at %s' %time.asctime()) scheduler = BrookJobScheduler(options) logging.info('Initialize of scheduler success at %s' %time.asctime()) try: scheduler.start_jobs() scheduler.monitor_jobs() scheduler.quit_jobs() logging.info('Job finished at %s' %time.asctime()) logging.info('Job run for %.3f seconds' %(time.time() - start_time)) except KeyboardInterrupt: logging.info('Interrupted by CTRL-C') scheduler.kill_jobs() sys.exit(-1) except Exception: exc_type, exc_value, exc_traceback = sys.exc_info() mesg = ''.join(traceback.format_exception(exc_type, exc_value, exc_traceback)) logging.info('cache exception in brook_scheduler.py') logging.info(mesg) scheduler.kill_jobs() sys.exit(-1)
def test_normal_case(self): test_options = { 'ssh_port': '22', 'machine_file': './machinefile.local', 'working_directory': '/tmp/brook', 'total_num_of_nodes': '4', 'client_name': 'client', 'brook': 'brook_main', 'num_of_agents': '2', 'num_of_servers': '1', 'parameter_channel': 'brook-parameter-channel', 'statistics_channel': 'brook-statistics-channel', 'parameter_signal': 'brook-parameter-signal', 'statistics_signal': 'brook-statistics-signal', 'counter_file': 'brook-counter', 'log_file': 'brook-log', 'input_format': 'protofile', 'output_format': 'protofile', 'num_of_feature': '7', 'consistency': 'BSP', 'updater': 'GAUpdater', 'aggregation': '1', 'communication_model': 'allreduce', 'aggregation_model': 'online', 'key_cache_store': 'memory' } filename = "./core.ini" configparser = ConfigFileParser(filename) option = configparser.parser() self.assertEqual(option['ssh_port'], test_options['ssh_port']) self.assertEqual(option['machine_file'], test_options['machine_file']) self.assertEqual(option['working_directory'], test_options['working_directory']) self.assertEqual(option['total_num_of_nodes'], test_options['total_num_of_nodes']) self.assertEqual(option['client_name'], test_options['client_name']) self.assertEqual(option['brook'], test_options['brook']) self.assertEqual(option['num_of_agents'], test_options['num_of_agents']) self.assertEqual(option['num_of_servers'], test_options['num_of_servers']) self.assertEqual(option['parameter_channel'], test_options['parameter_channel']) self.assertEqual(option['statistics_channel'], test_options['statistics_channel']) self.assertEqual(option['parameter_signal'], test_options['parameter_signal']) self.assertEqual(option['statistics_signal'], test_options['statistics_signal']) self.assertEqual(option['counter_file'], test_options['counter_file']) self.assertEqual(option['log_file'], test_options['log_file']) self.assertEqual(option['input_format'], test_options['input_format']) self.assertEqual(option['output_format'], test_options['output_format']) self.assertEqual(option['num_of_feature'], test_options['num_of_feature']) self.assertEqual(option['consistency'], test_options['consistency']) self.assertEqual(option['updater'], test_options['updater']) self.assertEqual(option['aggregation'], test_options['aggregation']) self.assertEqual(option['communication_model'], test_options['communication_model']) self.assertEqual(option['aggregation_model'], test_options['aggregation_model']) self.assertEqual(option['key_cache_store'], test_options['key_cache_store']) for machine in option['machine_list']: print machine