Skip to content

Commit

Permalink
Check forked process calls for success during app installation. (#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
csadorf committed Jul 28, 2022
1 parent 7c11f52 commit 3505e64
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 6 additions & 1 deletion aiidalab/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ def _pip_install(*args, stdout):
process = run_pip_install(*args, python_bin=python_bin)
for line in io.TextIOWrapper(process.stdout, encoding="utf-8"):
stdout.write(line)
if process.returncode != 0:
raise RuntimeError("Failed to install dependencies.")

# AiiDA plugins require reentry run to be found by AiiDA.
process = run_reentry_scan()
Expand All @@ -280,6 +282,8 @@ def _pip_install(*args, stdout):
process = run_verdi_daemon_restart()
for line in io.TextIOWrapper(process.stdout, encoding="utf-8"):
stdout.write(line)
if process.returncode != 0:
raise RuntimeError("Failed to restart verdi daemon.")

for path in (self.path.joinpath(".aiidalab"), self.path):
if path.exists():
Expand Down Expand Up @@ -312,7 +316,8 @@ def _post_install_triggers(self):
# detachment of child processes. For example, an app might trigger
# a background process that is supposed to finish after the
# installation is technically completed.
run_post_install_script(post_install_file)
if run_post_install_script(post_install_file).returncode != 0:
raise CalledProcessError

def _install_from_path(self, path):
if path.is_dir():
Expand Down
2 changes: 0 additions & 2 deletions aiidalab/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ def this_or_only_subdir(path):
def run_pip_install(*args, python_bin=sys.executable):
return subprocess.Popen(
[python_bin, "-m", "pip", "install", *args],
bufsize=1,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
Expand All @@ -219,7 +218,6 @@ def run_reentry_scan():
def run_verdi_daemon_restart():
return subprocess.Popen(
["verdi", "daemon", "restart"],
bufsize=1,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
Expand Down

0 comments on commit 3505e64

Please sign in to comment.