diff --git a/cylc/flow/config.py b/cylc/flow/config.py index 4ada6044a28..1f726b1496b 100644 --- a/cylc/flow/config.py +++ b/cylc/flow/config.py @@ -1795,6 +1795,7 @@ def generate_triggers(self, lexpression, left_nodes, right, seq, ) if self.xtrigger_mgr is None: + # Validation only. XtriggerManager.validate_xtrigger(label, xtrig, self.fdir) else: self.xtrigger_mgr.add_trig(label, xtrig, self.fdir) diff --git a/cylc/flow/subprocpool.py b/cylc/flow/subprocpool.py index 1ae4b129d9d..8a108380301 100644 --- a/cylc/flow/subprocpool.py +++ b/cylc/flow/subprocpool.py @@ -79,9 +79,9 @@ def get_func(mod_name, func_name, src_dir): AttributeError, if the function is not found in the module """ - if func_name in _XTRIG_FUNCS: + if (mod_name, func_name) in _XTRIG_FUNCS: # Found and cached already. - return _XTRIG_FUNCS[func_name] + return _XTRIG_FUNCS[(mod_name, func_name)] # 1. look in /lib/python. sys.path.insert(0, os.path.join(src_dir, 'lib', 'python')) @@ -94,8 +94,8 @@ def get_func(mod_name, func_name, src_dir): # Module found and imported, return the named function. - _XTRIG_FUNCS[func_name] = getattr(mod_by_name, func_name) - return _XTRIG_FUNCS[func_name] + _XTRIG_FUNCS[(mod_name, func_name)] = getattr(mod_by_name, func_name) + return _XTRIG_FUNCS[(mod_name, func_name)] def run_function(func_name, json_args, json_kwargs, src_dir): diff --git a/cylc/flow/xtriggers/wall_clock.py b/cylc/flow/xtriggers/wall_clock.py index 9d615da115a..e12a17ce8be 100644 --- a/cylc/flow/xtriggers/wall_clock.py +++ b/cylc/flow/xtriggers/wall_clock.py @@ -38,12 +38,11 @@ def validate_config(f_args, f_kwargs, f_signature): wall_clock(PT1H) wall_clock(offset=PT1H) - And offset must be a valid ISO 8601 interval. + The offset must be a valid ISO 8601 interval. If f_args used, convert to f_kwargs for clarity. """ - n_args = len(f_args) n_kwargs = len(f_kwargs) diff --git a/tests/unit/test_subprocpool.py b/tests/unit/test_subprocpool.py index c239f41a79c..02ee540fd64 100644 --- a/tests/unit/test_subprocpool.py +++ b/tests/unit/test_subprocpool.py @@ -167,20 +167,18 @@ def test_xfunction_cache(self): python_dir.mkdir(parents=True) amandita_file = python_dir / "amandita.py" with amandita_file.open(mode="w") as f: - f.write("""amandita = lambda: 'chocolate'""") + f.write("""choco = lambda: 'chocolate'""") f.flush() - f_name = "amandita" - fn = get_func(f_name, f_name, temp_dir) + m_name = "amandita" # module + f_name = "choco" # function + fn = get_func(m_name, f_name, temp_dir) result = fn() self.assertEqual('chocolate', result) # is in the cache - self.assertTrue('amandita' in _XTRIG_FUNCS) + self.assertTrue((m_name, f_name) in _XTRIG_FUNCS) # returned from cache - self.assertEqual(fn, get_func(f_name, f_name, temp_dir)) - del _XTRIG_FUNCS['amandita'] - # is not in the cache - self.assertFalse('amandita' in _XTRIG_FUNCS) + self.assertEqual(fn, get_func(m_name, f_name, temp_dir)) def test_xfunction_import_error(self): """Test for error on importing a xtrigger function.