Skip to content

Commit

Permalink
Merge pull request #6196 from MetRonnie/command-validation
Browse files Browse the repository at this point in the history
Command validation: include more in validation step
  • Loading branch information
oliver-sanders authored Sep 11, 2024
2 parents 2ec0cb3 + d2094fb commit 880db71
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 @@ -282,10 +282,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

Check warning on line 288 in cylc/flow/commands.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/commands.py#L288

Added line #L288 was not covered by tests
LOG.info(
f"Setting hold cycle point: {cycle_point}\n"
"All tasks after this point will be held."
Expand All @@ -304,13 +304,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

Check warning on line 313 in cylc/flow/commands.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/commands.py#L313

Added line #L313 was not covered by tests


@_command('remove_tasks')
Expand Down Expand Up @@ -444,5 +444,6 @@ async def force_trigger_tasks(
):
"""Manual task trigger."""
validate.is_tasks(tasks)
validate.flow_opts(flow, flow_wait)

Check warning on line 447 in cylc/flow/commands.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/commands.py#L447

Added line #L447 was not covered by tests
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 880db71

Please sign in to comment.