Skip to content

Commit

Permalink
Merge pull request #1020 from benfitzpatrick/1014.initial-final-cycle…
Browse files Browse the repository at this point in the history
…-point-env-tz

#1014: correctly format cycle point env vars
  • Loading branch information
hjoliver committed Jul 20, 2014
2 parents 85129c2 + c518b7d commit 3005096
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 8 deletions.
23 changes: 19 additions & 4 deletions lib/cylc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,15 @@ def __init__( self, suite, fpath, template_vars=[],
'dependencies', {})
if dependency_map.get('graph'):
# There is an async graph setting.
# If it is by itself, it is integer shorthand.
# If there are cycling graphs as well, it is handled as
# backwards-compatiblity for mixed-async suites.
just_has_async_graph = True
for item, value in dependency_map.items():
if item == 'graph':
continue
if value.get('graph'):
if item != 'graph' and value.get('graph'):
just_has_async_graph = False
break
else:
if just_has_async_graph:
# There aren't any other graphs, so set integer cycling.
self.cfg['scheduling']['cycling mode'] = (
INTEGER_CYCLING_TYPE
Expand Down Expand Up @@ -216,7 +219,19 @@ def __init__( self, suite, fpath, template_vars=[],
# after the call to init_cyclers, we can start getting proper points.
init_cyclers(self.cfg)

if self.cfg['scheduling']['initial cycle point'] is not None:
initial_point = get_point(
self.cfg['scheduling']['initial cycle point']).standardise()
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()
self.cfg['scheduling']['final cycle point'] = str(final_point)

self.cli_start_point = get_point(self._cli_start_string)
if self.cli_start_point is not None:
self.cli_start_point.standardise()

flags.back_comp_cycling = (
get_backwards_compatibility_mode())
Expand Down
6 changes: 6 additions & 0 deletions lib/cylc/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,10 +662,16 @@ def configure_suite( self, reconfigure=False ):
self._start_string or self._cli_start_string or
self.config.cfg['scheduling']['initial cycle point']
)
if self.start_point is not None:
self.start_point.standardise()

self.stop_point = get_point(
self.options.stop_string or
self.config.cfg['scheduling']['final cycle point']
)
if self.stop_point is not None:
self.stop_point.standardise()

if (not self.start_point and not self.is_restart and
self.config.cycling_tasks):
print >> sys.stderr, 'WARNING: No initial cycle point provided - no cycling tasks will be loaded.'
Expand Down
1 change: 0 additions & 1 deletion tests/jobscript/00-torture.t
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,3 @@ echo "" >> jobfile
sed 's/##suitename##/'$SUITE_NAME'/' $TEST_SOURCE_DIR/torture/foo.ref-jobfile > reffile
cmp_ok jobfile reffile
purge_suite $SUITE_NAME
rm -rf $(cylc get-global-config --print-run-dir)/$SUITE_NAME-submit
3 changes: 0 additions & 3 deletions tests/jobscript/01-multi.t
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,3 @@ grep -A1 "TASK COMMAND SCRIPTING" exp.jobfile > exp.task_cmd
cmp_ok exp.task_cmd $TEST_SOURCE_DIR/multi/exp.cmd

purge_suite $SUITE_NAME
if [[ -n $SUITE_NAME ]]; then
rm -rf $(cylc get-global-config --print-run-dir)/$SUITE_NAME-submit
fi
35 changes: 35 additions & 0 deletions tests/jobscript/02-cycling.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/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/>.
#-------------------------------------------------------------------------------
# job script torture test and check jobscript is generated correctly
. $(dirname $0)/test_header
#-------------------------------------------------------------------------------
set_test_number 4
#-------------------------------------------------------------------------------
install_suite $TEST_NAME_BASE cycling
#-------------------------------------------------------------------------------
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
#-------------------------------------------------------------------------------
TEST_NAME=$TEST_NAME_BASE-foo-jobscript-match
run_ok $TEST_NAME cylc jobscript $SUITE_NAME foo.20140203T00+13
sed -n '/_POINT=/p' $TEST_NAME.stdout > jobfile
cmp_ok jobfile $TEST_SOURCE_DIR/cycling/foo.ref-jobfile
purge_suite $SUITE_NAME
2 changes: 2 additions & 0 deletions tests/jobscript/cycling/bin/foo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
echo "Hello from $0"
3 changes: 3 additions & 0 deletions tests/jobscript/cycling/foo.ref-jobfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export CYLC_SUITE_FINAL_CYCLE_POINT=20140204T1200+13
export CYLC_SUITE_INITIAL_CYCLE_POINT=20140201T0500+13
export CYLC_TASK_CYCLE_POINT=20140203T0000+13
35 changes: 35 additions & 0 deletions tests/jobscript/cycling/reference.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
2014-07-16T12:18:22+01 INFO - Thread-2 start (Event Handlers)
2014-07-16T12:18:22+01 INFO - Thread-3 start (Poll & Kill Commands)
2014-07-16T12:18:22+01 INFO - port:7767
2014-07-16T12:18:22+01 INFO - Suite starting at 2014-07-16T12:18:22+01
2014-07-16T12:18:22+01 INFO - Log event clock: real time
2014-07-16T12:18:22+01 INFO - Run mode: live
2014-07-16T12:18:22+01 INFO - Start tag: 20140201T0500+13
2014-07-16T12:18:22+01 INFO - Stop tag: 20140204T1200+13
2014-07-16T12:18:22+01 INFO - Thread-4 start (Job Submission)
2014-07-16T12:18:22+01 INFO - Thread-5 start (Request Handling)
2014-07-16T12:18:22+01 INFO - Cold Start 20140201T0500+13
2014-07-16T12:18:22+01 INFO - [foo.20140202T0000+13] -triggered off []
2014-07-16T12:18:23+01 INFO - [foo.20140202T0000+13] -(current:ready)> foo.20140202T0000+13 submitting now
2014-07-16T12:18:24+01 INFO - [foo.20140202T0000+13] -(current:ready)> foo.20140202T0000+13 submission succeeded
2014-07-16T12:18:24+01 INFO - [foo.20140202T0000+13] -(current:submitted)> foo.20140202T0000+13 submit_method_id=3368
2014-07-16T12:18:25+01 INFO - [foo.20140202T0000+13] -(current:submitted)> foo.20140202T0000+13 started at 2014-07-16T12:18:24+01
2014-07-16T12:18:26+01 INFO - [foo.20140203T0000+13] -triggered off []
2014-07-16T12:18:26+01 INFO - [foo.20140202T0000+13] -(current:running)> foo.20140202T0000+13 succeeded at 2014-07-16T12:18:25+01
2014-07-16T12:18:27+01 INFO - [foo.20140203T0000+13] -(current:ready)> foo.20140203T0000+13 submitting now
2014-07-16T12:18:27+01 INFO - [foo.20140203T0000+13] -(current:ready)> foo.20140203T0000+13 submission succeeded
2014-07-16T12:18:27+01 INFO - [foo.20140203T0000+13] -(current:submitted)> foo.20140203T0000+13 submit_method_id=3566
2014-07-16T12:18:28+01 INFO - [foo.20140203T0000+13] -(current:submitted)> foo.20140203T0000+13 started at 2014-07-16T12:18:28+01
2014-07-16T12:18:29+01 INFO - [foo.20140204T0000+13] -triggered off []
2014-07-16T12:18:29+01 INFO - [foo.20140203T0000+13] -(current:running)> foo.20140203T0000+13 succeeded at 2014-07-16T12:18:28+01
2014-07-16T12:18:30+01 INFO - [foo.20140204T0000+13] -(current:ready)> foo.20140204T0000+13 submitting now
2014-07-16T12:18:30+01 INFO - [foo.20140204T0000+13] -(current:ready)> foo.20140204T0000+13 submission succeeded
2014-07-16T12:18:30+01 INFO - [foo.20140204T0000+13] -(current:submitted)> foo.20140204T0000+13 submit_method_id=3780
2014-07-16T12:18:31+01 INFO - [foo.20140205T0000+13] -holding (beyond suite stop point) 20140204T1200+13
2014-07-16T12:18:31+01 INFO - [foo.20140204T0000+13] -(current:submitted)> foo.20140204T0000+13 started at 2014-07-16T12:18:31+01
2014-07-16T12:18:32+01 INFO - [foo.20140204T0000+13] -(current:running)> foo.20140204T0000+13 succeeded at 2014-07-16T12:18:32+01
2014-07-16T12:18:32+01 INFO - Stopping:
+ all tasks have spawned past the final cycle 20140204T1200+13
2014-07-16T12:18:33+01 INFO - Thread-2 exit (Event Handlers)
2014-07-16T12:18:33+01 INFO - Thread-3 exit (Poll & Kill Commands)
2014-07-16T12:18:33+01 INFO - Thread-4 exit (Job Submission)
29 changes: 29 additions & 0 deletions tests/jobscript/cycling/suite.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

title = "job script cycling test"

description = """Test the output of cycling environment variables"""

[cylc]
cycle point time zone = +13
[[reference test]]
live mode suite timeout = 0.5
dummy mode suite timeout = 0.5
simulation mode suite timeout = 0.5

[scheduling]
initial cycle point = 20140201T05
final cycle point = 20140204T11+12
[[dependencies]]
[[[T00]]]
graph = "foo"
[runtime]
[[foo]]
initial scripting = echo HELLO FROM INITIAL SCRIPTING
pre-command scripting = echo HELLO FROM PRE-COMMAND SCRIPTING
command scripting = echo HELLO FROM COMMAND SCRIPTING
post-command scripting = echo HELLO FROM POST-COMMAND SCRIPTING
[[[remote]]]
# force use of ssh job submission to disconnect local tasks
# from the submitting suite environment.
host = localhost

0 comments on commit 3005096

Please sign in to comment.