Convert formatting to use ruff instead of yapf + isort (#26247)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
Harry Mellor
2025-10-05 15:06:22 +01:00
committed by GitHub
parent 17edd8a807
commit d6953beb91
1508 changed files with 115244 additions and 94146 deletions

View File

@@ -6,6 +6,7 @@ def is_ray_initialized():
"""Check if Ray is initialized."""
try:
import ray
return ray.is_initialized()
except ImportError:
return False
@@ -16,7 +17,10 @@ def is_in_ray_actor():
try:
import ray
return (ray.is_initialized()
and ray.get_runtime_context().get_actor_id() is not None)
return (
ray.is_initialized()
and ray.get_runtime_context().get_actor_id() is not None
)
except ImportError:
return False

View File

@@ -14,7 +14,8 @@ CONFIG_HOME = envs.VLLM_CONFIG_ROOT
# This file contains a list of env vars that should not be copied
# from the driver to the Ray workers.
RAY_NON_CARRY_OVER_ENV_VARS_FILE = os.path.join(
CONFIG_HOME, "ray_non_carry_over_env_vars.json")
CONFIG_HOME, "ray_non_carry_over_env_vars.json"
)
try:
if os.path.exists(RAY_NON_CARRY_OVER_ENV_VARS_FILE):
@@ -25,13 +26,16 @@ try:
except json.JSONDecodeError:
logger.warning(
"Failed to parse %s. Using an empty set for non-carry-over env vars.",
RAY_NON_CARRY_OVER_ENV_VARS_FILE)
RAY_NON_CARRY_OVER_ENV_VARS_FILE,
)
RAY_NON_CARRY_OVER_ENV_VARS = set()
def get_env_vars_to_copy(exclude_vars: Optional[set[str]] = None,
additional_vars: Optional[set[str]] = None,
destination: Optional[str] = None) -> set[str]:
def get_env_vars_to_copy(
exclude_vars: Optional[set[str]] = None,
additional_vars: Optional[set[str]] = None,
destination: Optional[str] = None,
) -> set[str]:
"""
Get the environment variables to copy to downstream Ray actors.
@@ -60,13 +64,17 @@ def get_env_vars_to_copy(exclude_vars: Optional[set[str]] = None,
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)
"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