From 33a8e47c2c45a363915f50063c72b59ed0421c38 Mon Sep 17 00:00:00 2001 From: Larry Singleton <166439969+larrysingleton007@users.noreply.github.com> Date: Wed, 12 Aug 2026 19:03:57 -0500 Subject: [PATCH] fix: Resolve kserve with pip --dry-run instead of installing it test_install_kserve_with_feast installed kserve into the interpreter running the suite, with no isolation and no cleanup, so it mutated the environment every other test was using. Feast pins psutil==5.9.0 and kserve requires psutil>=5.9.6, so pip could not leave the installed version alone: it uninstalled psutil before reinstalling 5.9.8. The unit suite runs pytest -n 8 against one environment, so any test importing psutil in that window failed, including every test that shells out to the CLI, since feast.metrics imports it at module scope. That is how an unrelated docs PR got a red unit-test-python job on test_3rd_party_providers with ModuleNotFoundError: No module named 'psutil'. Being timing-dependent, it read as flake. kserve also pulled protobuf down to 4.25.x, which left the environment broken for the next run: the installed grpcio-health-checking ships protobuf 6.x gencode importing google.protobuf.runtime_version. The first run passed because collection imports precede the mid-run install; the second failed at collection. --dry-run performs the same resolution and still exits non-zero when the versions cannot be satisfied together, which is what the test guards against, without installing anything. Verified both directions: a clean resolution exits 0 and leaves psutil at 5.9.0 with kserve not importable, and 'pip install --dry-run kserve==0.15.2 psutil==5.9.0' exits 1 with conflicting dependencies. Also replaces the conflict assertion, which was inverted - it was only true when pip reported conflicts without an error, so a loud failure set it to False. The exit code was already doing the real work; it now carries pip's output for diagnosis. The full unit suite now passes twice in a row: 2529 passed, 20 skipped both times, with psutil and protobuf unchanged after the first. Closes #6732 Signed-off-by: Larry Singleton <166439969+larrysingleton007@users.noreply.github.com> --- .../unit/infra/test_dependency_conflicts.py | 37 +++++++++++++++---- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/sdk/python/tests/unit/infra/test_dependency_conflicts.py b/sdk/python/tests/unit/infra/test_dependency_conflicts.py index 8b0b39569e3..4e4634d1bbc 100644 --- a/sdk/python/tests/unit/infra/test_dependency_conflicts.py +++ b/sdk/python/tests/unit/infra/test_dependency_conflicts.py @@ -8,11 +8,29 @@ class TestDependencyConflicts: def test_install_kserve_with_feast(self): - """Test installing KServe in the current environment where Feast is already installed. - Ensures no dependency conflict errors occur. + """Resolve KServe against the environment Feast is installed in. + + ``--dry-run`` makes pip resolve the full dependency set and report what + it would install, without installing anything. Resolution is the part + this test cares about: pip exits non-zero when the versions cannot be + satisfied together, which is the conflict being guarded against. + + Installing for real would mutate the interpreter running the suite. + Feast pins ``psutil==5.9.0`` while KServe requires ``psutil>=5.9.6``, so + pip has to uninstall psutil before reinstalling it, and the unit suite + runs under ``pytest -n 8`` against a single environment. Any test that + imports psutil during that window fails, including every test that + shells out to the CLI, since ``feast.metrics`` imports it at module + scope. It also left the environment inconsistent for the next run. """ - # Command to install KServe - command = [sys.executable, "-m", "pip", "install", "kserve==0.15.2"] + command = [ + sys.executable, + "-m", + "pip", + "install", + "--dry-run", + "kserve==0.15.2", + ] process = subprocess.Popen( command, stdout=subprocess.PIPE, stderr=subprocess.PIPE @@ -26,7 +44,10 @@ def test_install_kserve_with_feast(self): logger.debug(out) logger.debug(err) - # Assertions - assert exit_code == 0 - conflict_occured = "dependency conflicts" in err and "ERROR" not in err - assert not conflict_occured, "Dependency conflict detected during installation" + # pip reports an unsatisfiable set on stdout and exits non-zero, so the + # exit code is the assertion that matters; the message is for the + # failure output. + assert exit_code == 0, ( + f"pip could not resolve kserve==0.15.2 against the current " + f"environment:\n{out}\n{err}" + )