[autoscaler/docker] Migrate --docker to --run-env (#9001)

This commit is contained in:
Ian Rodney
2020-06-25 20:37:42 -07:00
committed by GitHub
parent 11bda7272b
commit 42631c5b87
5 changed files with 94 additions and 71 deletions
+13 -17
View File
@@ -16,7 +16,7 @@ import ray.services as services
from ray.autoscaler.commands import (
attach_cluster, exec_cluster, create_or_update_cluster, monitor_cluster,
rsync, teardown_cluster, get_head_node_ip, kill_node, get_worker_node_ips,
debug_status)
debug_status, RUN_ENV_TYPES)
import ray.ray_constants as ray_constants
import ray.utils
from ray.projects.scripts import project_cli, session_cli
@@ -831,11 +831,6 @@ def rsync_up(cluster_config_file, source, target, cluster_name, all_nodes):
@cli.command(context_settings={"ignore_unknown_options": True})
@click.argument("cluster_config_file", required=True, type=str)
@click.option(
"--docker",
is_flag=True,
default=False,
help="Runs command in the docker container specified in cluster_config.")
@click.option(
"--stop",
is_flag=True,
@@ -873,8 +868,8 @@ def rsync_up(cluster_config_file, source, target, cluster_name, all_nodes):
type=str,
help="(deprecated) Use '-- --arg1 --arg2' for script args.")
@click.argument("script_args", nargs=-1)
def submit(cluster_config_file, docker, screen, tmux, stop, start,
cluster_name, port_forward, script, args, script_args):
def submit(cluster_config_file, screen, tmux, stop, start, cluster_name,
port_forward, script, args, script_args):
"""Uploads and runs a script on the specified cluster.
The script is automatically synced to the following location:
@@ -897,8 +892,7 @@ def submit(cluster_config_file, docker, screen, tmux, stop, start,
create_or_update_cluster(cluster_config_file, None, None, False, False,
True, cluster_name)
target = os.path.basename(script)
if not docker:
target = os.path.join("~", target)
target = os.path.join("~", target)
rsync(cluster_config_file, script, target, cluster_name, down=False)
command_parts = ["python", target]
@@ -912,7 +906,7 @@ def submit(cluster_config_file, docker, screen, tmux, stop, start,
exec_cluster(
cluster_config_file,
cmd,
docker,
"docker",
screen,
tmux,
stop,
@@ -925,10 +919,12 @@ def submit(cluster_config_file, docker, screen, tmux, stop, start,
@click.argument("cluster_config_file", required=True, type=str)
@click.argument("cmd", required=True, type=str)
@click.option(
"--docker",
is_flag=True,
default=False,
help="Runs command in the docker container specified in cluster_config.")
"--run-env",
required=False,
type=click.Choice(RUN_ENV_TYPES),
default="auto",
help="Choose whether to execute this command in a container or directly on"
" the cluster head. Only applies when docker is configured in the YAML.")
@click.option(
"--stop",
is_flag=True,
@@ -959,11 +955,11 @@ def submit(cluster_config_file, docker, screen, tmux, stop, start,
multiple=True,
type=int,
help="Port to forward. Use this multiple times to forward multiple ports.")
def exec_cmd(cluster_config_file, cmd, docker, screen, tmux, stop, start,
def exec_cmd(cluster_config_file, cmd, run_env, screen, tmux, stop, start,
cluster_name, port_forward):
"""Execute a command via SSH on a Ray cluster."""
port_forward = [(port, port) for port in list(port_forward)]
exec_cluster(cluster_config_file, cmd, docker, screen, tmux, stop, start,
exec_cluster(cluster_config_file, cmd, run_env, screen, tmux, stop, start,
cluster_name, port_forward)