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

Allow manual trigger when workflow paused. #6192

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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: 3 additions & 4 deletions cylc/flow/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1225,8 +1225,7 @@ def release_queued_tasks(self) -> bool:

"""
if (
not self.is_paused
and self.stop_mode is None
self.stop_mode is None
Copy link
Member

@oliver-sanders oliver-sanders Jul 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's nothing wrong with defining workflow pause as pausing all automatic job submission

This has gone a little further than that one word change above as we are now continuing to process the queues whilst the workflow is paused making the paused state a little more dynamic than before.

I don't think we actually need to process the entire queue to achieve this, we just need to skip any manually triggered tasks through the queue (ideally bypassing the queue itself if possible).

If we pass self.is_paused through to release_queued_tasks we could reduce the scope of this override such that it only impacts manually triggered tasks.

and self.auto_restart_time is None
and self.reload_pending is False
):
Expand Down Expand Up @@ -1883,7 +1882,7 @@ def pause_workflow(self, msg: Optional[str] = None) -> None:
if msg:
_msg += f': {msg}'
LOG.info(_msg)
self.is_paused = True
self.is_paused = self.pool.task_queue_mgr.is_paused = True
self.workflow_db_mgr.put_workflow_paused(True)
self.update_data_store()

Expand All @@ -1905,7 +1904,7 @@ def resume_workflow(self, quiet: bool = False) -> None:
return
if not quiet:
LOG.info("RESUMING the workflow now")
self.is_paused = False
self.is_paused = self.pool.task_queue_mgr.is_paused = False
self.workflow_db_mgr.put_workflow_paused(False)
self.update_data_store()

Expand Down
13 changes: 10 additions & 3 deletions cylc/flow/task_queues/independent.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def push_task(self, itask: 'TaskProxy') -> None:
if itask.tdef.name in self.members:
self.deque.appendleft(itask)

def release(self, active: Counter[str]) -> List['TaskProxy']:
def release(
self, active: Counter[str], is_paused: bool = False
) -> List['TaskProxy']:
"""Release tasks if below the active limit."""
# The "active" argument counts active tasks by name.
released: List['TaskProxy'] = []
Expand All @@ -54,7 +56,10 @@ def release(self, active: Counter[str]) -> List['TaskProxy']:
except IndexError:
# deque empty
break
if itask.state.is_held:
if (
itask.state.is_held or
(is_paused and not itask.is_manual_submit)
):
Comment on lines +59 to +62
Copy link
Member

@oliver-sanders oliver-sanders Jul 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would expect this functionality to work the same across all queue implementations, so we could really do with abstracting it into the base class rather than relying on each queue to implement it separately.

Note: If we could bypass the queue entirely that would be ideal.

Idea (for future work), write some abstract tests that should hold for all queue implementations.

held.append(itask)
else:
released.append(itask)
Expand Down Expand Up @@ -114,6 +119,8 @@ def __init__(self,
)

self.force_released: Set['TaskProxy'] = set()
# if paused don't release tasks unless manually triggered
self.is_paused = False

def push_task(self, itask: 'TaskProxy') -> None:
"""Push a task to the appropriate queue."""
Expand All @@ -124,7 +131,7 @@ def release_tasks(self, active: Counter[str]) -> List['TaskProxy']:
"""Release tasks up to the queue limits."""
released: List['TaskProxy'] = []
for queue in self.queues.values():
released += queue.release(active)
released += queue.release(active, self.is_paused)
if self.force_released:
released.extend(self.force_released)
self.force_released = set()
Expand Down
Loading