Skip to content

Commit

Permalink
Don't record satisfied xtriggers in the DB
Browse files Browse the repository at this point in the history
Closes cylc#5911
  • Loading branch information
wxtim committed Jan 15, 2024
1 parent c07392d commit 937b595
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cylc/flow/workflow_db_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,10 @@ def put_task_event_timers(self, task_events_mgr):
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(trigger_time='):
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
37 changes: 37 additions & 0 deletions tests/integration/test_workflow_db_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,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/>.

import asyncio
import pytest
import sqlite3

Expand Down Expand Up @@ -127,3 +128,39 @@ 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):
"""Database does not record wall_clock xtriggers.
https://github.com/cylc/cylc-flow/issues/5911
"""
id_ = flow({
"scheduler": {
"allow implicit tasks": True,
'cycle point format': '%Y'
},
"scheduling": {
"initial cycle point": "1348",
"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"
}
},
})
# Run workflow unto completion:
schd = scheduler(id_, paused_start=False)
async with run(schd) as log:
while 'Workflow shutting down - AUTOMATIC' not in log.messages:
await asyncio.sleep(1)

# Get xtriggers db table:
info = schd.workflow_db_mgr.get_pri_dao().conn.execute(
'SELECT * FROM xtriggers').fetchall()

# All xtriggers are xrandom: None are wall_clock:
assert all(i[0].startswith('xrandom') for i in info)

0 comments on commit 937b595

Please sign in to comment.