Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🤖 Merge 8.2.x-sync into master #5957

Merged
merged 2 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions cylc/flow/workflow_db_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,10 @@ def put_task_event_timers(self, task_events_mgr) -> None:
def put_xtriggers(self, sat_xtrig):
"""Put statements to update external triggers table."""
for sig, res in sat_xtrig.items():
self.db_inserts_map[self.TABLE_XTRIGGERS].append({
"signature": sig,
"results": json.dumps(res)})
if not sig.startswith('wall_clock('):
self.db_inserts_map[self.TABLE_XTRIGGERS].append({
"signature": sig,
"results": json.dumps(res)})

def put_update_task_state(self, itask):
"""Update task_states table for current state of itask.
Expand Down
66 changes: 59 additions & 7 deletions tests/integration/test_workflow_db_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import asyncio
import pytest
import sqlite3
from typing import TYPE_CHECKING

from cylc.flow.scheduler import Scheduler
from cylc.flow.cycling.iso8601 import ISO8601Point

if TYPE_CHECKING:
from cylc.flow.scheduler import Scheduler


async def test_restart_number(
Expand All @@ -29,7 +34,7 @@ async def test_restart_number(
async def test(expected_restart_num: int, do_reload: bool = False):
"""(Re)start the workflow and check the restart number is as expected.
"""
schd: Scheduler = scheduler(id_, paused_start=True)
schd: 'Scheduler' = scheduler(id_, paused_start=True)
async with start(schd) as log:
if do_reload:
schd.command_reload_workflow()
Expand All @@ -52,7 +57,7 @@ async def test(expected_restart_num: int, do_reload: bool = False):
await test(expected_restart_num=3)


def db_remove_column(schd: Scheduler, table: str, column: str) -> None:
def db_remove_column(schd: 'Scheduler', table: str, column: str) -> None:
"""Remove a column from a scheduler DB table.

ALTER TABLE DROP COLUMN is not supported by sqlite yet, so we have to copy
Expand Down Expand Up @@ -82,23 +87,23 @@ async def test_db_upgrade_pre_803(
id_ = flow(one_conf)

# Run a scheduler to create a DB.
schd: Scheduler = scheduler(id_, paused_start=True)
schd: 'Scheduler' = scheduler(id_, paused_start=True)
async with start(schd):
assert ('n_restart', '0') in db_select(schd, False, 'workflow_params')

# Remove task_states:is_manual_submit to fake a pre-8.0.3 DB.
db_remove_column(schd, "task_states", "is_manual_submit")
db_remove_column(schd, "task_jobs", "flow_nums")

schd: Scheduler = scheduler(id_, paused_start=True)
schd: 'Scheduler' = scheduler(id_, paused_start=True)

# Restart should fail due to the missing column.
with pytest.raises(sqlite3.OperationalError):
async with start(schd):
pass
assert ('n_restart', '1') in db_select(schd, False, 'workflow_params')

schd: Scheduler = scheduler(id_, paused_start=True)
schd: 'Scheduler' = scheduler(id_, paused_start=True)

# Run the DB upgrader for version 8.0.2
# (8.0.2 requires upgrade)
Expand All @@ -117,7 +122,7 @@ async def test_workflow_param_rapid_toggle(

https://github.com/cylc/cylc-flow/issues/5593
"""
schd: Scheduler = scheduler(flow(one_conf), paused_start=False)
schd: 'Scheduler' = scheduler(flow(one_conf), paused_start=False)
async with run(schd):
assert schd.is_paused is False
schd.pause_workflow()
Expand All @@ -127,3 +132,50 @@ async def test_workflow_param_rapid_toggle(

w_params = dict(schd.workflow_db_mgr.pri_dao.select_workflow_params())
assert w_params['is_paused'] == '0'


async def test_record_only_non_clock_triggers(
flow, run, scheduler, complete, db_select
):
"""Database does not record wall_clock xtriggers.

https://github.com/cylc/cylc-flow/issues/5911

Includes:
- Not in DB: A normal wall clock xtrigger (wall_clock).
- In DB: An xrandom mis-labelled as wall_clock trigger DB).
- Not in DB: An execution retry xtrigger.

@TODO: Refactor to use simulation mode to speedup after Simulation
mode upgrade bugfixes: This should speed this test up considerably.
"""
rawpoint = '1348'
id_ = flow({
"scheduler": {
'cycle point format': '%Y',
'allow implicit tasks': True
},
"scheduling": {
"initial cycle point": rawpoint,
"xtriggers": {
"another": "xrandom(100)",
"wall_clock": "xrandom(100, _=Not a real wall clock trigger)",
"real_wall_clock": "wall_clock()"
},
"graph": {
"R1": """
@another & @wall_clock & @real_wall_clock => foo
@real_wall_clock => bar
"""
}
},
})
schd = scheduler(id_, paused_start=False, run_mode='simulation')

async with run(schd):
await complete(schd, timeout=20)

# Assert that (only) the real clock trigger is not in the db:
assert db_select(schd, False, 'xtriggers', 'signature') == [
('xrandom(100)',),
('xrandom(100, _=Not a real wall clock trigger)',)]
Loading