Skip to content

Commit

Permalink
Tidy up.
Browse files Browse the repository at this point in the history
  • Loading branch information
hjoliver committed Sep 24, 2022
1 parent 7a62450 commit 1b685a0
Show file tree
Hide file tree
Showing 7 changed files with 193 additions and 106 deletions.
18 changes: 9 additions & 9 deletions cylc/flow/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 26,6 @@
structures.
"""

# TODO NOCYCLE GRAPHS:
# - graph and check-circular for startup and shutdown

from contextlib import suppress
from copy import copy
from fnmatch import fnmatchcase
Expand Down Expand Up @@ -58,9 55,9 @@
INTEGER_CYCLING_TYPE, ISO8601_CYCLING_TYPE
)
from cylc.flow.cycling.nocycle import (
NocycleSequence,
NOCYCLE_SEQ_ALPHA,
NOCYCLE_SEQ_OMEGA,
NocycleSequence
NOCYCLE_SEQ_OMEGA
)
from cylc.flow.id import Tokens
from cylc.flow.cycling.integer import IntegerInterval
Expand All @@ -69,7 66,6 @@
CylcError,
WorkflowConfigError,
IntervalParsingError,
SequenceParsingError,
TaskDefError,
ParamExpandError,
InputError
Expand Down Expand Up @@ -274,8 270,8 @@ def __init__(
self.xtrigger_mgr = xtrigger_mgr
self.workflow_polling_tasks = {} # type: ignore # TODO figure out type

self.initial_point: Optional['PointBase'] = None
self.start_point: Optional['PointBase'] = None
self.initial_point: 'PointBase'
self.start_point: 'PointBase'
self.stop_point: Optional['PointBase'] = None
self.final_point: Optional['PointBase'] = None
self.nocycle_sequences: Set['NocycleSequence'] = set()
Expand Down Expand Up @@ -593,7 589,11 @@ def prelim_process_graph(self) -> None:
'cycling mode' not in self.cfg['scheduling'] and
self.cfg['scheduling'].get('initial cycle point', '1') == '1' and
all(
item in ['graph', '1', 'R1', 'startup', 'shutdown']
item in [
'graph', '1', 'R1',
str(NOCYCLE_SEQ_ALPHA),
str(NOCYCLE_SEQ_OMEGA)
]
for item in graphdict
)
):
Expand Down
7 changes: 6 additions & 1 deletion cylc/flow/cycling/integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 21,12 @@
import re

from cylc.flow.cycling import (
PointBase, IntervalBase, SequenceBase, ExclusionBase, parse_exclusion, cmp
PointBase,
IntervalBase,
SequenceBase,
ExclusionBase,
parse_exclusion,
cmp
)
from cylc.flow.exceptions import (
CylcMissingContextPointError,
Expand Down
69 changes: 67 additions & 2 deletions cylc/flow/cycling/nocycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 18,21 @@
Cycling logic for isolated non-cycling startup and shutdown graphs.
"""

from cylc.flow.cycling import PointBase, SequenceBase, cmp

# TODO: scheduler check DB to be sure alpha and omega sections have run or not.

# cycle point values
NOCYCLE_PT_ALPHA = "alpha"
NOCYCLE_PT_OMEGA = "omega"

NOCYCLE_POINTS = (
NOCYCLE_PT_ALPHA,
NOCYCLE_PT_OMEGA
)


class NocyclePoint:
class NocyclePoint(PointBase):
"""A string-valued point."""

def __init__(self, value: str) -> None:
Expand Down Expand Up @@ -52,8 61,27 @@ def __gt__(self, other):
def __str__(self):
return self.value

def _cmp(self, other):
return cmp(int(self), int(other))

def add(self, other):
# NOT USED
return None

def sub(self, other):
# NOT USED
return None

def TYPE(self) -> str:
# NOT USED
return self.__class__.__name__

def TYPE_SORT_KEY(self) -> int:
# NOT USED
return 0


class NocycleSequence:
class NocycleSequence(SequenceBase):
"""A single point sequence."""

def __init__(self, dep_section, p_context_start=None, p_context_stop=None):
Expand Down Expand Up @@ -89,6 117,43 @@ def __eq__(self, other):
def __str__(self):
return str(self.point)

def TYPE(self) -> str:
raise NotImplementedError

def TYPE_SORT_KEY(self) -> int:
raise NotImplementedError

def get_async_expr(cls, start_point=0):
raise NotImplementedError

def get_interval(self):
"""Return the cycling interval of this sequence."""
raise NotImplementedError

def get_offset(self):
"""Deprecated: return the offset used for this sequence."""
raise NotImplementedError

def set_offset(self, i_offset):
"""Deprecated: alter state to offset the entire sequence."""
raise NotImplementedError

def is_on_sequence(self, point):
"""Is point on-sequence, disregarding bounds?"""
raise NotImplementedError

def get_prev_point(self, point):
"""Return the previous point < point, or None if out of bounds."""
raise NotImplementedError

def get_nearest_prev_point(self, point):
"""Return the largest point < some arbitrary point."""
raise NotImplementedError

def get_stop_point(self):
"""Return the last point in this sequence, or None if unbounded."""
raise NotImplementedError


NOCYCLE_SEQ_ALPHA = NocycleSequence(NOCYCLE_PT_ALPHA)
NOCYCLE_SEQ_OMEGA = NocycleSequence(NOCYCLE_PT_OMEGA)
Loading

0 comments on commit 1b685a0

Please sign in to comment.