Skip to content

Commit 7b3e9f7

Browse files
committed
Make more possible combinations of start and stop points emit warnings
1 parent 4cd9cec commit 7b3e9f7

File tree

2 files changed

+78
-13
lines changed

2 files changed

+78
-13
lines changed

cylc/flow/config.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ def __init__(
433433
self.process_start_cycle_point()
434434
self.process_final_cycle_point()
435435
self.process_stop_cycle_point()
436+
self.start_point_checks()
436437

437438
# Parse special task cycle point offsets, and replace family names.
438439
LOG.debug("Parsing [special tasks]")
@@ -756,6 +757,7 @@ def process_start_cycle_point(self) -> None:
756757
if self.options.startcp == 'now':
757758
self.options.startcp = get_current_time_string()
758759
self.start_point = get_point(self.options.startcp).standardise()
760+
759761
elif starttask:
760762
# Start from designated task(s).
761763
# Select the earliest start point for use in pre-initial ignore.
@@ -774,6 +776,30 @@ def process_start_cycle_point(self) -> None:
774776
# Start from the initial point.
775777
self.start_point = self.initial_point
776778

779+
def start_point_checks(self):
780+
"""Check that the start point makes sense.
781+
"""
782+
if not self.start_point:
783+
return
784+
elif self.start_point < self.initial_point:
785+
LOG.warning(
786+
f"Start cycle point '{self.start_point}' will have no "
787+
"effect as it is before the initial cycle "
788+
f"point '{self.initial_point}'."
789+
)
790+
elif self.start_point > self.final_point:
791+
LOG.warning(
792+
f"Start cycle point '{self.start_point}' will have no "
793+
"effect as it is after the final cycle "
794+
f"point '{self.final_point}'."
795+
)
796+
elif self.start_point > self.stop_point:
797+
LOG.warning(
798+
f"Stop cycle point '{self.stop_point}' will have no "
799+
"effect as it is before the start cycle "
800+
f"point '{self.start_point}'."
801+
)
802+
777803
def process_final_cycle_point(self) -> None:
778804
"""Validate and set the final cycle point from flow.cylc or options.
779805
@@ -864,6 +890,16 @@ def process_stop_cycle_point(self) -> None:
864890
f"point '{self.final_point}'."
865891
)
866892
self.stop_point = None
893+
if (
894+
self.stop_point is not None
895+
and self.stop_point < self.initial_point
896+
):
897+
LOG.warning(
898+
f"Stop cycle point '{self.stop_point}' will have no "
899+
"effect as it is before the initial cycle "
900+
f"point '{self.initial_point}'."
901+
)
902+
self.stop_point = None
867903
stopcp_str = str(self.stop_point) if self.stop_point else None
868904
self.cfg['scheduling']['stop after cycle point'] = stopcp_str
869905

tests/integration/test_config.py

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -681,9 +681,16 @@ async def test_invalid_starttask(one_conf, flow, scheduler, start):
681681
"Stop cycle point '20030101T0000Z' will have no effect as it"
682682
" is after the final cycle point '20020101T0000Z'."
683683
),
684-
# Not detectable from validate
685-
# ('initial', 'stop', 'start', 'final', False, "asdf"),
686-
# ('initial', 'stop', 'final', 'start', False, "asdf"),
684+
(
685+
'initial', 'stop', 'start', 'final', False,
686+
"Stop cycle point '20010101T0000Z' will have no effect as it"
687+
" is before the start cycle point '20020101T0000Z'."
688+
),
689+
(
690+
'initial', 'stop', 'final', 'start', False,
691+
"Start cycle point '20030101T0000Z' will have no effect as it"
692+
" is after the final cycle point '20020101T0000Z'."
693+
),
687694
(
688695
'initial', 'final', 'start', 'stop', True,
689696
"Stop cycle point '20030101T0000Z' will have no effect as it"
@@ -694,7 +701,11 @@ async def test_invalid_starttask(one_conf, flow, scheduler, start):
694701
"Stop cycle point '20020101T0000Z' will have no effect as it"
695702
" is after the final cycle point '20010101T0000Z'."
696703
),
697-
# ('start', 'initial', 'stop', 'final', True, "asdf"),
704+
(
705+
'start', 'initial', 'stop', 'final', False,
706+
"Start cycle point '20000101T0000Z' will have no effect as it"
707+
" is before the initial cycle point '20010101T0000Z'."
708+
),
698709
(
699710
'start', 'initial', 'final', 'stop', True,
700711
"Stop cycle point '20030101T0000Z' will have no effect as it"
@@ -734,8 +745,19 @@ async def test_invalid_starttask(one_conf, flow, scheduler, start):
734745
('final', 'stop', 'start', 'initial', True, WorkflowConfigError),
735746
)
736747
)
737-
def test_milestone_cycle_points(
738-
a, b, c, d, validation_fail, err, flow, validate, scheduler, start, caplog
748+
async def test_milestone_cycle_points(
749+
a,
750+
b,
751+
c,
752+
d,
753+
validation_fail,
754+
err,
755+
flow,
756+
validate,
757+
scheduler,
758+
start,
759+
log_filter,
760+
caplog,
739761
):
740762
"""Ensure that all combinations of
741763
"""
@@ -749,11 +771,18 @@ def test_milestone_cycle_points(
749771
'graph': {'P1Y': 'foo'}
750772
},
751773
})
752-
if not err:
753-
validate(wid)
754-
elif isinstance(err, str):
755-
validate(wid)
756-
assert err in caplog.messages
757-
else:
758-
with pytest.raises(err):
774+
if validation_fail:
775+
if not err:
759776
validate(wid)
777+
elif isinstance(err, str):
778+
validate(wid)
779+
assert err in caplog.messages
780+
else:
781+
with pytest.raises(err):
782+
validate(wid)
783+
784+
else:
785+
schd = scheduler(wid, startcp=str(order['start']))
786+
async with start(schd) as log:
787+
assert err in caplog.messages
788+

0 commit comments

Comments
 (0)