From b52eeb746c53b74a3fccccf12fb0b7084a85c6bf Mon Sep 17 00:00:00 2001 From: James Corbett Date: Tue, 31 Jan 2023 16:50:03 -0800 Subject: [PATCH] dws: improve error message Problem: when coral2_dws.py is not running as a Flux job, the error message is unclear. Clarify the error. --- src/modules/coral2_dws.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/coral2_dws.py b/src/modules/coral2_dws.py index a6558e8..577d63d 100755 --- a/src/modules/coral2_dws.py +++ b/src/modules/coral2_dws.py @@ -370,6 +370,10 @@ def main(): parser.add_argument("--watch-interval", type=int, default=5) parser.add_argument("--verbose", "-v", action="count", default=0) args = parser.parse_args() + try: + jobid = id_parse(os.environ["FLUX_JOB_ID"]) + except KeyError as keyerr: + raise RuntimeError("this script is meant to be run as a Flux job") from keyerr log_level = logging.WARNING if args.verbose > 1: log_level = logging.INFO @@ -428,7 +432,6 @@ def main(): # process starting and the `dws` service being registered. Once # https://github.com/flux-framework/flux-core/issues/3821 is # implemented/closed, this can be replaced with that solution. - jobid = id_parse(os.environ["FLUX_JOB_ID"]) Future(fh.job_raise(jobid, "exception", 7, "dws watchers setup")).get() fh.reactor_run()