def create_store(self, store_type): if store_type == "redis": redisStore = pygloo.rendezvous.RedisStore(self._ip_address, int(self._redis_port)) redis_password = ray_constants.REDIS_DEFAULT_PASSWORD redisStore.authorize(redis_password) self._store = redisStore elif store_type == "file": store_name = get_store_name(self._group_name) store_path = gloo_util.get_gloo_store_path(store_name) if self._context.rank == 0: if not os.path.exists(store_path): os.makedirs(store_path) elif os.listdir(store_path) and os.listdir(store_path): shutil.rmtree(store_path) os.makedirs(store_path) else: while not os.path.exists(store_path): time.sleep(0.1) # Note: multi-machines needs a shared NFS. fileStore = pygloo.rendezvous.FileStore(store_path) self._store = pygloo.rendezvous.PrefixStore( self._group_name, fileStore) elif store_type == "hash": raise NotImplementedError("No implementation for hash store.") else: raise RuntimeError( "Unrecognized store type: {}.".format(store_type))
def destroy_group(self): """Destroy the group and release GLOO communicators.""" if self._gloo_context is not None: pygloo.barrier(self._gloo_context) # destroy the communicator self._gloo_context = None if self.rank == 0 and self._rendezvous.store_type == "file": store_name = get_store_name(self._group_name) store_path = gloo_util.get_gloo_store_path(store_name) if os.path.exists(store_path): shutil.rmtree(store_path) super(GLOOGroup, self).destroy_group()