Skip to content

Commit

Permalink
fix merge mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
wxtim committed Oct 24, 2023
1 parent 12ba4c9 commit acf659f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 30 deletions.
4 changes: 2 additions & 2 deletions cylc/flow/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"""Utilities supporting simulation and skip modes
"""

from queue import Queue
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
from time import time

Expand All @@ -33,6 +32,7 @@
from metomi.isodatetime.parsers import DurationParser

if TYPE_CHECKING:
from queue import Queue
from cylc.flow.cycling import PointBase
from cylc.flow.task_proxy import TaskProxy

Expand Down Expand Up @@ -132,7 +132,7 @@ def disable_platforms(


def parse_fail_cycle_points(
f_pts_orig: list
f_pts_orig: List[str]
) -> 'Union[None, List[PointBase]]':
"""Parse `[simulation][fail cycle points]`.
Expand Down
20 changes: 10 additions & 10 deletions cylc/flow/task_events_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,16 +592,6 @@ def process_message(
itask, severity, message, event_time, flag, submit_num):
return None

severity = cast(int, LOG_LEVELS.get(severity, INFO))
# Demote log level to DEBUG if this is a message that duplicates what
# gets logged by itask state change anyway (and not manual poll)
if severity > DEBUG and flag != self.FLAG_POLLED and message in {
self.EVENT_SUBMITTED, self.EVENT_STARTED, self.EVENT_SUCCEEDED,
self.EVENT_SUBMIT_FAILED, f'{FAIL_MESSAGE_PREFIX}ERR'
}:
severity = DEBUG
LOG.log(severity, f"[{itask}] {flag}{message} at {event_time}")

# always update the workflow state summary for latest message
if flag == self.FLAG_POLLED:
new_msg = f'{message} {self.FLAG_POLLED}'
Expand Down Expand Up @@ -819,6 +809,16 @@ def _process_message_check(
f"{self.FLAG_POLLED_IGNORED}{message}{timestamp}"
)
return False

severity = cast('int', LOG_LEVELS.get(severity, INFO))
# Demote log level to DEBUG if this is a message that duplicates what
# gets logged by itask state change anyway (and not manual poll)
if severity > DEBUG and flag != self.FLAG_POLLED and message in {
self.EVENT_SUBMITTED, self.EVENT_STARTED, self.EVENT_SUCCEEDED,
self.EVENT_SUBMIT_FAILED, f'{FAIL_MESSAGE_PREFIX}ERR'
}:
severity = DEBUG
LOG.log(severity, f"[{itask}] {flag}{message}{timestamp}")
return True

def setup_event_handlers(self, itask, event, message):
Expand Down
1 change: 0 additions & 1 deletion tests/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1761,7 +1761,6 @@ def test_configure_sim_mode(caplog):
'outputs': {},
}
rtconfig_2 = deepcopy(rtconfig_1)
rtconfig_2['job'] = job_section
rtconfig_2['simulation']['default run length'] = 'PT2S'

taskdefs = [
Expand Down
28 changes: 11 additions & 17 deletions tests/unit/test_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,13 @@ def test_set_simulation_script(fail_one_time_only):
}
}
result = build_dummy_script(rtc, 60)
expect = [
assert result.split('\n') == [
'sleep 60',
"cylc message '1'",
"cylc message '2'",
f"cylc__job__dummy_result {str(fail_one_time_only).lower()}"
" 1 || exit 1"
]
for i, line in enumerate(result.split('\n')):
assert expect[i] == line


@pytest.mark.parametrize(
Expand All @@ -92,22 +90,18 @@ def test_disable_platforms(rtc, expect):
disable_platforms(rtc)
assert rtc['platform'] == expect
subdicts = [v for v in rtc.values() if isinstance(v, dict)]
for val in [
v for subdict in subdicts
for k, v in subdict.items()
if k != 'platform'
]:
assert val is None
for subdict in subdicts:
for k, val in subdict.items():
if k != 'platform':
assert val is None


def test_parse_fail_cycle_points(monkeypatch):
before = ['2']
monkeypatch.setattr(
'cylc.flow.cycling.loader.get_point_cls',
lambda cycling_type: IntegerPoint)
result = parse_fail_cycle_points(before)[0]
assert isinstance(result, IntegerPoint)
assert int(result) == 2
def test_parse_fail_cycle_points(set_cycling_type):
before = ['2', '4']
set_cycling_type()
assert parse_fail_cycle_points(before) == [
IntegerPoint(i) for i in before
]


@pytest.mark.parametrize(
Expand Down

0 comments on commit acf659f

Please sign in to comment.