From f180401760e21e5c3e033083c93cfc6b3478821a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20H=C3=B6rstrup?= Date: Wed, 21 Aug 2024 15:55:11 +0200 Subject: [PATCH] Check if there is only a single task call in parallel loop --- .../validation/semantic_error_checker.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/pfdl_scheduler/validation/semantic_error_checker.py b/pfdl_scheduler/validation/semantic_error_checker.py index 7330dfa..4e5086b 100644 --- a/pfdl_scheduler/validation/semantic_error_checker.py +++ b/pfdl_scheduler/validation/semantic_error_checker.py @@ -709,12 +709,19 @@ def check_counting_loop(self, counting_loop: CountingLoop, task: Task) -> bool: Returns: True if the Counting Loop statement is valid. """ - valid = True - for statement in counting_loop.statements: - if not self.check_statement(statement, task): - valid = False + if counting_loop.parallel: + if len(counting_loop.statements) == 1 and isinstance(counting_loop.statements[0], TaskCall): + return True + error_msg = "Only a single task is allowed in a parallel loop statement!" + self.error_handler.print_error(error_msg, context=counting_loop.context) + return False + else: + valid = True + for statement in counting_loop.statements: + if not self.check_statement(statement, task): + valid = False - return valid + return valid def check_conditional_statement(self, condition: Condition, task: Task) -> bool: """Calls check methods for the conditional statement.