From 26c17a4317c036ce253f3f0783f6b5f955650bfa Mon Sep 17 00:00:00 2001 From: Balthasar Reuter Date: Mon, 14 Oct 2024 22:43:27 +0200 Subject: [PATCH] Fix Scheduler instantiation without config (fix #373) --- loki/batch/scheduler.py | 2 +- loki/batch/tests/test_scheduler.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/loki/batch/scheduler.py b/loki/batch/scheduler.py index f95f4e270..edb6cd94a 100644 --- a/loki/batch/scheduler.py +++ b/loki/batch/scheduler.py @@ -134,7 +134,7 @@ def __init__(self, paths, config=None, seed_routines=None, preprocess=False, elif isinstance(config, (str, Path)): self.config = SchedulerConfig.from_file(config) else: - self.config = SchedulerConfig.from_dict(config) + self.config = SchedulerConfig.from_dict(config or {}) self.full_parse = full_parse diff --git a/loki/batch/tests/test_scheduler.py b/loki/batch/tests/test_scheduler.py index b3d42948b..7d4f7f02c 100644 --- a/loki/batch/tests/test_scheduler.py +++ b/loki/batch/tests/test_scheduler.py @@ -266,6 +266,20 @@ def test_scheduler_enrichment(testdir, config, frontend, tmp_path): assert call.routine is call_item.ir +def test_scheduler_empty_config(testdir, frontend, tmp_path): + """ + Test that instantiating the Scheduler without config works (albeit it's not very useful) + This fixes #373 + """ + projA = testdir/'sources/projA' + + scheduler = Scheduler( + paths=projA, includes=projA/'include', + seed_routines=['driverA'], frontend=frontend, xmods=[tmp_path] + ) + assert scheduler.items == ('drivera_mod#drivera',) + + @pytest.mark.skipif(not graphviz_present(), reason='Graphviz is not installed') @pytest.mark.parametrize('with_file_graph', [True, False, 'filegraph_simple']) @pytest.mark.parametrize('with_legend', [True, False])