Visitar URL original
test: Stabilize CLI runner subprocess path (#6560) · feast-dev/feast@141c08c · GitHub
Skip to content

Commit 141c08c

Browse files
test: Stabilize CLI runner subprocess path (#6560)
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
1 parent c8f3149 commit 141c08c

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎sdk/python/tests/utils/cli_repo_creator.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
that can push the cumulative test time past the pytest global timeout budget.
2020
"""
2121

22+
import os
2223
import random
2324
import string
2425
import subprocess
@@ -53,6 +54,15 @@ class CliRunner:
5354
modules from the feature repo, and it is hard to clean up that state otherwise.
5455
"""
5556

57+
def _subprocess_env(self) -> dict[str, str]:
58+
env = os.environ.copy()
59+
parent_paths = [path for path in sys.path if path]
60+
existing_pythonpath = env.get("PYTHONPATH")
61+
if existing_pythonpath:
62+
parent_paths.append(existing_pythonpath)
63+
env["PYTHONPATH"] = os.pathsep.join(parent_paths)
64+
return env
65+
5666
def run(self, args: List[str], cwd: Path) -> subprocess.CompletedProcess:
5767
# Apply a conservative timeout to prevent CI hangs from Dask atexit-handler
5868
# stalls or other subprocess blockages.
@@ -64,6 +74,7 @@ def run(self, args: List[str], cwd: Path) -> subprocess.CompletedProcess:
6474
cwd=cwd,
6575
capture_output=True,
6676
timeout=timeout,
77+
env=self._subprocess_env(),
6778
)
6879
except subprocess.TimeoutExpired:
6980
return subprocess.CompletedProcess(
@@ -87,6 +98,7 @@ def run_with_output(self, args: List[str], cwd: Path) -> Tuple[int, bytes]:
8798
cwd=cwd,
8899
stdout=subprocess.PIPE,
89100
stderr=subprocess.STDOUT,
101+
env=self._subprocess_env(),
90102
)
91103
try:
92104
stdout, _ = proc.communicate(timeout=timeout)

0 commit comments

Comments
 (0)