Skip to content

Commit 3af69d4

Browse files
committed
Ensure next/prev syntax works for --startcp option
1 parent 5f4c36f commit 3af69d4

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

cylc/flow/config.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,17 @@ def interpolate_template(tmpl, params_dict):
250250
raise ParamExpandError('bad template syntax') from None
251251

252252

253+
def _parse_iso_cycle_point(value: str) -> str:
254+
"""Helper for parsing initial/start cycle point option in
255+
datetime cycling mode."""
256+
if value == 'now':
257+
return get_current_time_string()
258+
try:
259+
return ingest_time(value, get_current_time_string())
260+
except IsodatetimeError as exc:
261+
raise WorkflowConfigError(str(exc)) from None
262+
263+
253264
class WorkflowConfig:
254265
"""Class for workflow configuration items and derived quantities."""
255266

@@ -763,13 +774,7 @@ def process_initial_cycle_point(self) -> None:
763774
if orig_icp is None:
764775
raise WorkflowConfigError(
765776
"This workflow requires an initial cycle point.")
766-
if orig_icp == "now":
767-
icp = get_current_time_string()
768-
else:
769-
try:
770-
icp = ingest_time(orig_icp, get_current_time_string())
771-
except IsodatetimeError as exc:
772-
raise WorkflowConfigError(str(exc)) from None
777+
icp = _parse_iso_cycle_point(orig_icp)
773778
self.evaluated_icp = None
774779
if icp != orig_icp:
775780
# now/next()/previous() was used, need to store
@@ -810,8 +815,7 @@ def process_start_cycle_point(self) -> None:
810815
)
811816
if startcp:
812817
# Start from a point later than initial point.
813-
if self.options.startcp == 'now':
814-
self.options.startcp = get_current_time_string()
818+
self.options.startcp = _parse_iso_cycle_point(startcp)
815819
self.start_point = get_point(self.options.startcp).standardise()
816820
elif starttask:
817821
# Start from designated task(s).

tests/unit/test_config.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,14 @@ def test_family_inheritance_and_quotes(
314314
None,
315315
id="ICP = now"
316316
),
317+
pytest.param(
318+
ISO8601_CYCLING_TYPE,
319+
{'initial cycle point': 'previous(T00)'},
320+
'20050102T0000+0530',
321+
'20050102T0000+0530',
322+
None,
323+
id="ICP = prev"
324+
),
317325
pytest.param(
318326
ISO8601_CYCLING_TYPE,
319327
{
@@ -413,6 +421,12 @@ def test_process_icp(
413421
'20050102T0615+0530',
414422
None
415423
),
424+
(
425+
'previous(T00)',
426+
None,
427+
'20050102T0000+0530',
428+
None,
429+
),
416430
(
417431
None,
418432
None,

0 commit comments

Comments
 (0)