Skip to content

Commit

Permalink
HELICS Runner should return error code 1 is any federate fails (#111)
Browse files Browse the repository at this point in the history
* Return error code 1 is any federate fails

* Added error note to final cli runner message

* Undo silly last commit

---------

Co-authored-by: Joseph McKinsey <[email protected]>
Co-authored-by: Trevor Hardy <[email protected]>
  • Loading branch information
3 people authored Jan 10, 2025
1 parent de19cd6 commit fa82c94
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions helics/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import json
import os
import io
import sys
import shlex
import subprocess
import collections
Expand Down Expand Up @@ -282,10 +283,10 @@ def run(path, silent, connect_server, no_log_files, no_kill_on_error):
if helics_server_available:
fetch("/runner/file/name", {"name": os.path.basename(path_to_config)})
fetch("/runner/file/folder", {"folder": os.path.dirname(path_to_config)})
# Default to logging in the same location as the config file; this is the

# Default to logging in the same location as the config file; this is the
# historical behavior of the cli. If there's a "logging_path" in the runner
# JSON, use that path
# JSON, use that path
if "logging_path" in config.keys():
logging_path = config["logging_path"]
else:
Expand Down Expand Up @@ -361,13 +362,15 @@ def run(path, silent, connect_server, no_log_files, no_kill_on_error):
for p in process_list:
p.process.kill()
finally:
errored = False
for p in process_list:
t.status(p)
if (
p.process.returncode != 0
and p.process.returncode != -9
and p.process.returncode is not None
):
errored = True
error(
"Process {} exited with return code {}".format(
p.name, p.process.returncode
Expand All @@ -380,6 +383,8 @@ def run(path, silent, connect_server, no_log_files, no_kill_on_error):
for line in f.readlines()[-10:]:
print(line, end="")
print("...")
if errored:
sys.exit(1)

info("Done.")

Expand Down

0 comments on commit fa82c94

Please sign in to comment.