コード例 #1
0
ファイル: exp40sim.py プロジェクト: AndreaCensi/yc1304
    def define_jobs_context(self, context):
        GlobalConfig.global_load_dir(Exp40.config_dir)
    
        robots = Exp40.robots
        agents = Exp40.agents
        explorer = Exp40.explorer
        num_episodes = 2
        max_episode_len = 5
        data_central = self.get_data_central()
        boot_root = data_central.get_boot_root()

        episodes = [episode_id_exploration(explorer, i) for i in range(num_episodes)]
        
        for id_robot in robots:
            recipe_episodeready_by_simulation(context, data_central, id_robot,
                                              explorer, max_episode_len)

        recipe_agentlearn_by_parallel(context, data_central, episodes)
   
        jobs_publish_learning_agents_robots(context, boot_root, agents, robots)

 
        output_dir = os.path.join(context.get_output_dir(), 'tex')
        
        for c, id_agent, id_robot in iterate_context_names_pair(context, agents, robots):
            job_tex_report(c, output_dir, id_agent=id_agent, id_robot=id_robot)
コード例 #2
0
ファイル: utils.py プロジェクト: AndreaCensi/conf_tools
def create_test_environment(files):
    with create_tmp_dir() as dirname:
        GlobalConfig.clear_for_tests()
        for filename, contents in files.items():
            with open(os.path.join(dirname, filename), 'w') as f:
                f.write(contents)

        yield dirname
コード例 #3
0
    def get_bo_config(self):
        if self.bo_config is None:
            self.bo_config = get_boot_config()
            
            dirs = self.dir_structure.get_config_directories()
            for dirname in dirs:
                if not os.path.exists(dirname):
                    msg = ('Warning, the config dir %r does not exist ' % 
                           friendly_path(dirname))
                    logger.info(msg)  
                else:
                    GlobalConfig.global_load_dir(dirname)
#                     self.bo_config.load(dirname)
        return self.bo_config
コード例 #4
0
ファイル: main.py プロジェクト: AndreaCensi/boot_olympics
def boot_olympics_manager(arguments):
    usage = substitute(usage_pattern, commands_list=commands_list,
                       cmd='boot_olympics_manager')

    parser = OptionParser(prog='boot_olympics_manager', usage=usage)
    parser.disable_interspersed_args()
    parser.add_option("-d", dest='boot_root', default=None,
                      help='Root directory with logs, config, etc. [%default]')

    parser.add_option("-c", dest='extra_conf_dirs', action="append", default=[],
                      help='Adds an extra config dir.')

    parser.add_option("-l", dest='extra_log_dirs', action="append", default=[],
                      help='Adds an extra directory storing logs.')

    parser.add_option("--contracts", default=False, action='store_true',
                      help="Activate PyContracts (disabled by default)")

    parser.add_option("--seterr", dest='seterr', default="warn",
                      help="Sets np.seterr. "
                      "Possible values: ignore, warn, raise, print, log")

    parser.add_option("--profile", default=False, action='store_true',
                      help="Use Python profiler")

    available = LogsFormat.formats.keys()
    parser.add_option("--logformat", dest='log_format',
                      default=BootOlympicsConstants.DEFAULT_LOG_FORMAT,
                      help="Choose format for writing logs in %s. [%%default]"
                        % str(available))

    (options, args) = parser.parse_args(arguments)

    if not args:
        msg = ('Please supply command. Available: %s'
               % ", ".join(Storage.commands.keys()))
        raise UserError(msg)

    cmd = args[0]
    cmd_options = args[1:]

    if not cmd in Storage.commands:
        msg = ('Unknown command %r. Available: %s.' % 
               (cmd, ", ".join(Storage.commands.keys())))
        raise UserError(msg)

    np.seterr(all=options.seterr)
    # underflow is very common in all libraries (e.g. matplotlib)
    np.seterr(under='warn')

    if not options.contracts:
        contracts.disable_all()

    if options.boot_root is None:
        options.boot_root = DirectoryStructure.DEFAULT_ROOT
        logger.info('Using %r as default root directory '
                    '(use -d <dir> to change)' % options.boot_root)


    data_central = DataCentral(options.boot_root)
    
    GlobalConfig.global_load_dir('default')  # need skins
    for dirname in options.extra_conf_dirs:
        GlobalConfig.global_load_dir(dirname)
    
    dir_structure = data_central.get_dir_structure() 
    dir_structure.set_log_format(options.log_format)
    for dirname in options.extra_log_dirs:
        dir_structure.add_log_directory(dirname)

    def go():
        return Storage.commands[cmd](data_central, cmd_options)

    if not options.profile:
        go()
    else:
        logger.warning('Note: the profiler does not work when using '
                       'parallel execution. (use "make" instead of "parmake").')
        import cProfile
        cProfile.runctx('go()', globals(), locals(), 'bom_prof')
        import pstats
        p = pstats.Stats('bom_prof')
        p.sort_stats('cumulative').print_stats(30)
        p.sort_stats('time').print_stats(30)
コード例 #5
0
ファイル: __init__.py プロジェクト: AndreaCensi/diffeo
 def initial_setup(self):
     options = self.get_options()
     # Load configurations for all modules
     GlobalConfig.global_load_dir(options.config)
コード例 #6
0
ファイル: __init__.py プロジェクト: ajaycharan/diffeo
 def initial_setup(self):
     options = self.get_options()
     # Load configurations for all modules
     GlobalConfig.global_load_dir(options.config)