From f453deb5c832bdbef7827d9e6a2bd15dbb785e7b Mon Sep 17 00:00:00 2001 From: Vaggelis Date: Sun, 23 Aug 2026 12:50:58 -0400 Subject: [PATCH 1/2] polygraphy: fix POLYGRAPHY_ASK_BEFORE_INSTALL parsing The default value passed to os.environ.get was the boolean expression "0" != "0" instead of the string "0", so the lookup could never return a falsy default and bool("0") is True. Setting POLYGRAPHY_ASK_BEFORE_INSTALL=0 thereby enabled the prompt it was meant to disable. Use the same get(KEY, "0") != "0" idiom as the neighboring flags, and cover all three cases (unset, 0, 1) with a regression test that reloads the config module. Test Plan: cd tools/Polygraphy PYTHONPATH=$PWD python -m pytest tests/test_config.py -v fails before the fix on the =0 case (assert not True), passes after PYTHONPATH=$PWD python -m pytest tests/test_config.py tests/comparator tests/common -q identical failure set to the suites alone (all pre-existing environment failures), proving no reload side effects or ordering dependence Signed-off-by: Vaggelis --- tools/Polygraphy/CHANGELOG.md | 4 +++ tools/Polygraphy/polygraphy/config.py | 2 +- tools/Polygraphy/tests/test_config.py | 44 +++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 tools/Polygraphy/tests/test_config.py diff --git a/tools/Polygraphy/CHANGELOG.md b/tools/Polygraphy/CHANGELOG.md index 35c33eaf5..7d26ba04e 100644 --- a/tools/Polygraphy/CHANGELOG.md +++ b/tools/Polygraphy/CHANGELOG.md @@ -2,6 +2,10 @@ Dates are in YYYY-MM-DD format. +## v0.49.28 +### Fixed +- Fixed a bug where setting `POLYGRAPHY_ASK_BEFORE_INSTALL=0` would enable asking before installing dependencies instead of disabling it. + ## v0.49.27 ### Added - Added `polygraphy template shard-hints` to generate hints file for `polygraphy multi-device shard`. diff --git a/tools/Polygraphy/polygraphy/config.py b/tools/Polygraphy/polygraphy/config.py index fde1a1883..bcb763a73 100644 --- a/tools/Polygraphy/polygraphy/config.py +++ b/tools/Polygraphy/polygraphy/config.py @@ -31,7 +31,7 @@ This can be configured by setting the 'POLYGRAPHY_AUTOINSTALL_DEPS' environment variable. """ -ASK_BEFORE_INSTALL = bool(os.environ.get("POLYGRAPHY_ASK_BEFORE_INSTALL", "0" != "0")) +ASK_BEFORE_INSTALL = bool(os.environ.get("POLYGRAPHY_ASK_BEFORE_INSTALL", "0") != "0") """ bool: Whether Polygraphy should ask before automatically installing required Python packages. Has no effect if AUTOINSTALL_DEPS is not enabled. diff --git a/tools/Polygraphy/tests/test_config.py b/tools/Polygraphy/tests/test_config.py new file mode 100644 index 000000000..7a6737b39 --- /dev/null +++ b/tools/Polygraphy/tests/test_config.py @@ -0,0 +1,44 @@ +# +# SPDX-FileCopyrightText: Copyright (c) 1993-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import importlib +import os + +from polygraphy import config + + +class TestConfigEnvVars: + def test_ask_before_install(self): + key = "POLYGRAPHY_ASK_BEFORE_INSTALL" + prev = os.environ.pop(key, None) + try: + importlib.reload(config) + assert not config.ASK_BEFORE_INSTALL + + os.environ[key] = "0" + importlib.reload(config) + assert not config.ASK_BEFORE_INSTALL + + os.environ[key] = "1" + importlib.reload(config) + assert config.ASK_BEFORE_INSTALL + finally: + if prev is not None: + os.environ[key] = prev + else: + os.environ.pop(key, None) + importlib.reload(config) From 4e279d9fac550cb3e1376d1ae78b304366338248 Mon Sep 17 00:00:00 2001 From: Vaggelis Date: Mon, 24 Aug 2026 07:36:18 -0400 Subject: [PATCH 2/2] polygraphy: move ask-before-install changelog entry under v0.49.27 Upstream appends entries for unreleased changes to the existing undated version section rather than opening a new heading. Signed-off-by: Vaggelis --- tools/Polygraphy/CHANGELOG.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tools/Polygraphy/CHANGELOG.md b/tools/Polygraphy/CHANGELOG.md index 7d26ba04e..d6da60ea3 100644 --- a/tools/Polygraphy/CHANGELOG.md +++ b/tools/Polygraphy/CHANGELOG.md @@ -2,10 +2,6 @@ Dates are in YYYY-MM-DD format. -## v0.49.28 -### Fixed -- Fixed a bug where setting `POLYGRAPHY_ASK_BEFORE_INSTALL=0` would enable asking before installing dependencies instead of disabling it. - ## v0.49.27 ### Added - Added `polygraphy template shard-hints` to generate hints file for `polygraphy multi-device shard`. @@ -17,6 +13,7 @@ Dates are in YYYY-MM-DD format. ### Fixed - Fixed issue when `polygraphy multi-device shard` would exceed python recursive depth limit on large models. +- Fixed a bug where setting `POLYGRAPHY_ASK_BEFORE_INSTALL=0` would enable asking before installing dependencies instead of disabling it. ## v0.49.26 (2025-07-16)