chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
filegroup(
|
||||
name = "example",
|
||||
data = glob(["example-*.yaml"]),
|
||||
visibility = ["//python/ray/tests:__pkg__"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "default_config",
|
||||
srcs = ["defaults.yaml"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
@@ -0,0 +1,137 @@
|
||||
"""Web server that runs on local/private clusters to coordinate and manage
|
||||
different clusters for multiple users. It receives node provider function calls
|
||||
through HTTP requests from remote CoordinatorSenderNodeProvider and runs them
|
||||
locally in LocalNodeProvider. To start the webserver the user runs:
|
||||
`python coordinator_server.py --ips <comma separated ips> --host <HOST> --port <PORT>`."""
|
||||
import argparse
|
||||
import json
|
||||
import logging
|
||||
import socket
|
||||
import threading
|
||||
from http.server import HTTPServer, SimpleHTTPRequestHandler
|
||||
from typing import List, Optional, Tuple
|
||||
|
||||
from ray._common.network_utils import build_address
|
||||
from ray.autoscaler._private.local.node_provider import LocalNodeProvider
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
def runner_handler(node_provider):
|
||||
class Handler(SimpleHTTPRequestHandler):
|
||||
"""A custom handler for OnPremCoordinatorServer.
|
||||
|
||||
Handles all requests and responses coming into and from the
|
||||
remote CoordinatorSenderNodeProvider.
|
||||
"""
|
||||
|
||||
def _do_header(
|
||||
self,
|
||||
response_code: int = 200,
|
||||
headers: Optional[List[Tuple[str, str]]] = None,
|
||||
):
|
||||
"""Sends the header portion of the HTTP response.
|
||||
|
||||
Args:
|
||||
response_code: Standard HTTP response code
|
||||
headers: Standard HTTP response headers
|
||||
"""
|
||||
if headers is None:
|
||||
headers = [("Content-type", "application/json")]
|
||||
|
||||
self.send_response(response_code)
|
||||
for key, value in headers:
|
||||
self.send_header(key, value)
|
||||
self.end_headers()
|
||||
|
||||
def do_HEAD(self):
|
||||
"""HTTP HEAD handler method."""
|
||||
self._do_header()
|
||||
|
||||
def do_GET(self):
|
||||
"""Processes requests from remote CoordinatorSenderNodeProvider."""
|
||||
if self.headers["content-length"]:
|
||||
raw_data = (
|
||||
self.rfile.read(int(self.headers["content-length"]))
|
||||
).decode("utf-8")
|
||||
logger.info(
|
||||
"OnPremCoordinatorServer received request: " + str(raw_data)
|
||||
)
|
||||
request = json.loads(raw_data)
|
||||
response = getattr(node_provider, request["type"])(*request["args"])
|
||||
logger.info(
|
||||
"OnPremCoordinatorServer response content: " + str(raw_data)
|
||||
)
|
||||
response_code = 200
|
||||
message = json.dumps(response)
|
||||
self._do_header(response_code=response_code)
|
||||
self.wfile.write(message.encode())
|
||||
|
||||
return Handler
|
||||
|
||||
|
||||
class OnPremCoordinatorServer(threading.Thread):
|
||||
"""Initializes HTTPServer and serves CoordinatorSenderNodeProvider forever.
|
||||
|
||||
It handles requests from the remote CoordinatorSenderNodeProvider. The
|
||||
requests are forwarded to LocalNodeProvider function calls.
|
||||
"""
|
||||
|
||||
def __init__(self, list_of_node_ips, host, port):
|
||||
"""Initialize HTTPServer and serve forever by invoking self.run()."""
|
||||
|
||||
logger.info(
|
||||
"Running on prem coordinator server on address " + build_address(host, port)
|
||||
)
|
||||
threading.Thread.__init__(self)
|
||||
self._port = port
|
||||
self._list_of_node_ips = list_of_node_ips
|
||||
address = (host, self._port)
|
||||
config = {"list_of_node_ips": list_of_node_ips}
|
||||
self._server = HTTPServer(
|
||||
address,
|
||||
runner_handler(LocalNodeProvider(config, cluster_name=None)),
|
||||
)
|
||||
self.start()
|
||||
|
||||
def run(self):
|
||||
self._server.serve_forever()
|
||||
|
||||
def shutdown(self):
|
||||
"""Shutdown the underlying server."""
|
||||
self._server.shutdown()
|
||||
self._server.server_close()
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Please provide a list of node ips and port."
|
||||
)
|
||||
parser.add_argument(
|
||||
"--ips", required=True, help="Comma separated list of node ips."
|
||||
)
|
||||
parser.add_argument(
|
||||
"--host",
|
||||
type=str,
|
||||
required=False,
|
||||
help="The Host on which the coordinator listens.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--port",
|
||||
type=int,
|
||||
required=True,
|
||||
help="The port on which the coordinator listens.",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
host = args.host or socket.gethostbyname(socket.gethostname())
|
||||
list_of_node_ips = args.ips.split(",")
|
||||
OnPremCoordinatorServer(
|
||||
list_of_node_ips=list_of_node_ips,
|
||||
host=host,
|
||||
port=args.port,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,33 @@
|
||||
# This configuration file is used internally
|
||||
# to fill default settings for on-prem Ray clusters
|
||||
# bootstrapped by the Ray autoscaler.
|
||||
# For annotated examples, see the example yamls in this directory.
|
||||
|
||||
cluster_name: default
|
||||
|
||||
auth: {}
|
||||
|
||||
upscaling_speed: 1.0
|
||||
idle_timeout_minutes: 5
|
||||
|
||||
docker: {}
|
||||
|
||||
# Defaults are empty to avoid any surprise changes to on-prem cluster's state.
|
||||
# Refer to example yamls for examples of ray installation in setup commands.
|
||||
initialization_commands: []
|
||||
setup_commands: []
|
||||
head_setup_commands: []
|
||||
worker_setup_commands: []
|
||||
|
||||
head_start_ray_commands:
|
||||
- ray stop
|
||||
- ulimit -c unlimited; ray start --head --port=6379 --autoscaling-config=~/ray_bootstrap_config.yaml
|
||||
worker_start_ray_commands:
|
||||
- ray stop
|
||||
- ray start --address=$RAY_HEAD_IP:6379
|
||||
|
||||
file_mounts: {}
|
||||
cluster_synced_files: []
|
||||
file_mounts_sync_continuously: false
|
||||
rsync_exclude: []
|
||||
rsync_filter: []
|
||||
@@ -0,0 +1,26 @@
|
||||
cluster_name: default
|
||||
docker:
|
||||
image: ""
|
||||
container_name: ""
|
||||
provider:
|
||||
type: local
|
||||
head_ip: YOUR_HEAD_NODE_HOSTNAME
|
||||
worker_ips: []
|
||||
auth:
|
||||
ssh_user: YOUR_USERNAME
|
||||
ssh_private_key: ~/.ssh/id_rsa
|
||||
file_mounts:
|
||||
"/tmp/ray_sha": "/YOUR/LOCAL/RAY/REPO/.git/refs/heads/YOUR_BRANCH"
|
||||
setup_commands: []
|
||||
head_setup_commands: []
|
||||
worker_setup_commands: []
|
||||
setup_commands:
|
||||
- source activate ray && test -e ray || git clone https://github.com/YOUR_GITHUB/ray.git
|
||||
- source activate ray && cd ray && git fetch && git reset --hard `cat /tmp/ray_sha`
|
||||
# - source activate ray && cd ray/python && pip install -e .
|
||||
head_start_ray_commands:
|
||||
- source activate ray && ray stop
|
||||
- source activate ray && ulimit -c unlimited && ray start --head --port=6379 --autoscaling-config=~/ray_bootstrap_config.yaml
|
||||
worker_start_ray_commands:
|
||||
- source activate ray && ray stop
|
||||
- source activate ray && ray start --address=$RAY_HEAD_IP:6379
|
||||
@@ -0,0 +1,143 @@
|
||||
# A unique identifier for the head node and workers of this cluster.
|
||||
cluster_name: default
|
||||
|
||||
# Running Ray in Docker images is optional (this docker section can be commented out).
|
||||
# This executes all commands on all nodes in the docker container,
|
||||
# and opens all the necessary ports to support the Ray cluster.
|
||||
# Empty string means disabled. Assumes Docker is installed.
|
||||
docker:
|
||||
image: "rayproject/ray-ml:latest-gpu" # You can change this to latest-cpu if you don't need GPU support and want a faster startup
|
||||
# image: rayproject/ray:latest-gpu # use this one if you don't need ML dependencies, it's faster to pull
|
||||
container_name: "ray_container"
|
||||
# If true, pulls latest version of image. Otherwise, `docker run` will only pull the image
|
||||
# if no cached version is present.
|
||||
pull_before_run: True
|
||||
run_options: # Extra options to pass into "docker run"
|
||||
- --ulimit nofile=65536:65536
|
||||
|
||||
provider:
|
||||
type: local
|
||||
head_ip: YOUR_HEAD_NODE_HOSTNAME
|
||||
# You may need to supply a public ip for the head node if you need
|
||||
# to run `ray up` from outside of the Ray cluster's network
|
||||
# (e.g. the cluster is in an AWS VPC and you're starting ray from your laptop)
|
||||
# This is useful when debugging the local node provider with cloud VMs.
|
||||
# external_head_ip: YOUR_HEAD_PUBLIC_IP
|
||||
worker_ips: [WORKER_NODE_1_HOSTNAME, WORKER_NODE_2_HOSTNAME, ... ]
|
||||
# Optional when running automatic cluster management on prem. If you use a coordinator server,
|
||||
# then you can launch multiple autoscaling clusters on the same set of machines, and the coordinator
|
||||
# will assign individual nodes to clusters as needed.
|
||||
# coordinator_address: "<host>:<port>"
|
||||
|
||||
# How Ray will authenticate with newly launched nodes.
|
||||
auth:
|
||||
ssh_user: YOUR_USERNAME
|
||||
# You can comment out `ssh_private_key` if the following machines don't need a private key for SSH access to the Ray
|
||||
# cluster:
|
||||
# (1) The machine on which `ray up` is executed.
|
||||
# (2) The head node of the Ray cluster.
|
||||
#
|
||||
# The machine that runs ray up executes SSH commands to set up the Ray head node. The Ray head node subsequently
|
||||
# executes SSH commands to set up the Ray worker nodes. When you run ray up, ssh credentials sitting on the ray up
|
||||
# machine are copied to the head node -- internally, the ssh key is added to the list of file mounts to rsync to head node.
|
||||
# ssh_private_key: ~/.ssh/id_rsa
|
||||
|
||||
# The minimum number of workers nodes to launch in addition to the head
|
||||
# node. This number should be >= 0.
|
||||
# Typically, min_workers == max_workers == len(worker_ips).
|
||||
# This field is optional.
|
||||
min_workers: TYPICALLY_THE_NUMBER_OF_WORKER_IPS
|
||||
|
||||
# The maximum number of workers nodes to launch in addition to the head node.
|
||||
# This takes precedence over min_workers.
|
||||
# Typically, min_workers == max_workers == len(worker_ips).
|
||||
# This field is optional.
|
||||
max_workers: TYPICALLY_THE_NUMBER_OF_WORKER_IPS
|
||||
# The default behavior for manually managed clusters is
|
||||
# min_workers == max_workers == len(worker_ips),
|
||||
# meaning that Ray is started on all available nodes of the cluster.
|
||||
# For automatically managed clusters, max_workers is required and min_workers defaults to 0.
|
||||
|
||||
# The autoscaler will scale up the cluster faster with higher upscaling speed.
|
||||
# E.g., if the task requires adding more nodes then autoscaler will gradually
|
||||
# scale up the cluster in chunks of upscaling_speed*currently_running_nodes.
|
||||
# This number should be > 0.
|
||||
upscaling_speed: 1.0
|
||||
|
||||
idle_timeout_minutes: 5
|
||||
|
||||
# Files or directories to copy to the head and worker nodes. The format is a
|
||||
# dictionary from REMOTE_PATH: LOCAL_PATH. E.g. you could save your conda env to an environment.yaml file, mount
|
||||
# that directory to all nodes and call `conda -n my_env -f /path1/on/remote/machine/environment.yaml`. In this
|
||||
# example paths on all nodes must be the same (so that conda can be called always with the same argument)
|
||||
file_mounts: {
|
||||
# "/path1/on/remote/machine": "/path1/on/local/machine",
|
||||
# "/path2/on/remote/machine": "/path2/on/local/machine",
|
||||
}
|
||||
|
||||
# Files or directories to copy from the head node to the worker nodes. The format is a
|
||||
# list of paths. The same path on the head node will be copied to the worker node.
|
||||
# This behavior is a subset of the file_mounts behavior. In the vast majority of cases
|
||||
# you should just use file_mounts. Only use this if you know what you're doing!
|
||||
cluster_synced_files: []
|
||||
|
||||
# Whether changes to directories in file_mounts or cluster_synced_files in the head node
|
||||
# should sync to the worker node continuously
|
||||
file_mounts_sync_continuously: False
|
||||
|
||||
# Patterns for files to exclude when running rsync up or rsync down
|
||||
rsync_exclude:
|
||||
- "**/.git"
|
||||
- "**/.git/**"
|
||||
|
||||
# Pattern files to use for filtering out files when running rsync up or rsync down. The file is searched for
|
||||
# in the source directory and recursively through all subdirectories. For example, if .gitignore is provided
|
||||
# as a value, the behavior will match git's behavior for finding and using .gitignore files.
|
||||
rsync_filter:
|
||||
- ".gitignore"
|
||||
|
||||
# List of commands that will be run before `setup_commands`. If docker is
|
||||
# enabled, these commands will run outside the container and before docker
|
||||
# is setup.
|
||||
initialization_commands: []
|
||||
|
||||
# List of shell commands to run to set up each nodes.
|
||||
setup_commands: []
|
||||
# If we have e.g. conda dependencies stored in "/path1/on/local/machine/environment.yaml", we can prepare the
|
||||
# work environment on each worker by:
|
||||
# 1. making sure each worker has access to this file i.e. see the `file_mounts` section
|
||||
# 2. adding a command here that creates a new conda environment on each node or if the environment already exists,
|
||||
# it updates it:
|
||||
# conda env create -q -n my_venv -f /path1/on/local/machine/environment.yaml || conda env update -q -n my_venv -f /path1/on/local/machine/environment.yaml
|
||||
#
|
||||
# Ray developers:
|
||||
# you probably want to create a Docker image that
|
||||
# has your Ray repo pre-cloned. Then, you can replace the pip installs
|
||||
# below with a git checkout <your_sha> (and possibly a recompile).
|
||||
# To run the nightly version of ray (as opposed to the latest), either use a rayproject docker image
|
||||
# that has the "nightly" (e.g. "rayproject/ray-ml:nightly-gpu") or uncomment the following line:
|
||||
# - pip install -U "ray[default] @ https://s3-us-west-2.amazonaws.com/ray-wheels/latest/ray-3.0.0.dev0-cp37-cp37m-manylinux2014_x86_64.whl"
|
||||
|
||||
# Custom commands that will be run on the head node after common setup.
|
||||
head_setup_commands: []
|
||||
|
||||
# Custom commands that will be run on worker nodes after common setup.
|
||||
worker_setup_commands: []
|
||||
|
||||
# Command to start ray on the head node. You don't need to change this.
|
||||
head_start_ray_commands:
|
||||
# If we have e.g. conda dependencies, we could create on each node a conda environment (see `setup_commands` section).
|
||||
# In that case we'd have to activate that env on each node before running `ray`:
|
||||
# - conda activate my_venv && ray stop
|
||||
# - conda activate my_venv && ulimit -c unlimited && ray start --head --port=6379 --autoscaling-config=~/ray_bootstrap_config.yaml
|
||||
- ray stop
|
||||
- ulimit -c unlimited && ray start --head --port=6379 --autoscaling-config=~/ray_bootstrap_config.yaml
|
||||
|
||||
# Command to start ray on worker nodes. You don't need to change this.
|
||||
worker_start_ray_commands:
|
||||
# If we have e.g. conda dependencies, we could create on each node a conda environment (see `setup_commands` section).
|
||||
# In that case we'd have to activate that env on each node before running `ray`:
|
||||
# - conda activate my_venv && ray stop
|
||||
# - ray start --address=$RAY_HEAD_IP:6379
|
||||
- ray stop
|
||||
- ray start --address=$RAY_HEAD_IP:6379
|
||||
@@ -0,0 +1,55 @@
|
||||
# Minimal configuration for an automatically managed on-premise cluster.
|
||||
|
||||
# To use, run the script at ray/python/ray/autoscaler/local/coordinator_server.py:
|
||||
# $ python coordinator_server.py --ips <list_of_node_ips> --host <HOST> --port <PORT>
|
||||
# Copy the address from the output into the coordinator_address field.
|
||||
|
||||
# A unique identifier for the head node and workers of this cluster.
|
||||
cluster_name: minimal-automatic
|
||||
|
||||
provider:
|
||||
type: local
|
||||
coordinator_address: COORDINATOR_HOST:COORDINATOR_PORT
|
||||
|
||||
# The minimum number of workers nodes to add to the Ray cluster in addition to the head
|
||||
# node. This number should be >= 0.
|
||||
# Set to 0 by default.
|
||||
min_workers: 0
|
||||
|
||||
# The maximum number of worker nodes to add to the Ray cluster in addition to the head node.
|
||||
# This takes precedence over min_workers.
|
||||
# Required for automatically managed clusters.
|
||||
max_workers: 2
|
||||
|
||||
# How Ray will authenticate with newly launched nodes.
|
||||
auth:
|
||||
ssh_user: YOUR_USERNAME
|
||||
# Optional if an ssh private key is necessary to ssh to the cluster.
|
||||
# ssh_private_key: ~/.ssh/id_rsa
|
||||
|
||||
# The above configuration assumes Ray is installed on your on-prem cluster.
|
||||
# If Ray is not already installed on your cluster, you can use setup
|
||||
# commands to install it.
|
||||
# For the latest Python 3.7 Linux wheels:
|
||||
# setup_commands:
|
||||
# - if [ $(which ray) ]; then pip uninstall ray -y; fi
|
||||
# - pip install -U "ray[default] @ https://s3-us-west-2.amazonaws.com/ray-wheels/latest/ray-3.0.0.dev0-cp37-cp37m-manylinux2014_x86_64.whl"
|
||||
|
||||
# Defaults are empty to avoid any surprise changes to on-prem cluster's state.
|
||||
# Refer to example yamls for examples of ray installation in setup commands.
|
||||
initialization_commands: []
|
||||
setup_commands: []
|
||||
head_setup_commands: []
|
||||
worker_setup_commands: []
|
||||
|
||||
available_node_types: {}
|
||||
head_node_type: {}
|
||||
|
||||
head_start_ray_commands: []
|
||||
worker_start_ray_commands: []
|
||||
|
||||
file_mounts: {}
|
||||
cluster_synced_files: []
|
||||
file_mounts_sync_continuously: false
|
||||
rsync_exclude: []
|
||||
rsync_filter: []
|
||||
@@ -0,0 +1,23 @@
|
||||
# Minimal configuration for a manually managed on-premise cluster.
|
||||
|
||||
# A unique identifier for the head node and workers of this cluster.
|
||||
cluster_name: minimal-manual
|
||||
|
||||
provider:
|
||||
type: local
|
||||
head_ip: YOUR_HEAD_NODE_HOSTNAME
|
||||
worker_ips: [WORKER_NODE_1_HOSTNAME, WORKER_NODE_2_HOSTNAME, ... ]
|
||||
|
||||
# How Ray will authenticate with newly launched nodes.
|
||||
auth:
|
||||
ssh_user: YOUR_USERNAME
|
||||
# Optional if an ssh private key is necessary to ssh to the cluster.
|
||||
# ssh_private_key: ~/.ssh/id_rsa
|
||||
|
||||
# The above configuration assumes Ray is installed on your on-prem cluster.
|
||||
# If Ray is not already installed on your cluster, you can use setup
|
||||
# commands to install it.
|
||||
# For the latest Python 3.7 Linux wheels:
|
||||
# setup_commands:
|
||||
# - if [ $(which ray) ]; then pip uninstall ray -y; fi
|
||||
# - pip install -U "ray[default] @ https://s3-us-west-2.amazonaws.com/ray-wheels/latest/ray-3.0.0.dev0-cp37-cp37m-manylinux2014_x86_64.whl"
|
||||
Reference in New Issue
Block a user