Get the environment variables to copy to downstream Ray actors.
Example use cases: - Copy environment variables from RayDistributedExecutor to Ray workers. - Copy environment variables from RayDPClient to Ray DPEngineCoreActor.
Parameters:
| Name | Type | Description | Default |
exclude_vars | set[str] | None | A set of vllm defined environment variables to exclude from copying. | None |
additional_vars | set[str] | None | A set of additional environment variables to copy. If a variable is in both exclude_vars and additional_vars, it will be excluded. | None |
destination | str | None | The destination of the environment variables. | None |
Returns: A set of environment variables to copy.
Source code in vllm/ray/ray_env.py
| def get_env_vars_to_copy(
exclude_vars: set[str] | None = None,
additional_vars: set[str] | None = None,
destination: str | None = None,
) -> set[str]:
"""
Get the environment variables to copy to downstream Ray actors.
Example use cases:
- Copy environment variables from RayDistributedExecutor to Ray workers.
- Copy environment variables from RayDPClient to Ray DPEngineCoreActor.
Args:
exclude_vars: A set of vllm defined environment variables to exclude
from copying.
additional_vars: A set of additional environment variables to copy.
If a variable is in both exclude_vars and additional_vars, it will
be excluded.
destination: The destination of the environment variables.
Returns:
A set of environment variables to copy.
"""
exclude_vars = exclude_vars or set()
additional_vars = additional_vars or set()
env_vars_to_copy = {
v
for v in set(envs.environment_variables).union(additional_vars)
if v not in exclude_vars and v not in RAY_NON_CARRY_OVER_ENV_VARS
}
to_destination = " to " + destination if destination is not None else ""
logger.info(
"RAY_NON_CARRY_OVER_ENV_VARS from config: %s", RAY_NON_CARRY_OVER_ENV_VARS
)
logger.info(
"Copying the following environment variables%s: %s",
to_destination,
[v for v in env_vars_to_copy if v in os.environ],
)
logger.info(
"If certain env vars should NOT be copied, add them to %s file",
RAY_NON_CARRY_OVER_ENV_VARS_FILE,
)
return env_vars_to_copy
|