Пример #1
0
 def tar_and_fput(self, src_dir, dest_obj_name):
     try:
         tar_path = src_dir + ".gz"
         self.make_targz(tar_path, src_dir)
         self.fput_obj(tar_path, dest_obj_name)
         os.remove(tar_path)
     except Exception as err:
         logger.error(str(err))
         traceback.print_stack()
Пример #2
0
 def __init__(self, args=None):
     try:
         self.client = Minio(args.minio_host,
                             access_key=args.minio_key,
                             secret_key=args.minio_secret,
                             secure=False)
     except Exception as err:
         logger.error(str(err))
         traceback.print_stack()
         self.client = None
     self.bucket_name = args.minio_bucket
Пример #3
0
def explore(args, id):
    c = zmq.Context()
    s = c.socket(zmq.REQ)
    host = 'tcp://%s:%d' % (args.host, args.port)
    s.connect(host)
    logger.info('zmq socket addr: tcp://%s:%d' % (args.host, args.port))
    batch_env = BatchedEnvironment(args, id)
    obs = batch_env.reset()
    action = batch_env.uniform_action()
    i = 0
    n = args.env_batch_size
    episode = [0] * n
    episode_step = [0] * n

    while True:
        next_obs, rew, done, info = batch_env.step(action)
        i += n
        increment(episode_step, n)
        terminal = [episode_step[i] >= args.max_episode_len for i in range(n)]
        sample = [obs, action, next_obs, rew, done, terminal]
        p = pickle.dumps(sample)
        z = zlib.compress(p)
        while True:
            try:
                s.send_pyobj(z)
                data = s.recv_pyobj()
                action = pickle.loads(data)
                break
            except zmq.ZMQError:
                logger.error("send to zmq server[%s] error, sleep 1s" % host)
                time.sleep(1)
        if str(action) == "stop":
            logger.info("[%d],%d finished explore, learning server stoped" %
                        (id, i))
            break

        if i % (10 * args.save_rate) == 0:
            logger.debug("batch_env[%d] step:%i, episode:%s" %
                         (id, i, str(episode)))
        obs = batch_env.reset_if_done(done, terminal, episode_step, episode)
        if i % 10000 == 0:
            logger.debug(str(id) + ":" + str(episode))
Пример #4
0
 def fput_obj(self, local_path, minio_path):
     try:
         self.client.fput_object(self.bucket_name, minio_path, local_path)
     except Exception as err:
         logger.error(str(err))
         traceback.print_stack()
Пример #5
0
 def fget_object(self, bucket_name, obj_name, save_path):
     try:
         self.client.fget_object(bucket_name, obj_name, save_path)
     except ResponseError as err:
         logger.error(str(err))
         traceback.print_stack()