diff --git a/cylc/flow/network/schema.py b/cylc/flow/network/schema.py index cfa6986189a..19298918cd3 100644 --- a/cylc/flow/network/schema.py +++ b/cylc/flow/network/schema.py @@ -1444,11 +1444,15 @@ class TimePoint(String): class WorkflowStopMode(Enum): """The mode used to stop a running workflow.""" + # NOTE: using a different enum because: + # * Graphene requires special enums. + # * We only want to offer a subset of stop modes. + # Note: contains only the REQUEST_* values from StopMode - Clean = StopMode.REQUEST_CLEAN - Kill = StopMode.REQUEST_KILL - Now = StopMode.REQUEST_NOW - NowNow = StopMode.REQUEST_NOW_NOW + Clean = StopMode.REQUEST_CLEAN.value + Kill = StopMode.REQUEST_KILL.value + Now = StopMode.REQUEST_NOW.value + NowNow = StopMode.REQUEST_NOW_NOW.value @property def description(self): @@ -1722,7 +1726,7 @@ class Meta: class Arguments: workflows = List(WorkflowID, required=True) mode = WorkflowStopMode( - default_value=StopMode.REQUEST_CLEAN + default_value=WorkflowStopMode.Clean.value # type: ignore ) cycle_point = CyclePoint( description='Stop after the workflow reaches this cycle.' diff --git a/cylc/flow/scheduler.py b/cylc/flow/scheduler.py index 19e9ac9cf3b..ba08237943b 100644 --- a/cylc/flow/scheduler.py +++ b/cylc/flow/scheduler.py @@ -856,6 +856,11 @@ def command_stop( pass else: # immediate shutdown + try: + mode = StopMode(mode) + except ValueError: + LOG.error(f'Invalid stop mode {mode}') + return self._set_stop(mode) if mode is StopMode.REQUEST_KILL: self.time_next_kill = time() diff --git a/cylc/flow/scripts/cylc.py b/cylc/flow/scripts/cylc.py index 8d8b2007e02..036cf4c05a9 100644 --- a/cylc/flow/scripts/cylc.py +++ b/cylc/flow/scripts/cylc.py @@ -137,8 +137,6 @@ def get_version(long=False): ' use cylc graph --diff ', 'gscan': 'cylc gscan has been removed, use the web UI', - 'gui': - 'cylc gui has been removed, use the web UI', 'insert': 'inserting tasks is now done automatically', 'jobscript': @@ -329,7 +327,7 @@ def cli_version(long_fmt=False): """Wrapper for get_version.""" print(get_version(long_fmt)) if long_fmt: - list_plugins() + print(list_plugins()) sys.exit(0) @@ -357,23 +355,26 @@ def list_plugins(): for entry_point in entry_points } + lines = [] if dists: - print('\nPlugins:') + lines.append('\nPlugins:') maxlen1 = max(len(dist.project_name) for dist in dists) + 2 maxlen2 = max(len(dist.version) for dist in dists) + 2 for dist in dists: - print( + lines.append( f' {dist.project_name.ljust(maxlen1)}' f' {dist.version.ljust(maxlen2)}' f' {dist.module_path}' ) - print('\nEntry Points:') + lines.append('\nEntry Points:') for entry_point_name, entry_points in entry_point_groups.items(): if entry_points: - print(f' {entry_point_name}:') + lines.append(f' {entry_point_name}:') for entry_point in entry_points: - print(f' {entry_point}') + lines.append(f' {entry_point}') + + return '\n'.join(lines) @contextmanager