Skip to content

Commit

Permalink
Renamed some modules and classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
hjoliver committed Mar 15, 2016
1 parent d31f135 commit 9932fc5
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 40 deletions.
8 changes: 4 additions & 4 deletions lib/cylc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
from isodatetime.data import Calendar
from envvar import check_varnames, expandvars
from copy import deepcopy, copy
from output import output
from message_output import MessageOutput
from graphnode import graphnode, GraphNodeError
from print_tree import print_tree
from cylc.prerequisite import TriggerExpressionError
from regpath import RegPath
from trigger import trigger
from task_trigger import TaskTrigger
from parsec.util import replicate
from cylc.task_id import TaskID
from C3MRO import C3
Expand Down Expand Up @@ -1698,7 +1698,7 @@ def generate_taskdefs(self, line, left_nodes, right, section, seq,
if self.run_mode == 'live':
# Record message outputs.
for lbl, msg in self.cfg['runtime'][name]['outputs'].items():
outp = output(msg, base_interval)
outp = MessageOutput(msg, base_interval)
if outp not in self.taskdefs[name].outputs:
self.taskdefs[name].outputs.append(outp)

Expand Down Expand Up @@ -1736,7 +1736,7 @@ def generate_triggers(self, lexpression, left_nodes, right, seq, suicide):
offset_tuple = (lnode.offset_string, None)
ltaskdef.intercycle_offsets.append(offset_tuple)

trig = trigger(
trig = Trigger(
lnode.name, lnode.output, lnode.offset_string, cycle_point,
suicide, self.cfg['runtime'][lnode.name]['outputs'],
base_interval)
Expand Down
19 changes: 12 additions & 7 deletions lib/cylc/output.py → lib/cylc/message_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,27 @@
from trigger import get_message_offset


class output(object):
class MessageOutput(object):
"""
Task outputs, used to generate message output strings.
A task message output.
Unlike prerequisites generated by task triggers, which can have message
and graph offsets, outputs only have message offsets; they are always
evaluated at the task's own cycle point.
Used to generate an output strings.for a message triggers at cycle point.
TODO - these can be plain strings once the deprecated cycle point offset
placeholders are removed from cylc (see GitHub #1761).
TODO - this module can probably be unified with trigger.py.
"""

def __init__(self, msg, base_interval=None):
self.msg = msg
self.msg_offset = get_message_offset(msg, base_interval)

def get(self, point):
def get_string(self, point):
"""Return the message string for this cycle point.
Placeholders are replaced with the actual cycle point offset.
"""
new_point = point
if self.msg_offset:
new_point = point + self.msg_offset
Expand Down
2 changes: 1 addition & 1 deletion lib/cylc/outputs.py → lib/cylc/task_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# A collection of messages representing the outputs of ONE TASK.


class outputs(object):
class TaskOutputs(object):
def __init__(self, owner_id):

self.owner_id = owner_id
Expand Down
9 changes: 6 additions & 3 deletions lib/cylc/task_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""Provide a class to represent a task proxy in a running suite."""

from collections import namedtuple
Expand Down Expand Up @@ -50,7 +51,7 @@
from cylc.job_file import JOB_FILE
from cylc.job_host import RemoteJobHostManager
from cylc.batch_sys_manager import BATCH_SYS_MANAGER
from cylc.outputs import outputs
from cylc.task_outputs import TaskOutputs
from cylc.owner import is_remote_user, user
from cylc.poll_timer import PollTimer
from cylc.prerequisite import Prerequisite
Expand Down Expand Up @@ -250,9 +251,11 @@ def __init__(
self.point_as_seconds = None

# Task outputs.
self.outputs = outputs(self.identity)
self.outputs = TaskOutputs(self.identity)
# Message outputs.
for outp in self.tdef.outputs:
self.outputs.add(outp.get(self.point))
self.outputs.add(outp.get_string(self.point))
# Standard outputs.
self.outputs.add_standard()

self.external_triggers = {}
Expand Down
45 changes: 20 additions & 25 deletions lib/cylc/trigger.py → lib/cylc/task_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,40 @@


warned = False

BCOMPAT_MSG_RE_C5 = re.compile('^(.*)\[\s*T\s*(([+-])\s*(\d+))?\s*\](.*)$')
BCOMPAT_MSG_RE_C6 = re.compile('^(.*)\[\s*(([+-])?\s*(.*))?\s*\](.*)$')
DEPRECN_WARN_TMPL = "WARNING: message trigger offsets are deprecated\n %s"

def get_message_offset(msg, base_interval=None):
"""Return back-compat message offset, or None."""
"""Return deprecated message offset, or None.
TODO - this function can be deleted once the deprecated cycle point offset
placeholders are removed from cylc (see GitHub #1761).
BACK_COMPAT_MSG_RE_OLD = re.compile('^(.*)\[\s*T\s*(([+-])\s*(\d+))?\s*\](.*)$')
BACK_COMPAT_MSG_RE = re.compile('^(.*)\[\s*(([+-])?\s*(.*))?\s*\](.*)$')
DEPRECATION_TEMPLATE = "WARNING: message trigger offsets are deprecated\n %s"
"""

offset = None
global warned
global BCOMPAT_MSG_RE_C5
global BCOMPAT_MSG_RE_C6
global DEPRECN_WARN_TMPL

# cylc-5 [T+n] message offset - DEPRECATED
m = re.match(BACK_COMPAT_MSG_RE_OLD, msg)
m = re.match(BCOMPAT_MSG_RE_C5, msg)
if m:
if not warned:
print >> sys.stderr, DEPRECATION_TEMPLATE % msg
print >> sys.stderr, DEPRECN_WARN_TMPL % msg
warned = True
prefix, signed_offset, sign, offset, suffix = m.groups()
if signed_offset is not None:
offset = base_interval.get_inferred_child(
signed_offset)
else:
# cylc-6 [<interval>] message offset - DEPRECATED
n = re.match(BACK_COMPAT_MSG_RE, msg)
n = re.match(BCOMPAT_MSG_RE_C6, msg)
if n:
if not warned:
print >> sys.stderr, DEPRECATION_TEMPLATE % msg
print >> sys.stderr, DEPRECN_WARN_TMPL % msg
warned = True
prefix, signed_offset, sign, offset, suffix = n.groups()
if offset:
Expand All @@ -72,23 +78,12 @@ def __str__(self):
return repr(self.msg)


class trigger(object):
class TaskTrigger(object):
"""
A task trigger is a prerequisite in the abstract, defined by the suite graph.
It generates a concrete prerequisite string given a task's cycle point value.
"""
Task triggers, used to generate prerequisite messages.
#(a) graph offsets:
# trigger bar if foo at -P1D succeeded:
graph = foo[-P1D] => bar
# trigger bar if foo at -P1D reported message output:
graph = foo[-P1D]:x => bar
#(b) output message offsets:
[runtime]
[[foo]]
[[[outputs]]]
x = "file X uploaded"
y = "file Y finished"
"""

def __init__(
self, task_name, qualifier=None, graph_offset_string=None,
Expand Down

0 comments on commit 9932fc5

Please sign in to comment.