diff --git a/autosubmit/autosubmit.py b/autosubmit/autosubmit.py index fa565a28e776c8a7748b1bb3241db2be9d9d48c2..f4feb04d8be08479b898a9ecc3853a4871a54652 100644 --- a/autosubmit/autosubmit.py +++ b/autosubmit/autosubmit.py @@ -2075,6 +2075,8 @@ class Autosubmit: try: if Autosubmit.exit: Autosubmit.terminate(threading.enumerate()) + if job_list.get_failed(): + return 1 return 0 # reload parameters changes Log.debug("Reloading parameters...") @@ -2276,6 +2278,12 @@ class Autosubmit: if profile: profiler.stop() + # Suppress in case ``job_list`` was not defined yet... + with suppress(NameError): + if job_list.get_failed(): + return 1 + return 0 + @staticmethod def restore_platforms(platform_to_test, mail_notify=False, as_conf=None, expid=None): Log.info("Checking the connection to all platforms in use") diff --git a/bin/autosubmit b/bin/autosubmit index d3775fbb1d0179539f8e9de0e400f237fbb7f6b5..de9c86d3b171fe90357dc9aa5f184ff675924a6f 100755 --- a/bin/autosubmit +++ b/bin/autosubmit @@ -34,9 +34,11 @@ from autosubmit.autosubmit import Autosubmit # noinspection PyProtectedMember def main(): try: - Autosubmit.parse_args() + return_value = Autosubmit.parse_args() if os.path.exists(os.path.join(Log.file_path, "autosubmit.lock")): os.remove(os.path.join(Log.file_path, "autosubmit.lock")) + if type(return_value) is int: + os._exit(return_value) os._exit(0) except AutosubmitError as e: if os.path.exists(os.path.join(Log.file_path, "autosubmit.lock")): diff --git a/docs/source/userguide/run/index.rst b/docs/source/userguide/run/index.rst index a3b7984ad41aa10b9a3d816b74b71b2d14263a9e..e61e62f23d8e8bc0df190f2d35df4ded8925f155 100644 --- a/docs/source/userguide/run/index.rst +++ b/docs/source/userguide/run/index.rst @@ -12,7 +12,9 @@ Launch Autosubmit with the command: ssh-add ~/.ssh/id_rsa autosubmit run EXPID -*EXPID* is the experiment identifier. +In the previous command output ``EXPID`` is the experiment identifier. The command +exits with ``0`` when the workflow finishes with no failed jobs, and with ``1`` +otherwise. Options: :: @@ -40,7 +42,7 @@ Example: ssh-add ~/.ssh/id_rsa autosubmit run cxxx -.. important:: If the autosubmit version is set on autosubmit.yml it must match the actual autosubmit version +.. important:: If the autosubmit version is set on ``autosubmit.yml`` it must match the actual autosubmit version .. hint:: It is recommended to launch it in background and with ``nohup`` (continue running although the user who launched the process logs out). .. code-block:: bash