python/ray/_private/test_utils.py
def run_string_as_driver(driver_script: str, env: Dict = None, encode: str = "utf-8"):
    """Run a driver as a separate process.

    Args:
        driver_script (str): A string to run as a Python script.
        env (dict): The environment variables for the driver.

    Returns:
        The script's output.
    """
    proc = subprocess.Popen(
        [sys.executable, "-"],
        stdin=subprocess.PIPE,
        stdout=subprocess.PIPE,
        stderr=subprocess.STDOUT,
        env=env,
    )
    with proc:
        output = proc.communicate(driver_script.encode(encoding=encode))[0]
        if proc.returncode:
            print(ray._private.utils.decode(output, encode_type=encode))
            raise subprocess.CalledProcessError(
                proc.returncode, proc.args, output, proc.stderr
            )
        out = ray._private.utils.decode(output, encode_type=encode)
    return out
Run a driver as a separate process.

    Args:
        driver_script (str): A string to run as a Python script.
        env (dict): The environment variables for the driver.

    Returns:
        The script's output.
    
Run a driver as a separate process.
Run a driver as a separate process .
def run_string_as_driver(driver_script: str, env: Dict = None, encode: str = "utf-8"):
    proc = subprocess.Popen(
        [sys.executable, "-"],
        stdin=subprocess.PIPE,
        stdout=subprocess.PIPE,
        stderr=subprocess.STDOUT,
        env=env,
    )
    with proc:
        output = proc.communicate(driver_script.encode(encoding=encode))[0]
        if proc.returncode:
            print(ray._private.utils.decode(output, encode_type=encode))
            raise subprocess.CalledProcessError(
                proc.returncode, proc.args, output, proc.stderr
            )
        out = ray._private.utils.decode(output, encode_type=encode)
    return out
def run_string_as_driver ( driver_script : str , env : Dict = None , encode : str = "utf-8" ) : proc = subprocess . Popen ( [ sys . executable , "-" ] , stdin = subprocess . PIPE , stdout = subprocess . PIPE , stderr = subprocess . STDOUT , env = env , ) with proc : output = proc . communicate ( driver_script . encode ( encoding = encode ) ) [ 0 ] if proc . returncode : print ( ray . _private . utils . decode ( output , encode_type = encode ) ) raise subprocess . CalledProcessError ( proc . returncode , proc . args , output , proc . stderr ) out = ray . _private . utils . decode ( output , encode_type = encode ) return out
Run a driver as a separate process.
Run a driver as a separate process .
"""Run a driver as a separate process.

    Args:
        driver_script (str): A string to run as a Python script.
        env (dict): The environment variables for the driver.

    Returns:
        The script's output.
    """
The script's output.
The script ' s output .
driver_script
str
A string to run as a Python script.
A string to run as a Python script .
env
Dict
The environment variables for the driver.
The environment variables for the driver .
encode
str