Skip to content

Commit

Permalink
dws: improve error message
Browse files Browse the repository at this point in the history
Problem: when coral2_dws.py is not running as a Flux job,
the error message is unclear.

Clarify the error.
  • Loading branch information
jameshcorbett committed Feb 1, 2023
1 parent b416543 commit b52eeb7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/modules/coral2_dws.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit b52eeb7

Please sign in to comment.