Skip to content

Commit

Permalink
Revert graph sorting change.
Browse files Browse the repository at this point in the history
  • Loading branch information
hjoliver committed Sep 26, 2022
1 parent 75c1763 commit 8d09900
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 46 deletions.
6 changes: 3 additions & 3 deletions cylc/flow/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2075,12 2075,12 @@ def load_graph(self):
traceback.print_exc()
msg = (
f"Cannot process recurrence {section}"
f" (initial cycle point={icp}"
f" (final cycle point={fcp}"
f" (initial cycle point={icp})"
f" (final cycle point={fcp})"
)
if isinstance(exc, CylcError):
msg = ' %s' % exc.args[0]
raise WorkflowConfigError(msg)
raise WorkflowConfigError(msg)
else:
self.nocycle_sequences.add(seq)
else:
Expand Down
16 changes: 8 additions & 8 deletions cylc/flow/cycling/nocycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 31,18 @@
NOCYCLE_PT_OMEGA
)

CYCLER_TYPE_NOCYCLE = "nocycle"
CYCLER_TYPE_SORT_KEY_NOCYCLE = 1


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

TYPE = CYCLER_TYPE_NOCYCLE
TYPE_SORT_KEY = CYCLER_TYPE_SORT_KEY_NOCYCLE

__slots__ = ('value')

def __init__(self, value: str) -> None:
if value not in [NOCYCLE_PT_ALPHA, NOCYCLE_PT_OMEGA]:
raise ValueError(f"Illegal Nocycle value {value}")
Expand Down Expand Up @@ -72,14 80,6 @@ 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(SequenceBase):
"""A single point sequence."""
Expand Down
29 changes: 2 additions & 27 deletions cylc/flow/scripts/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 43,7 @@
from typing import Dict, List, Optional, TYPE_CHECKING, Tuple, Callable

from cylc.flow.config import WorkflowConfig
from cylc.flow.cycling.nocycle import (
NOCYCLE_PT_ALPHA,
NOCYCLE_PT_OMEGA
)
from cylc.flow.cycling.nocycle import NOCYCLE_PT_ALPHA
from cylc.flow.exceptions import InputError, CylcError
from cylc.flow.id import Tokens
from cylc.flow.id_cli import parse_id
Expand Down Expand Up @@ -101,28 98,6 @@ def sort_integer_edge(id_):
)


def sort_datetime_node(id_):
"""Return sort tokens for nodes with cyclepoints in datetime format.
Lexicological sort, but tweaked for nocycle graphs.
Example:
>>> sort_datetime_node('2001/foo')
('foo', '2001')
>>> sort_datetime_node('alpha/foo')
('foo', '0')
>>> sort_datetime_node('omega/foo')
('foo', '9')
"""
tokens = Tokens(id_, relative=True)
if tokens['cycle'] == NOCYCLE_PT_ALPHA:
return (tokens['task'], '0')
elif tokens['cycle'] == NOCYCLE_PT_OMEGA:
return (tokens['task'], '9')
else:
return (tokens['task'], tokens['cycle'])


def sort_datetime_edge(item):
"""Return sort tokens for edges with cyclepoints in ISO8601 format.
Expand Down Expand Up @@ -186,7 161,7 @@ def _get_graph_nodes_edges(
edge_sort = sort_integer_edge
else:
# datetime sorting
node_sort = sort_datetime_node
node_sort = None
edge_sort = sort_datetime_edge

# get nodes
Expand Down
8 changes: 0 additions & 8 deletions tests/integration/utils/flow_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,24 147,16 @@ async def _run_flow(
# context manager.
# Need to shut down Scheduler, but time out in case something
# goes wrong:
print("ONE")
async with timeout(5):
print("TWAO")
if task:
print("THREE")
# ask the scheduler to shut down nicely,
# let main loop handle it:
schd._set_stop(StopMode.REQUEST_NOW_NOW)
await task
print("FOUR")
if schd.contact_data:
print("FIVE")
async with timeout(5):
# Scheduler still running... try more forceful tear down:
await schd.shutdown(SchedulerStop("integration test teardown"))
print("SIX")
if task:
# Brute force cleanup if something went wrong:
print("SEVEN")
task.cancel()
print("EIGHT")

0 comments on commit 8d09900

Please sign in to comment.