Skip to content

Commit

Permalink
Move checking of implicit tasks to its own method
Browse files Browse the repository at this point in the history
  • Loading branch information
MetRonnie committed Mar 5, 2021
1 parent 3069746 commit 5a3cadc
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions cylc/flow/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,25 +465,7 @@ def __init__(
self._check_special_tasks() # adds to self.implicit_tasks
self._check_explicit_cycling()

# Warn or abort if implicit tasks are found in graph or queue config
if self.implicit_tasks:
print_limit = 10
implicit_tasks_str = '\n * '.join(
list(self.implicit_tasks)[:print_limit])
num = len(self.implicit_tasks)
if num > print_limit:
implicit_tasks_str = (
f"{implicit_tasks_str}\n and {num} more")
err_msg = (
"implicit tasks detected (no entry under [runtime]):\n"
f" * {implicit_tasks_str}")
if self.cfg['scheduler']['allow implicit tasks']:
LOG.debug(err_msg)
else:
raise SuiteConfigError(
f"{err_msg}\n\n"
"To allow implicit tasks, use "
"'flow.cylc[scheduler]allow implicit tasks'")
self._check_implicit_tasks()

# Check that external trigger messages are only used once (they have to
# be discarded immediately to avoid triggering the next instance of the
Expand Down Expand Up @@ -859,6 +841,28 @@ def process_final_cycle_point(self):
f"Final cycle point {self.final_point} does not "
f"meet the constraints {constraints}")

def _check_implicit_tasks(self) -> None:
"""Raise SuiteConfigError if implicit tasks are found in graph or
queue config, unless allowed by config."""
if self.implicit_tasks:
print_limit = 10
implicit_tasks_str = '\n * '.join(
list(self.implicit_tasks)[:print_limit])
num = len(self.implicit_tasks)
if num > print_limit:
implicit_tasks_str = (
f"{implicit_tasks_str}\n and {num} more")
err_msg = (
"implicit tasks detected (no entry under [runtime]):\n"
f" * {implicit_tasks_str}")
if self.cfg['scheduler']['allow implicit tasks']:
LOG.debug(err_msg)
else:
raise SuiteConfigError(
f"{err_msg}\n\n"
"To allow implicit tasks, use "
"'flow.cylc[scheduler]allow implicit tasks'")

def _check_circular(self):
"""Check for circular dependence in graph."""
if (len(self.taskdefs) > self.CHECK_CIRCULAR_LIMIT and
Expand Down

0 comments on commit 5a3cadc

Please sign in to comment.