def get_info_from_ray_cluster_config( cluster_config: str ) -> Tuple[List[str], str, str, Optional[str], Optional[str]]: """Get information from Ray cluster config. Return list of host IPs, ssh user, ssh key file, and optional docker container. Args: cluster_config (str): Path to ray cluster config. Returns: Tuple of list of host IPs, ssh user name, ssh key file path, optional docker container name, optional cluster name. """ from ray.autoscaler._private.commands import _bootstrap_config cli_logger.print(f"Retrieving cluster information from ray cluster file: " f"{cluster_config}") cluster_config = os.path.expanduser(cluster_config) config = yaml.safe_load(open(cluster_config).read()) config = _bootstrap_config(config, no_config_cache=True) provider = _get_node_provider(config["provider"], config["cluster_name"]) head_nodes = provider.non_terminated_nodes({ TAG_RAY_NODE_KIND: NODE_KIND_HEAD }) worker_nodes = provider.non_terminated_nodes({ TAG_RAY_NODE_KIND: NODE_KIND_WORKER }) hosts = [provider.external_ip(node) for node in head_nodes + worker_nodes] ssh_user = config["auth"]["ssh_user"] ssh_key = config["auth"]["ssh_private_key"] docker = None docker_config = config.get("docker", None) if docker_config: docker = docker_config.get("container_name", None) cluster_name = config.get("cluster_name", None) return hosts, ssh_user, ssh_key, docker, cluster_name
def bootstrap_config(cluster_config: Dict[str, Any], no_config_cache: bool = False) -> Dict[str, Any]: """Validate and add provider-specific fields to the config. For example, IAM/authentication may be added here.""" return commands._bootstrap_config(cluster_config, no_config_cache)