如何获取现有 Ray redis 集群的地址?

How to get address of existing Ray redis cluster?

我正在编写一个使用 Ray 的烧瓶应用程序。我试图在应用程序启动时只 运行 ray.init() 一次,然后在其他文件中实际使用 ray 时引用该集群。从文档看来,我需要 运行 ray.init(address="") 才能使用 ray,但是如何在 运行ning 之后以编程方式获取或传递现有射线簇的地址ray.init() 第一次?另外,如果这通常不是正确的方法,请推荐更好的设计。

ray.init(address="auto") 应该可以。如果需要运行ray.init"after running init the first time",可以运行ray.shutdown()然后ray.init(address="auto").

我采用的解决方案是

if ray.is_initialized() == False: ray.init()