From bd26e938d3095e2425d74f7ba00ff2a17fd01bac Mon Sep 17 00:00:00 2001 From: Abishek Sethuraman Date: Mon, 29 Sep 2025 12:23:19 -0700 Subject: [PATCH] Make it possible for users to disable .torchxconfig (#1125) Summary: X-link: https://github.com/pytorch/torchx/pull/1125 So that the one below is valid and does not use any configs ``` TORCHXCONFIG="" torchx run ``` Reviewed By: kiukchung Differential Revision: D83086473 --- torchx/runner/config.py | 2 ++ torchx/runner/test/config_test.py | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/torchx/runner/config.py b/torchx/runner/config.py index ab8e52711..2ae253b96 100644 --- a/torchx/runner/config.py +++ b/torchx/runner/config.py @@ -494,6 +494,8 @@ def find_configs(dirs: Optional[Iterable[str]] = None) -> List[str]: config = os.getenv(ENV_TORCHXCONFIG) if config is not None: + if not config: + return [] configfile = Path(config) if not configfile.is_file(): raise FileNotFoundError( diff --git a/torchx/runner/test/config_test.py b/torchx/runner/test/config_test.py index 6abff46fa..2c0eaa0cb 100644 --- a/torchx/runner/test/config_test.py +++ b/torchx/runner/test/config_test.py @@ -275,6 +275,12 @@ def test_get_configs(self) -> None: ), ) + def test_no_config(self) -> None: + config_dir = self.tmpdir + with patch.dict(os.environ, {ENV_TORCHXCONFIG: str("")}): + configs = find_configs(dirs=[str(config_dir)]) + self.assertEqual([], configs) + def test_find_configs(self) -> None: config_dir = self.tmpdir cwd_dir = config_dir / "cwd"