Skip to content

Commit

Permalink
Return non-zero exit code if at least 1 run failed
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp v. K committed Mar 11, 2022
1 parent 2c3a15e commit 321aecb
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
10 changes: 9 additions & 1 deletion mlonmcu/cli/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# limitations under the License.
#
import os
import sys
import multiprocessing
import logging
from mlonmcu.target import SUPPORTED_TARGETS
Expand All @@ -27,6 +28,10 @@
from mlonmcu.logging import get_logger, set_log_level
from .helper.parse import extract_config

from mlonmcu.logging import get_logger

logger = get_logger()


def handle_logging_flags(args):
if hasattr(args, "verbose") and hasattr(args, "quiet"):
Expand Down Expand Up @@ -186,11 +191,14 @@ def kickoff_runs(args, until, context):
per_stage = bool(config["runs_per_stage"])
elif "runs_per_stage" in context.environment.vars:
per_stage = bool(context.environment.vars["runs_per_stage"])
session.process_runs(
success = session.process_runs(
until=until,
per_stage=per_stage,
num_workers=args.parallel,
progress=args.progress,
context=context,
export=True,
)
if not success:
logger.error("At least one error occured!")
sys.exit(1)
1 change: 0 additions & 1 deletion mlonmcu/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

logger = get_logger()


def lookup_environment() -> Environment:
"""Helper function to automatically find a suitable environment.
Expand Down
3 changes: 3 additions & 0 deletions mlonmcu/session/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,9 @@ def get_report(self):
post["Config"] = self.get_all_configs(omit_paths=True, omit_defaults=True, omit_globals=True)
post["Postprocesses"] = self.get_all_postprocess_names()
post["Comment"] = self.comment if len(self.comment) > 0 else "-"
if self.failing:
post["Failing"] = True

self.export_stage(RunStage.RUN, optional=self.export_optional)

metrics = Metrics()
Expand Down
4 changes: 3 additions & 1 deletion mlonmcu/session/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def _used_stages(runs, until):
results = _join_workers(workers)
if num_failures == 0:
logger.info("All runs completed successfuly!")
elif num_failures == 0:
elif num_failures == num_runs:
logger.error("All runs have failed to complete!")
else:
num_success = num_runs - num_failures
Expand Down Expand Up @@ -315,6 +315,8 @@ def _used_stages(runs, until):
if print_report:
logger.info("Report:\n" + str(report.df))

return num_failures == 0

def __repr__(self):
return f"Session(idx={self.idx},status={self.status},runs={self.runs})"

Expand Down

0 comments on commit 321aecb

Please sign in to comment.