Skip to content

Commit

Permalink
Command validation: include more
Browse files Browse the repository at this point in the history
  • Loading branch information
MetRonnie committed Jul 4, 2024
1 parent 6d31111 commit d2094fb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
7 changes: 7 additions & 0 deletions cylc/flow/command_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,14 @@ def is_tasks(tasks: Iterable[str]):
...
cylc.flow.exceptions.InputError: This command does not take job ids:
* */baz/12
>>> is_tasks([])
Traceback (most recent call last):
...
cylc.flow.exceptions.InputError: No tasks specified
"""
if not tasks:
raise InputError("No tasks specified")
bad_tasks: List[str] = []
for task in tasks:
tokens = Tokens('//' + task)
Expand Down
5 changes: 3 additions & 2 deletions cylc/flow/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,10 @@ async def hold(schd: 'Scheduler', tasks: Iterable[str]):
@_command('set_hold_point')
async def set_hold_point(schd: 'Scheduler', point: str):
"""Hold all tasks after the specified cycle point."""
yield
cycle_point = TaskID.get_standardised_point(point)
if cycle_point is None:
raise CyclingError("Cannot set hold point to None")
yield
LOG.info(
f"Setting hold cycle point: {cycle_point}\n"
"All tasks after this point will be held."
Expand All @@ -299,13 +299,13 @@ async def pause(schd: 'Scheduler'):
@_command('set_verbosity')
async def set_verbosity(schd: 'Scheduler', level: Union[int, str]):
"""Set workflow verbosity."""
yield
try:
lvl = int(level)
LOG.setLevel(lvl)
except (TypeError, ValueError) as exc:
raise CommandFailedError(exc)
cylc.flow.flags.verbosity = log_level_to_verbosity(lvl)
yield


@_command('remove_tasks')
Expand Down Expand Up @@ -439,5 +439,6 @@ async def force_trigger_tasks(
):
"""Manual task trigger."""
validate.is_tasks(tasks)
validate.flow_opts(flow, flow_wait)
yield
yield schd.pool.force_trigger_tasks(tasks, flow, flow_wait, flow_descr)
2 changes: 0 additions & 2 deletions cylc/flow/scripts/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import sys
from typing import TYPE_CHECKING

from cylc.flow import command_validation
from cylc.flow.network.client_factory import get_client
from cylc.flow.network.multi import call_multi
from cylc.flow.option_parsers import (
Expand Down Expand Up @@ -115,7 +114,6 @@ async def run(options: 'Values', workflow_id: str, *tokens_list):
@cli_function(get_option_parser)
def main(parser: COP, options: 'Values', *ids: str):
"""CLI for "cylc trigger"."""
command_validation.flow_opts(options.flow or ['all'], options.flow_wait)
rets = call_multi(
partial(run, options),
*ids,
Expand Down

0 comments on commit d2094fb

Please sign in to comment.