From ea50b5379355ed2046dd6094021c775b5551e975 Mon Sep 17 00:00:00 2001 From: Tim Pillinger <26465611+wxtim@users.noreply.github.com> Date: Wed, 31 Jan 2024 12:49:18 +0000 Subject: [PATCH] loosen xargs validation checks --- cylc/flow/xtriggers/xrandom.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cylc/flow/xtriggers/xrandom.py b/cylc/flow/xtriggers/xrandom.py index 2fe5ebe1d71..6e952f4ae97 100644 --- a/cylc/flow/xtriggers/xrandom.py +++ b/cylc/flow/xtriggers/xrandom.py @@ -108,7 +108,7 @@ def validate(f_args, f_kwargs, f_signature): if n_args + n_kwargs > 3: raise WorkflowConfigError(f"Too many args: {f_signature}") - if n_args != 1: + if n_args + n_kwargs < 1: raise WorkflowConfigError(f"Wrong number of args: {f_signature}") if n_kwargs: @@ -123,16 +123,17 @@ def validate(f_args, f_kwargs, f_signature): try: percent = f_kwargs['percent'] + percent = float(percent) assert isinstance(percent, (float, int)) assert percent >= 0 assert percent <= 100 - except AssertionError: + except (AssertionError, ValueError): raise WorkflowConfigError( f"'percent' should be a float between 0 and 100: {f_signature}") try: - secs = f_kwargs['secs'] + secs = f_kwargs.get('secs', 0) assert isinstance(secs, int) - except AssertionError: + except (AssertionError, ValueError): raise WorkflowConfigError( f"'secs' should be an integer: {f_signature}")