[Autoscaler] Fix resource passing bug fix (#10397)

This commit is contained in:
Alex Wu
2020-08-28 15:43:18 -07:00
committed by GitHub
parent 2afb54c99c
commit b1f3c9e10e
5 changed files with 32 additions and 26 deletions
+2 -11
View File
@@ -8,6 +8,7 @@ import os
import subprocess
import sys
import time
import json
from ray.autoscaler.docker import check_docker_running_cmd, \
check_docker_image, \
@@ -81,18 +82,9 @@ def _with_environment_variables(cmd: str,
automatically be converted to a one line yaml string.
"""
def dict_as_one_line_yaml(d):
items = []
for key, val in d.items():
item_str = "{}: {}".format(quote(str(key)), quote(str(val)))
items.append(item_str)
return "{" + ",".join(items) + "}"
as_strings = []
for key, val in environment_variables.items():
if isinstance(val, dict):
val = dict_as_one_line_yaml(val)
val = json.dumps(val, separators=(",", ":"))
s = "export {}={};".format(key, quote(val))
as_strings.append(s)
all_vars = "".join(as_strings)
@@ -102,7 +94,6 @@ def _with_environment_variables(cmd: str,
def _with_interactive(cmd):
force_interactive = ("true && source ~/.bashrc && "
"export OMP_NUM_THREADS=1 PYTHONWARNINGS=ignore && ")
return ["bash", "--login", "-c", "-i", quote(force_interactive + cmd)]