Esempio n. 1
0
def try_create_gcs_client(
    address: Optional[str], redis_password: Optional[str]
) -> Optional[GcsClient]:
    """
    Try to create a gcs client based on the the command line args or by
    autodetecting a running Ray cluster.
    """
    address = canonicalize_bootstrap_address(address)
    if use_gcs_for_bootstrap():
        return GcsClient(address=address)
    else:
        if redis_password is None:
            redis_password = ray.ray_constants.REDIS_DEFAULT_PASSWORD
        return GcsClient.connect_to_gcs_by_redis_address(address, redis_password)
Esempio n. 2
0
def serve_proxier(
    connection_str: str,
    address: Optional[str],
    *,
    redis_password: Optional[str] = None,
    session_dir: Optional[str] = None,
    runtime_env_agent_port: int = 0,
):
    # Initialize internal KV to be used to upload and download working_dir
    # before calling ray.init within the RayletServicers.
    # NOTE(edoakes): redis_address and redis_password should only be None in
    # tests.
    if use_gcs_for_bootstrap():
        if address is not None:
            gcs_cli = GcsClient(address=address)
            ray.experimental.internal_kv._initialize_internal_kv(gcs_cli)
    else:
        if address is not None and redis_password is not None:
            gcs_cli = GcsClient.connect_to_gcs_by_redis_address(
                address, redis_password)
            ray.experimental.internal_kv._initialize_internal_kv(gcs_cli)

    server = grpc.server(
        futures.ThreadPoolExecutor(max_workers=CLIENT_SERVER_MAX_THREADS),
        options=GRPC_OPTIONS,
    )
    proxy_manager = ProxyManager(
        address,
        session_dir=session_dir,
        redis_password=redis_password,
        runtime_env_agent_port=runtime_env_agent_port,
    )
    task_servicer = RayletServicerProxy(None, proxy_manager)
    data_servicer = DataServicerProxy(proxy_manager)
    logs_servicer = LogstreamServicerProxy(proxy_manager)
    ray_client_pb2_grpc.add_RayletDriverServicer_to_server(
        task_servicer, server)
    ray_client_pb2_grpc.add_RayletDataStreamerServicer_to_server(
        data_servicer, server)
    ray_client_pb2_grpc.add_RayletLogStreamerServicer_to_server(
        logs_servicer, server)
    add_port_to_grpc_server(server, connection_str)
    server.start()
    return ClientServerHandle(
        task_servicer=task_servicer,
        data_servicer=data_servicer,
        logs_servicer=logs_servicer,
        grpc_server=server,
    )