示例#1
0
def start_server_factory():
    def dump():
        print "$ python server.py -c <game> <generation_name>"
        print "$ python server.py <config_file>"
        sys.exit(1)

    if len(sys.argv) != 2 and len(sys.argv) != 4:
        dump()

    if len(sys.argv) == 4:
        if sys.argv[1] != "-c":
            dump()

        game, generation_prefix = sys.argv[2], sys.argv[3]
        conf = templates.server_config_template(game, generation_prefix, 1)
        print attrutil.attr_to_json(conf, pretty=True)

    else:
        if sys.argv[1] == "-c":
            dump()

        from ggplib.util.init import setup_once
        setup_once("server")

        from ggpzero.util.keras import init
        init()

        filename = sys.argv[1]
        assert os.path.exists(filename)
        ServerBroker(filename)
        reactor.run()
示例#2
0
def lookup_all_games():
    # ensure things are initialised
    from ggplib.util.init import setup_once
    setup_once()

    failed = []
    known_to_fail = [
        'amazonsTorus_10x10', 'atariGoVariant_7x7', 'gt_two_thirds_4p',
        'gt_two_thirds_6p', 'linesOfAction'
    ]
    for game in lookup.get_all_game_names():
        if game not in known_to_fail:
            try:
                game_info = lookup.by_name(game, build_sm=False)
                assert game_info.game == game
                sm = game_info.get_sm()

                # run some depth charges to ensure we have valid statemachine
                interface.depth_charge(sm, 1)

                log.verbose("DONE GETTING Statemachine FOR GAME %s %s" %
                            (game, sm))
            except lookup.LookupFailed as exc:
                log.warning("Failed to lookup %s: %s" % (game, exc))
                failed.append(game)

    if failed:
        log.error("Failed games %s" % (failed, ))
        assert False, failed
示例#3
0
def main_wrap(main_fn, logfile_name=None, **kwds):
    if logfile_name is None:
        # if logfile_name not set, derive it from main_fn
        fn = main_fn.func_code.co_filename
        logfile_name = os.path.splitext(os.path.basename(fn))[0]

    setup_once(logfile_name)

    try:
        # we might be running under python with no keras/numpy support
        init(**kwds)

    except ImportError as exc:
        log.warning("ImportError: %s" % exc)

    try:
        if main_fn.func_code.co_argcount == 0:
            return main_fn()
        else:
            return main_fn(sys.argv[1:])

    except Exception as exc:
        print exc
        _, _, tb = sys.exc_info()
        traceback.print_exc()
        pdb.post_mortem(tb)
示例#4
0
def setup(log_name_base=None):
    if log_name_base is not None:
        setup_once(log_name_base=log_name_base)
    else:
        setup_once(log_name_base=log_name_base)
    init()
    os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
    tf.logging.set_verbosity(tf.logging.ERROR)
def setup():
    from ggplib.util.init import setup_once
    setup_once()

    os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
    tf.logging.set_verbosity(tf.logging.ERROR)

    np.set_printoptions(threshold=100000)
示例#6
0
文件: hex.py 项目: vipmath/ggp-zero
def setup():
    from ggplib.util.init import setup_once
    setup_once()

    from ggpzero.util.keras import init
    init()

    os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
    tf.logging.set_verbosity(tf.logging.ERROR)
示例#7
0
def start_worker_factory():
    from ggplib.util.init import setup_once
    setup_once("worker")

    from ggpzero.util.keras import init
    init()

    broker = Worker(sys.argv[1])
    broker.start()
示例#8
0
def setup():
    import tensorflow as tf

    from ggplib.util.init import setup_once
    setup_once()

    from ggpzero.util.keras import init
    init()

    os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
    tf.logging.set_verbosity(tf.logging.ERROR)

    import numpy as np
    np.set_printoptions(threshold=100000)
示例#9
0
def setup():
    # set up ggplib
    setup_once()

    # ensure we have database with ggplib
    lookup.get_database()

    # initialise keras/tf
    keras.init()

    # just ensures we have the manager ready
    get_manager()

    os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
    tf.logging.set_verbosity(tf.logging.ERROR)

    np.set_printoptions(threshold=100000, precision=2)
示例#10
0
def setup():
    import tensorflow as tf

    from ggplib.util.init import setup_once
    setup_once()

    from ggpzero.util.keras import init
    init()

    os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
    tf.logging.set_verbosity(tf.logging.ERROR)

    import numpy as np
    np.set_printoptions(threshold=100000)

    man = get_manager()
    if not man.can_load(GAME, RANDOM_GEN):
        network = man.create_new_network(GAME)
        man.save_network(network, RANDOM_GEN)
示例#11
0
def start_worker_factory():

    if len(sys.argv) != 2:
        print "$ python worker.py -c"
        print "$ python server.py <config_file>"
        sys.exit(1)

    if sys.argv[1] == "-c":
        print attrutil.attr_to_json(default_conf(), pretty=True)
        return

    from ggplib.util.init import setup_once
    setup_once("worker")

    from ggpzero.util.keras import init
    init()

    broker = Worker(sys.argv[1])
    broker.start()
def setup():
    # set up ggplib
    setup_once()

    # ensure we have database with ggplib
    lookup.get_database()

    # initialise keras/tf
    keras.init()

    # just ensures we have the manager ready
    get_manager()

    os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
    tf.logging.set_verbosity(tf.logging.ERROR)

    np.set_printoptions(threshold=100000)

    from gzero_games.ggphack import addgame
    addgame.install_games()
示例#13
0
def start_server_factory():
    from ggplib.util.init import setup_once
    setup_once("server")

    from ggpzero.util.keras import init
    init()

    if sys.argv[1] == "-c":
        game, generation_prefix = sys.argv[2], sys.argv[3]
        num_prev_states = int(sys.argv[4])
        filename = sys.argv[5]
        conf = templates.server_config_template(game, generation_prefix,
                                                num_prev_states)
        ServerBroker(filename, conf)

    else:
        filename = sys.argv[1]
        assert os.path.exists(filename)
        ServerBroker(filename)

    reactor.run()
示例#14
0
def setup():
    from ggplib.util.init import setup_once
    setup_once(__file__)

    if os.path.exists("tmp.cpp"):
        os.unlink("tmp.cpp")
示例#15
0
def setup():
    from ggplib.util.init import setup_once
    setup_once()

    from ggpzero.util.keras import init
    init()
示例#16
0
def setup():
    # set up ggplib
    setup_once()

    # ensure we have database with ggplib
    lookup.get_database()
示例#17
0
def setup():
    from ggplib.util.init import setup_once
    setup_once()
示例#18
0
文件: runner.py 项目: richemslie/k273
        self.cmds = None
        self.last_time = os.stat(watch_path).st_mtime
        reactor.callLater(0.1, self.check)

    def check(self):
        print ".",
        sys.stdout.flush()
        mtime = os.stat("/home/rxe/working/ggpzero/data/reversi/generations/").st_mtime
        if mtime > self.last_time + 0.01:
            print "directory changed", watch_path
            self.last_time = mtime
            self.run()
        else:
            reactor.callLater(5, self.check)

    def done(self):
        print "DONE sync"
        reactor.callLater(5, self.check)

    def run(self):
        self.cmds_running = runprocs.RunCmds([cmd], cb_on_completion=self.done, max_time=180.0)
        self.cmds_running.spawn()


if __name__ == "__main__":
    from ggplib.util.init import setup_once
    setup_once("runner")

    watch_dir = WatchDir()
    reactor.run()