ensure the main process raise an exception when the subprocess fails (#18663)
This commit is contained in:
parent
e3c68cd1d4
commit
353aaff034
@ -20,14 +20,13 @@ def setup_package():
|
|||||||
shell=True,
|
shell=True,
|
||||||
)
|
)
|
||||||
print(build_process.stdout)
|
print(build_process.stdout)
|
||||||
match = re.search(
|
whl_path = re.findall(
|
||||||
r"\s[^\s]*\.whl",
|
r"[^\s]*\.whl",
|
||||||
build_process.stdout,
|
build_process.stdout,
|
||||||
)
|
)[-1]
|
||||||
if not match:
|
if not whl_path:
|
||||||
raise ValueError("Installing Keras package unsuccessful. ")
|
|
||||||
print(build_process.stderr)
|
print(build_process.stderr)
|
||||||
whl_path = match.group()
|
raise ValueError("Installing Keras package unsuccessful. ")
|
||||||
return whl_path
|
return whl_path
|
||||||
|
|
||||||
|
|
||||||
@ -82,18 +81,21 @@ def cleanup():
|
|||||||
|
|
||||||
def run_commands_local(commands):
|
def run_commands_local(commands):
|
||||||
for command in commands:
|
for command in commands:
|
||||||
|
print(f"Running command: {command}")
|
||||||
subprocess.run(command, shell=True)
|
subprocess.run(command, shell=True)
|
||||||
|
|
||||||
|
|
||||||
def run_commands_venv(commands):
|
def run_commands_venv(commands):
|
||||||
for command in commands:
|
for command in commands:
|
||||||
|
print(f"Running command: {command}")
|
||||||
cmd_with_args = command.split(" ")
|
cmd_with_args = command.split(" ")
|
||||||
cmd_with_args[0] = "test_env/bin/" + cmd_with_args[0]
|
cmd_with_args[0] = "test_env/bin/" + cmd_with_args[0]
|
||||||
p = subprocess.Popen(cmd_with_args)
|
p = subprocess.Popen(cmd_with_args)
|
||||||
p.wait()
|
assert p.wait() == 0
|
||||||
|
|
||||||
|
|
||||||
def test_keras_imports():
|
def test_keras_imports():
|
||||||
|
try:
|
||||||
# Ensures packages from all backends are installed.
|
# Ensures packages from all backends are installed.
|
||||||
# Builds Keras core package and returns package file path.
|
# Builds Keras core package and returns package file path.
|
||||||
whl_path = setup_package()
|
whl_path = setup_package()
|
||||||
@ -110,6 +112,7 @@ def test_keras_imports():
|
|||||||
run_keras_flow()
|
run_keras_flow()
|
||||||
|
|
||||||
# Removes virtual environment and associated files
|
# Removes virtual environment and associated files
|
||||||
|
finally:
|
||||||
cleanup()
|
cleanup()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user