diff --git a/cylc/flow/scheduler.py b/cylc/flow/scheduler.py index 1c95008a948..20b82f3a88a 100644 --- a/cylc/flow/scheduler.py +++ b/cylc/flow/scheduler.py @@ -2157,14 +2157,20 @@ def command_set( self, tasks: List[str], flow: List[str], - outputs: List[str], - prerequisites: List[str], + outputs: Optional[List[str]] = None, + prerequisites: Optional[List[str]] = None, flow_wait: bool = False, flow_descr: Optional[str] = None ): """Force spawn task successors. + Note, the "outputs" and "prerequisites" arguments might not be + populated in the mutation arguments so must provide defaults here. """ + if outputs is None: + outputs = [] + if prerequisites is None: + prerequisites = [] return self.pool.set_prereqs_and_outputs( tasks, outputs, prerequisites, flow, flow_wait, flow_descr ) diff --git a/tests/integration/scripts/test_set.py b/tests/integration/scripts/test_set.py index 276bd726ccf..22cd44bbbce 100644 --- a/tests/integration/scripts/test_set.py +++ b/tests/integration/scripts/test_set.py @@ -73,7 +73,7 @@ async def test_rerun_incomplete( }, 'runtime': { # register a custom output - 'a': {'outputs': {'x': 'x'}}, + 'a': {'outputs': {'x': 'xyz'}}, }, }) schd = scheduler(id_, paused_start=False) @@ -103,7 +103,7 @@ async def test_data_store( }, 'runtime': { # register a custom output - 'a': {'outputs': {'x': 'x'}}, + 'a': {'outputs': {'x': 'xyz'}}, }, }) schd = scheduler(id_) diff --git a/tests/integration/tui/screenshots/test_set_mutation.set-command-selected.html b/tests/integration/tui/screenshots/test_set_mutation.set-command-selected.html new file mode 100644 index 00000000000..8f27deac20e --- /dev/null +++ b/tests/integration/tui/screenshots/test_set_mutation.set-command-selected.html @@ -0,0 +1,16 @@ +
Cylc Tui   work────────────────────────────────────────────────               
+                 id: 1/a                                                      
+- ~cylc                                                                       
+   - one - paus  Action                                                       
+      - ̿○ 1      < (cancel)                                 >                 
+           ̿○ a                                                                
+           ○ z   < hold                                     >                 
+                 < kill                                     >                 
+                 < log                                      >                 
+                 < poll                                     >                 
+                 < release                                  >                 
+                 < set                                      >                 
+                                                                              
+quit: q  help:  q to close                                     ↥ ↧ Home End   
+filter tasks: T────────────────────────────────────────────────               
+
\ No newline at end of file diff --git a/tests/integration/tui/screenshots/test_set_mutation.task-state-updated.html b/tests/integration/tui/screenshots/test_set_mutation.task-state-updated.html new file mode 100644 index 00000000000..37924d9b0e3 --- /dev/null +++ b/tests/integration/tui/screenshots/test_set_mutation.task-state-updated.html @@ -0,0 +1,16 @@ +
Cylc Tui   workflows filtered (W - edit, E - reset)                             
+                                                                                
+- ~cylc                                                                         
+   - one - paused 1■                                                            
+      - ̿○ 1                                                                     
+           ̿● a                                                                  
+           ̿○ z                                                                  
+                                                                                
+                                                                                
+                                                                                
+                                                                                
+                                                                                
+                                                                                
+quit: q  help: h  context: enter  tree: - ← + →  navigation: ↑ ↓ ↥ ↧ Home End   
+filter tasks: T f s r R  filter workflows: W E p                                
+
\ No newline at end of file diff --git a/tests/integration/tui/test_mutations.py b/tests/integration/tui/test_mutations.py index fd7a58675fd..844a0654ab1 100644 --- a/tests/integration/tui/test_mutations.py +++ b/tests/integration/tui/test_mutations.py @@ -31,6 +31,30 @@ async def gen_commands(schd): yield schd.command_queue.get()[1:] +async def process_command(schd, tries=10, interval=0.1): + """Wait for command(s) to be queued and run. + + Waits for at least one command to be queued and for all queued commands to + be run. + """ + # wait for the command to be queued + for _try in range(tries): + await asyncio.sleep(interval) + if not schd.command_queue.empty(): + break + else: + raise Exception(f'No command was queued after {tries * interval}s') + + # run the command + await schd.process_command_queue() + + # push out updates + await schd.update_data_structure() + + # make sure it ran + assert schd.command_queue.empty(), 'command queue has not emptied' + + async def test_online_mutation( one_conf, flow, @@ -215,3 +239,55 @@ async def test_offline_mutation( 'there should be a box displaying the error containing the stderr' ' returned by the command', ) + + +async def test_set_mutation( + flow, + scheduler, + start, + rakiura, +): + id_ = flow({ + 'scheduling': { + 'graph': { + 'R1': 'a => z' + }, + }, + }, name='one') + schd = scheduler(id_) + async with start(schd): + await schd.update_data_structure() + with rakiura(schd.tokens.id, size='80,15') as rk: + # open the context menu on 1/a + rk.user_input('down', 'down', 'down', 'enter') + rk.force_update() + + # select the "set" mutation + rk.user_input(*(('down',) * 6)) # 6th command down + + rk.compare_screenshot( + # take a screenshot to ensure we have focused on the mutation + # successfully + 'set-command-selected', + 'The command menu should be open for the task 1/a with the' + ' set command selected.' + ) + + # issue the "set" mutation + rk.user_input('enter') + + # wait for the command to be received and run it + await process_command(schd) + + # close the error dialogue + # NOTE: This hides an asyncio error that does not occur outside of + # the tests + rk.user_input('q', 'q', 'q') + + rk.compare_screenshot( + # take a screenshot to ensure we have focused on the mutation + # successfully + 'task-state-updated', + '1/a should now show as succeeded,' + ' there should be no associated job.' + )