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

Add "valid for" states to schema def for cylc set #6095

Merged
merged 1 commit into from
May 8, 2024
Merged
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
2 changes: 2 additions & 0 deletions cylc/flow/network/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -2103,6 +2103,8 @@ class Meta:
- ``started`` implies ``submitted``.
- ``succeeded`` and ``failed`` imply ``started``.
- custom outputs and ``expired`` do not imply any other outputs.

Valid for: paused, running, stopping workflows.
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this command is really valid for stopping workflows:

Suggested change
Valid for: paused, running, stopping workflows.
Valid for: paused, running.

Copy link
Member Author

Choose a reason for hiding this comment

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

If waiting for tasks to finish while stopping, is it not valid for users to set task states? I think it can be done from the CLI

Copy link
Member

Choose a reason for hiding this comment

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

Ooh, there is a reasonable point there due to this use case:

I need to orphan a "stuck" job submission

-- https://github.com/cylc/cylc-admin/blob/master/docs/proposal-interventions.md#4-i-need-to-orphan-a-stuck-job-submission

Which could otherwise block shutdown.

Ok, leave as is.

""")
resolver = partial(mutator, command='set')

Expand Down
24 changes: 24 additions & 0 deletions tests/unit/network/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@

from dataclasses import dataclass
from inspect import isclass
import re

import graphene
import pytest

from cylc.flow.cfgspec.workflow import SPEC as WORKFLOW_SPEC
from cylc.flow.network.schema import (
RUNTIME_FIELD_TO_CFG_MAP,
Mutations,
Runtime,
sort_elements,
SortArgs,
)
from cylc.flow.workflow_status import WorkflowStatus


@dataclass
Expand Down Expand Up @@ -99,3 +103,23 @@ def test_runtime_field_to_cfg_map(field_name: str):
cfg_name = RUNTIME_FIELD_TO_CFG_MAP[field_name]
assert field_name in Runtime.__dict__
assert WORKFLOW_SPEC.get('runtime', '__MANY__', cfg_name)


@pytest.mark.parametrize('mutation', (
pytest.param(attr, id=name)
for name, attr in Mutations.__dict__.items()
if isinstance(attr, graphene.Field)
))
def test_mutations_valid_for(mutation):
"""Check that all mutations have a "Valid for" in their description.

This is needed by the UI to disable mutations that are not valid for the
workflow state.
"""
match = re.search(
r'Valid for:\s(.*)\sworkflows.', mutation.description
)
assert match
valid_states = set(match.group(1).split(', '))
assert valid_states
assert not valid_states.difference(i.value for i in WorkflowStatus)
Loading