Skip to content

Commit

Permalink
Merge pull request #1055 from arjclark/relative_end_point
Browse files Browse the repository at this point in the history
#981: final cycle specification as an offset.
  • Loading branch information
hjoliver committed Aug 6, 2014
2 parents 4b37971 + f196bda commit 6c75b3d
Show file tree
Hide file tree
Showing 11 changed files with 323 additions and 6 deletions.
3 changes: 2 additions & 1 deletion doc/suiterc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,8 @@ \subsection{[scheduling]}

\begin{myitemize}
\item {\em type:} ISO 8601 date/time point representation (e.g.
\lstinline=CCYYMMDDThhmm=, 19951231T1230)
\lstinline=CCYYMMDDThhmm=, 19951231T1230) or ISO 8601 date/time offset
(e.g. +P1D)
\item {\em default:} (none)
\end{myitemize}

Expand Down
11 changes: 9 additions & 2 deletions lib/cylc/cfgspec/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ def _coerce_cycletime_time_zone( value, keys, args ):
return value


def _coerce_final_cycletime( value, keys, args ):
"""Coerce final cycle point."""
value = _strip_and_unquote( keys, value )
return value


def _coerce_interval( value, keys, args, back_comp_unit_factor=1 ):
"""Coerce an ISO 8601 interval (or number: back-comp) into seconds."""
value = _strip_and_unquote( keys, value )
Expand Down Expand Up @@ -152,6 +158,7 @@ def _coerce_interval_list( value, keys, args, back_comp_unit_factor=1 ):
coercers['cycletime_format'] = _coerce_cycletime_format
coercers['cycletime_time_zone'] = _coerce_cycletime_time_zone
coercers['cycleinterval'] = _coerce_cycleinterval
coercers['final_cycletime'] = _coerce_final_cycletime
coercers['interval'] = _coerce_interval
coercers['interval_minutes'] = lambda *a: _coerce_interval(
*a, back_comp_unit_factor=60)
Expand Down Expand Up @@ -207,7 +214,7 @@ def _coerce_interval_list( value, keys, args, back_comp_unit_factor=1 ):
},
'scheduling' : {
'initial cycle point' : vdr(vtype='cycletime'),
'final cycle point' : vdr(vtype='cycletime'),
'final cycle point' : vdr(vtype='final_cycletime'),
'cycling mode' : vdr(vtype='string', default=Calendar.MODE_GREGORIAN, options=Calendar.MODES.keys() + ["integer"] ),
'runahead limit' : vdr(vtype='cycleinterval' ),
'max active cycle points' : vdr(vtype='integer', default=3),
Expand Down Expand Up @@ -317,7 +324,7 @@ def _coerce_interval_list( value, keys, args, back_comp_unit_factor=1 ):
},
'visualization' : {
'initial cycle point' : vdr( vtype='cycletime' ),
'final cycle point' : vdr( vtype='cycletime' ),
'final cycle point' : vdr( vtype='final_cycletime' ),
'collapsed families' : vdr( vtype='string_list', default=[] ),
'use node color for edges' : vdr( vtype='boolean', default=True ),
'use node color for labels' : vdr( vtype='boolean', default=False ),
Expand Down
10 changes: 8 additions & 2 deletions lib/cylc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
init_cyclers, INTEGER_CYCLING_TYPE,
ISO8601_CYCLING_TYPE,
get_backwards_compat_mode)
from cylc.cycling.iso8601 import get_point_relative
from isodatetime.data import Calendar
from envvar import check_varnames, expandvars
from copy import deepcopy, copy
Expand Down Expand Up @@ -236,8 +237,13 @@ def __init__( self, suite, fpath, template_vars=[],
self.cfg['scheduling']['initial cycle point'] = str(initial_point)

if self.cfg['scheduling']['final cycle point'] is not None:
final_point = get_point(
self.cfg['scheduling']['final cycle point']).standardise()
try:
final_point = get_point_relative(
self.cfg['scheduling']['final cycle point'],
initial_point).standardise()
except ValueError:
final_point = get_point(
self.cfg['scheduling']['final cycle point']).standardise()
self.cfg['scheduling']['final cycle point'] = str(final_point)

self.cli_initial_point = get_point(self._cli_initial_point_string)
Expand Down
31 changes: 31 additions & 0 deletions tests/offset/00-final-simple.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
#C: THIS FILE IS PART OF THE CYLC SUITE ENGINE.
#C: Copyright (C) 2008-2014 Hilary Oliver, NIWA
#C:
#C: This program is free software: you can redistribute it and/or modify
#C: it under the terms of the GNU General Public License as published by
#C: the Free Software Foundation, either version 3 of the License, or
#C: (at your option) any later version.
#C:
#C: This program is distributed in the hope that it will be useful,
#C: but WITHOUT ANY WARRANTY; without even the implied warranty of
#C: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#C: GNU General Public License for more details.
#C:
#C: You should have received a copy of the GNU General Public License
#C: along with this program. If not, see <http://www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------
# Test specifying final cycle as an offset
. $(dirname $0)/test_header
#-------------------------------------------------------------------------------
set_test_number 2
#-------------------------------------------------------------------------------
install_suite $TEST_NAME_BASE $TEST_NAME_BASE
#-------------------------------------------------------------------------------
TEST_NAME=$TEST_NAME_BASE-validate
run_ok $TEST_NAME cylc validate $SUITE_NAME
#-------------------------------------------------------------------------------
TEST_NAME=$TEST_NAME_BASE-run
suite_run_ok $TEST_NAME cylc run --reference-test --debug $SUITE_NAME
#-------------------------------------------------------------------------------
purge_suite $SUITE_NAME
151 changes: 151 additions & 0 deletions tests/offset/00-final-simple/reference.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
2014-08-05T12:04:31+01 DEBUG - Initializing process pool, size 8
2014-08-05T12:04:31+01 INFO - port:7781
2014-08-05T12:04:31+01 INFO - Suite starting at 2014-08-05T12:04:31+01
2014-08-05T12:04:31+01 INFO - Log event clock: real time
2014-08-05T12:04:31+01 INFO - Run mode: live
2014-08-05T12:04:31+01 INFO - Initial point: 20100101T0000+01
2014-08-05T12:04:31+01 INFO - Final point: 20100106T0000+01
2014-08-05T12:04:31+01 DEBUG - request handling thread starting
2014-08-05T12:04:31+01 INFO - Cold Start 20100101T0000+01
2014-08-05T12:04:31+01 DEBUG - [foo.20100101T0000+01] -released to the task pool
2014-08-05T12:04:31+01 DEBUG - BEGIN TASK PROCESSING
2014-08-05T12:04:31+01 DEBUG - [foo.20100101T0000+01] -(setting:queued)
2014-08-05T12:04:31+01 DEBUG - 1 task(s) ready
2014-08-05T12:04:31+01 DEBUG - [foo.20100101T0000+01] -(setting:ready)
2014-08-05T12:04:31+01 DEBUG - [foo.20100101T0000+01] -incrementing submit number
2014-08-05T12:04:31+01 INFO - [foo.20100101T0000+01] -triggered off []
2014-08-05T12:04:31+01 DEBUG - END TASK PROCESSING (took 0.0146241188049 sec)
2014-08-05T12:04:32+01 INFO - [foo.20100101T0000+01] -submit_method_id=28482
2014-08-05T12:04:32+01 INFO - [foo.20100101T0000+01] -submission succeeded
2014-08-05T12:04:32+01 DEBUG - [foo.20100101T0000+01] -(setting:submitted)
2014-08-05T12:04:32+01 DEBUG - BEGIN TASK PROCESSING
2014-08-05T12:04:32+01 DEBUG - 0 task(s) ready
2014-08-05T12:04:32+01 DEBUG - [foo.20100101T0000+01] -forced spawning
2014-08-05T12:04:32+01 DEBUG - END TASK PROCESSING (took 0.0114269256592 sec)
2014-08-05T12:04:33+01 DEBUG - [foo.20100102T0000+01] -released to the task pool
2014-08-05T12:04:33+01 DEBUG - BEGIN TASK PROCESSING
2014-08-05T12:04:33+01 DEBUG - 0 task(s) ready
2014-08-05T12:04:33+01 DEBUG - END TASK PROCESSING (took 0.00534605979919 sec)
2014-08-05T12:04:33+01 INFO - [foo.20100101T0000+01] -(current:submitted)> foo.20100101T0000+01 started at 2014-08-05T12:04:32+01
2014-08-05T12:04:33+01 DEBUG - [foo.20100101T0000+01] -(setting:running)
2014-08-05T12:04:33+01 INFO - [foo.20100101T0000+01] -(current:running)> foo.20100101T0000+01 succeeded at 2014-08-05T12:04:33+01
2014-08-05T12:04:33+01 DEBUG - [foo.20100101T0000+01] -(setting:succeeded)
2014-08-05T12:04:34+01 DEBUG - BEGIN TASK PROCESSING
2014-08-05T12:04:34+01 DEBUG - [foo.20100102T0000+01] -(setting:queued)
2014-08-05T12:04:34+01 DEBUG - 1 task(s) ready
2014-08-05T12:04:34+01 DEBUG - [foo.20100102T0000+01] -(setting:ready)
2014-08-05T12:04:34+01 DEBUG - [foo.20100102T0000+01] -incrementing submit number
2014-08-05T12:04:34+01 INFO - [foo.20100102T0000+01] -triggered off ['foo.20100101T0000+01']
2014-08-05T12:04:34+01 DEBUG - [foo.20100101T0000+01] -task proxy removed
2014-08-05T12:04:34+01 DEBUG - END TASK PROCESSING (took 0.018651008606 sec)
2014-08-05T12:04:35+01 INFO - [foo.20100102T0000+01] -submit_method_id=28621
2014-08-05T12:04:35+01 INFO - [foo.20100102T0000+01] -submission succeeded
2014-08-05T12:04:35+01 DEBUG - [foo.20100102T0000+01] -(setting:submitted)
2014-08-05T12:04:36+01 DEBUG - BEGIN TASK PROCESSING
2014-08-05T12:04:36+01 DEBUG - 0 task(s) ready
2014-08-05T12:04:36+01 DEBUG - [foo.20100102T0000+01] -forced spawning
2014-08-05T12:04:36+01 DEBUG - END TASK PROCESSING (took 0.0133910179138 sec)
2014-08-05T12:04:36+01 INFO - [foo.20100102T0000+01] -(current:submitted)> foo.20100102T0000+01 started at 2014-08-05T12:04:35+01
2014-08-05T12:04:36+01 DEBUG - [foo.20100102T0000+01] -(setting:running)
2014-08-05T12:04:37+01 DEBUG - [foo.20100103T0000+01] -released to the task pool
2014-08-05T12:04:37+01 DEBUG - BEGIN TASK PROCESSING
2014-08-05T12:04:37+01 DEBUG - 0 task(s) ready
2014-08-05T12:04:37+01 DEBUG - END TASK PROCESSING (took 0.00515794754028 sec)
2014-08-05T12:04:37+01 INFO - [foo.20100102T0000+01] -(current:running)> foo.20100102T0000+01 succeeded at 2014-08-05T12:04:36+01
2014-08-05T12:04:37+01 DEBUG - [foo.20100102T0000+01] -(setting:succeeded)
2014-08-05T12:04:38+01 DEBUG - BEGIN TASK PROCESSING
2014-08-05T12:04:38+01 DEBUG - [foo.20100103T0000+01] -(setting:queued)
2014-08-05T12:04:38+01 DEBUG - 1 task(s) ready
2014-08-05T12:04:38+01 DEBUG - [foo.20100103T0000+01] -(setting:ready)
2014-08-05T12:04:38+01 DEBUG - [foo.20100103T0000+01] -incrementing submit number
2014-08-05T12:04:38+01 INFO - [foo.20100103T0000+01] -triggered off ['foo.20100102T0000+01']
2014-08-05T12:04:38+01 DEBUG - [foo.20100102T0000+01] -task proxy removed
2014-08-05T12:04:38+01 DEBUG - END TASK PROCESSING (took 0.0154209136963 sec)
2014-08-05T12:04:39+01 INFO - [foo.20100103T0000+01] -submit_method_id=28763
2014-08-05T12:04:39+01 INFO - [foo.20100103T0000+01] -submission succeeded
2014-08-05T12:04:39+01 DEBUG - [foo.20100103T0000+01] -(setting:submitted)
2014-08-05T12:04:39+01 DEBUG - BEGIN TASK PROCESSING
2014-08-05T12:04:39+01 DEBUG - 0 task(s) ready
2014-08-05T12:04:39+01 DEBUG - [foo.20100103T0000+01] -forced spawning
2014-08-05T12:04:39+01 DEBUG - END TASK PROCESSING (took 0.0126049518585 sec)
2014-08-05T12:04:39+01 INFO - [foo.20100103T0000+01] -(current:submitted)> foo.20100103T0000+01 started at 2014-08-05T12:04:38+01
2014-08-05T12:04:39+01 DEBUG - [foo.20100103T0000+01] -(setting:running)
2014-08-05T12:04:40+01 DEBUG - [foo.20100104T0000+01] -released to the task pool
2014-08-05T12:04:40+01 DEBUG - BEGIN TASK PROCESSING
2014-08-05T12:04:40+01 DEBUG - 0 task(s) ready
2014-08-05T12:04:40+01 DEBUG - END TASK PROCESSING (took 0.00577998161316 sec)
2014-08-05T12:04:40+01 INFO - [foo.20100103T0000+01] -(current:running)> foo.20100103T0000+01 succeeded at 2014-08-05T12:04:39+01
2014-08-05T12:04:40+01 DEBUG - [foo.20100103T0000+01] -(setting:succeeded)
2014-08-05T12:04:41+01 DEBUG - BEGIN TASK PROCESSING
2014-08-05T12:04:41+01 DEBUG - [foo.20100104T0000+01] -(setting:queued)
2014-08-05T12:04:41+01 DEBUG - 1 task(s) ready
2014-08-05T12:04:41+01 DEBUG - [foo.20100104T0000+01] -(setting:ready)
2014-08-05T12:04:41+01 DEBUG - [foo.20100104T0000+01] -incrementing submit number
2014-08-05T12:04:41+01 INFO - [foo.20100104T0000+01] -triggered off ['foo.20100103T0000+01']
2014-08-05T12:04:41+01 DEBUG - [foo.20100103T0000+01] -task proxy removed
2014-08-05T12:04:41+01 DEBUG - END TASK PROCESSING (took 0.0161001682281 sec)
2014-08-05T12:04:42+01 INFO - [foo.20100104T0000+01] -submit_method_id=28904
2014-08-05T12:04:42+01 INFO - [foo.20100104T0000+01] -submission succeeded
2014-08-05T12:04:42+01 DEBUG - [foo.20100104T0000+01] -(setting:submitted)
2014-08-05T12:04:42+01 DEBUG - BEGIN TASK PROCESSING
2014-08-05T12:04:42+01 DEBUG - 0 task(s) ready
2014-08-05T12:04:42+01 DEBUG - [foo.20100104T0000+01] -forced spawning
2014-08-05T12:04:42+01 DEBUG - END TASK PROCESSING (took 0.0274260044098 sec)
2014-08-05T12:04:42+01 INFO - [foo.20100104T0000+01] -(current:submitted)> foo.20100104T0000+01 started at 2014-08-05T12:04:41+01
2014-08-05T12:04:42+01 DEBUG - [foo.20100104T0000+01] -(setting:running)
2014-08-05T12:04:43+01 DEBUG - [foo.20100105T0000+01] -released to the task pool
2014-08-05T12:04:43+01 DEBUG - BEGIN TASK PROCESSING
2014-08-05T12:04:43+01 DEBUG - 0 task(s) ready
2014-08-05T12:04:43+01 DEBUG - END TASK PROCESSING (took 0.0056037902832 sec)
2014-08-05T12:04:43+01 INFO - [foo.20100104T0000+01] -(current:running)> foo.20100104T0000+01 succeeded at 2014-08-05T12:04:42+01
2014-08-05T12:04:43+01 DEBUG - [foo.20100104T0000+01] -(setting:succeeded)
2014-08-05T12:04:44+01 DEBUG - BEGIN TASK PROCESSING
2014-08-05T12:04:44+01 DEBUG - [foo.20100105T0000+01] -(setting:queued)
2014-08-05T12:04:44+01 DEBUG - 1 task(s) ready
2014-08-05T12:04:44+01 DEBUG - [foo.20100105T0000+01] -(setting:ready)
2014-08-05T12:04:44+01 DEBUG - [foo.20100105T0000+01] -incrementing submit number
2014-08-05T12:04:44+01 INFO - [foo.20100105T0000+01] -triggered off ['foo.20100104T0000+01']
2014-08-05T12:04:44+01 DEBUG - [foo.20100104T0000+01] -task proxy removed
2014-08-05T12:04:44+01 DEBUG - END TASK PROCESSING (took 0.0160040855408 sec)
2014-08-05T12:04:45+01 INFO - [foo.20100105T0000+01] -submit_method_id=29049
2014-08-05T12:04:45+01 INFO - [foo.20100105T0000+01] -submission succeeded
2014-08-05T12:04:45+01 DEBUG - [foo.20100105T0000+01] -(setting:submitted)
2014-08-05T12:04:45+01 DEBUG - BEGIN TASK PROCESSING
2014-08-05T12:04:45+01 DEBUG - 0 task(s) ready
2014-08-05T12:04:45+01 DEBUG - [foo.20100105T0000+01] -forced spawning
2014-08-05T12:04:45+01 DEBUG - END TASK PROCESSING (took 0.0133059024811 sec)
2014-08-05T12:04:45+01 INFO - [foo.20100105T0000+01] -(current:submitted)> foo.20100105T0000+01 started at 2014-08-05T12:04:44+01
2014-08-05T12:04:45+01 DEBUG - [foo.20100105T0000+01] -(setting:running)
2014-08-05T12:04:46+01 DEBUG - [foo.20100106T0000+01] -released to the task pool
2014-08-05T12:04:46+01 DEBUG - BEGIN TASK PROCESSING
2014-08-05T12:04:46+01 DEBUG - 0 task(s) ready
2014-08-05T12:04:46+01 DEBUG - END TASK PROCESSING (took 0.00688409805298 sec)
2014-08-05T12:04:46+01 INFO - [foo.20100105T0000+01] -(current:running)> foo.20100105T0000+01 succeeded at 2014-08-05T12:04:45+01
2014-08-05T12:04:46+01 DEBUG - [foo.20100105T0000+01] -(setting:succeeded)
2014-08-05T12:04:47+01 DEBUG - BEGIN TASK PROCESSING
2014-08-05T12:04:47+01 DEBUG - [foo.20100106T0000+01] -(setting:queued)
2014-08-05T12:04:47+01 DEBUG - 1 task(s) ready
2014-08-05T12:04:47+01 DEBUG - [foo.20100106T0000+01] -(setting:ready)
2014-08-05T12:04:47+01 DEBUG - [foo.20100106T0000+01] -incrementing submit number
2014-08-05T12:04:47+01 INFO - [foo.20100106T0000+01] -triggered off ['foo.20100105T0000+01']
2014-08-05T12:04:47+01 DEBUG - [foo.20100105T0000+01] -task proxy removed
2014-08-05T12:04:47+01 DEBUG - END TASK PROCESSING (took 0.0164649486542 sec)
2014-08-05T12:04:48+01 INFO - [foo.20100106T0000+01] -submit_method_id=29187
2014-08-05T12:04:48+01 INFO - [foo.20100106T0000+01] -submission succeeded
2014-08-05T12:04:48+01 DEBUG - [foo.20100106T0000+01] -(setting:submitted)
2014-08-05T12:04:48+01 DEBUG - BEGIN TASK PROCESSING
2014-08-05T12:04:48+01 DEBUG - 0 task(s) ready
2014-08-05T12:04:48+01 DEBUG - [foo.20100106T0000+01] -forced spawning
2014-08-05T12:04:48+01 INFO - [foo.20100107T0000+01] -holding (beyond suite stop point) 20100106T0000+01
2014-08-05T12:04:48+01 DEBUG - [foo.20100107T0000+01] -(setting:held)
2014-08-05T12:04:48+01 DEBUG - END TASK PROCESSING (took 0.0190420150757 sec)
2014-08-05T12:04:48+01 INFO - [foo.20100106T0000+01] -(current:submitted)> foo.20100106T0000+01 started at 2014-08-05T12:04:47+01
2014-08-05T12:04:48+01 DEBUG - [foo.20100106T0000+01] -(setting:running)
2014-08-05T12:04:49+01 DEBUG - [foo.20100107T0000+01] -released to the task pool
2014-08-05T12:04:49+01 DEBUG - BEGIN TASK PROCESSING
2014-08-05T12:04:49+01 DEBUG - 0 task(s) ready
2014-08-05T12:04:49+01 DEBUG - END TASK PROCESSING (took 0.00570511817932 sec)
2014-08-05T12:04:49+01 INFO - [foo.20100106T0000+01] -(current:running)> foo.20100106T0000+01 succeeded at 2014-08-05T12:04:48+01
2014-08-05T12:04:49+01 DEBUG - [foo.20100106T0000+01] -(setting:succeeded)
2014-08-05T12:04:49+01 DEBUG - Closing process pool
2014-08-05T12:04:50+01 INFO - Suite shutting down at 2014-08-05T12:04:50+01
14 changes: 14 additions & 0 deletions tests/offset/00-final-simple/suite.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[cylc]
cycle point time zone = +01
[[reference test]]
required run mode = live
live mode suite timeout = 1.0 # minutes
[scheduling]
initial cycle point = 20100101T00
final cycle point = +P5D
[[dependencies]]
[[[T00]]]
graph = "foo[-P1D] => foo"
[runtime]
[[foo]]
command scripting = true
31 changes: 31 additions & 0 deletions tests/offset/01-final-next.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
#C: THIS FILE IS PART OF THE CYLC SUITE ENGINE.
#C: Copyright (C) 2008-2014 Hilary Oliver, NIWA
#C:
#C: This program is free software: you can redistribute it and/or modify
#C: it under the terms of the GNU General Public License as published by
#C: the Free Software Foundation, either version 3 of the License, or
#C: (at your option) any later version.
#C:
#C: This program is distributed in the hope that it will be useful,
#C: but WITHOUT ANY WARRANTY; without even the implied warranty of
#C: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#C: GNU General Public License for more details.
#C:
#C: You should have received a copy of the GNU General Public License
#C: along with this program. If not, see <http://www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------
# Test specifying final cycle as the next instance of T06
. $(dirname $0)/test_header
#-------------------------------------------------------------------------------
set_test_number 2
#-------------------------------------------------------------------------------
install_suite $TEST_NAME_BASE $TEST_NAME_BASE
#-------------------------------------------------------------------------------
TEST_NAME=$TEST_NAME_BASE-validate
run_ok $TEST_NAME cylc validate $SUITE_NAME
#-------------------------------------------------------------------------------
TEST_NAME=$TEST_NAME_BASE-run
suite_run_ok $TEST_NAME cylc run --reference-test --debug $SUITE_NAME
#-------------------------------------------------------------------------------
purge_suite $SUITE_NAME
Loading

0 comments on commit 6c75b3d

Please sign in to comment.