Skip to content

Commit 01da132

Browse files
larrysingleton007ntkathole
authored andcommitted
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 <[email protected]>
1 parent a9219d9 commit 01da132

1 file changed

Lines changed: 29 additions & 8 deletions

File tree

‎sdk/python/tests/unit/infra/test_dependency_conflicts.py‎

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,29 @@
88

99
class TestDependencyConflicts:
1010
def test_install_kserve_with_feast(self):
11-
"""Test installing KServe in the current environment where Feast is already installed.
12-
Ensures no dependency conflict errors occur.
11+
"""Resolve KServe against the environment Feast is installed in.
12+
13+
``--dry-run`` makes pip resolve the full dependency set and report what
14+
it would install, without installing anything. Resolution is the part
15+
this test cares about: pip exits non-zero when the versions cannot be
16+
satisfied together, which is the conflict being guarded against.
17+
18+
Installing for real would mutate the interpreter running the suite.
19+
Feast pins ``psutil==5.9.0`` while KServe requires ``psutil>=5.9.6``, so
20+
pip has to uninstall psutil before reinstalling it, and the unit suite
21+
runs under ``pytest -n 8`` against a single environment. Any test that
22+
imports psutil during that window fails, including every test that
23+
shells out to the CLI, since ``feast.metrics`` imports it at module
24+
scope. It also left the environment inconsistent for the next run.
1325
"""
14-
# Command to install KServe
15-
command = [sys.executable, "-m", "pip", "install", "kserve==0.15.2"]
26+
command = [
27+
sys.executable,
28+
"-m",
29+
"pip",
30+
"install",
31+
"--dry-run",
32+
"kserve==0.15.2",
33+
]
1634

1735
process = subprocess.Popen(
1836
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE
@@ -26,7 +44,10 @@ def test_install_kserve_with_feast(self):
2644
logger.debug(out)
2745
logger.debug(err)
2846

29-
# Assertions
30-
assert exit_code == 0
31-
conflict_occured = "dependency conflicts" in err and "ERROR" not in err
32-
assert not conflict_occured, "Dependency conflict detected during installation"
47+
# pip reports an unsatisfiable set on stdout and exits non-zero, so the
48+
# exit code is the assertion that matters; the message is for the
49+
# failure output.
50+
assert exit_code == 0, (
51+
f"pip could not resolve kserve==0.15.2 against the current "
52+
f"environment:\n{out}\n{err}"
53+
)

0 commit comments

Comments
 (0)