From 649d5f4105edd0c8b222ad6f422a86ce40c530cc Mon Sep 17 00:00:00 2001 From: Wendell Hom Date: Fri, 6 Feb 2026 20:43:40 -0800 Subject: [PATCH 1/3] Don't use SCCACHE_MEMCACHED_ENDPOINT if it is not valid --- utilities/cli/container.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/utilities/cli/container.py b/utilities/cli/container.py index 88c6787712..012823998d 100644 --- a/utilities/cli/container.py +++ b/utilities/cli/container.py @@ -20,6 +20,7 @@ import re import shlex import shutil +import socket import stat import subprocess import sys @@ -726,6 +727,27 @@ def get_gpu_runtime_args(self) -> List[str]: args.extend(self.get_device_cgroup_args()) return args + def is_valid_endpoint(self) -> bool: + """Check if SCCACHE_MEMCACHED_ENDPOINT is valid""" + endpoint = os.environ.get("SCCACHE_MEMCACHED_ENDPOINT") + + if endpoint: + try: + host, port_str = endpoint.rsplit(":", 1) + port = int(port_str) + + with socket.create_connection((host, port), timeout=5): + print(f" > Using memcached endpoint {endpoint}") + return True + + except Exception: + print( + f" > Warning: Memcached endpoint {endpoint} is not reachable, " + "falling back to local caching." + ) + + return False + def get_environment_args(self) -> List[str]: """Environment variable arguments""" args = [ @@ -757,7 +779,7 @@ def get_environment_args(self) -> List[str]: args.extend(["-e", f"SCCACHE_DIR={SCCACHE_CONTAINER_DIR}"]) # Forward other SCCACHE_* environment variables present on host for k in sccache_keys: - if k != "SCCACHE_DIR": + if (k != "SCCACHE_DIR") and (k != "SCCACHE_MEMCACHED_ENDPOINT" or self.is_valid_endpoint()): args.extend(["-e", k]) elif len(sccache_keys) > 0: warn( From e873ba32972a609b1be322cf28b0e818afb1e497 Mon Sep 17 00:00:00 2001 From: Wendell Hom Date: Sat, 14 Feb 2026 19:35:08 -0800 Subject: [PATCH 2/3] Update to use info / warn --- utilities/cli/container.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utilities/cli/container.py b/utilities/cli/container.py index 012823998d..5c1f960f62 100644 --- a/utilities/cli/container.py +++ b/utilities/cli/container.py @@ -737,12 +737,12 @@ def is_valid_endpoint(self) -> bool: port = int(port_str) with socket.create_connection((host, port), timeout=5): - print(f" > Using memcached endpoint {endpoint}") + info(f" > Using memcached endpoint {endpoint}") return True except Exception: - print( - f" > Warning: Memcached endpoint {endpoint} is not reachable, " + warn( + f" > Memcached endpoint {endpoint} is not reachable, " "falling back to local caching." ) From 3b542c4f74b7d43df59eddd3368122ea9dd82c87 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 7 Mar 2026 04:08:32 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- utilities/cli/container.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utilities/cli/container.py b/utilities/cli/container.py index fd8d048b0e..d527421791 100644 --- a/utilities/cli/container.py +++ b/utilities/cli/container.py @@ -779,7 +779,9 @@ def get_environment_args(self) -> List[str]: args.extend(["-e", f"SCCACHE_DIR={SCCACHE_CONTAINER_DIR}"]) # Forward other SCCACHE_* environment variables present on host for k in sccache_keys: - if (k != "SCCACHE_DIR") and (k != "SCCACHE_MEMCACHED_ENDPOINT" or self.is_valid_endpoint()): + if (k != "SCCACHE_DIR") and ( + k != "SCCACHE_MEMCACHED_ENDPOINT" or self.is_valid_endpoint() + ): args.extend(["-e", k]) elif len(sccache_keys) > 0: warn(