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

Better queue config warning. #3618

Merged
merged 3 commits into from
May 21, 2020
Merged

Better queue config warning. #3618

merged 3 commits into from
May 21, 2020

Conversation

hjoliver
Copy link
Member

@hjoliver hjoliver commented May 20, 2020

This is a small change with no associated Issue. Result of a user complaint today.

The following queue validation warning applies if the task bar (assigned to a queue) is not defined under [runtime] or if it is defined there but is simply not used in the graph:

WARNING - Queue configuration warnings:
        + q1: ignoring bar (task not defined)

On this branch, the warning in the latter case changes to:

WARNING - Queue configuration warnings:
        + q1: ignoring bar (task not used in the graph)

Requirements check-list

  • I have read CONTRIBUTING.md and added my name as a Code Contributor.
  • Contains logically grouped changes (else tidy your branch by rebase).
  • Does not contain off-topic changes (use other PRs for other changes).
  • Appropriate tests are included (unit and/or functional).
  • Appropriate change log entry included.
  • No documentation update required.

@hjoliver hjoliver self-assigned this May 20, 2020
@hjoliver hjoliver added could be better Not exactly a bug, but not ideal. small labels May 20, 2020
@hjoliver hjoliver added this to the cylc-8.0.0 milestone May 20, 2020
@hjoliver
Copy link
Member Author

This trivial change really demands a simple unit test, except that it requires the whole monolithic suite config class so at the moment a functional test would be much easier to write 😬 Might be best to wait on @oliver-sanders latest experiment? #3616 (which I have seen but not read yet...).

@hjoliver
Copy link
Member Author

That's weird, style fail in cylc/flow/cfgspec/globalcfg.py not touched by this branch 🤔

@kinow
Copy link
Member

kinow commented May 20, 2020

@hjoliver I merged a PR that had pycodestyle issues today, sorry. I thought it failed because of pending merge of other PR's in cylc-doc/cylc-sphinx-extensions.

https://github.com/cylc/cylc-flow/pull/3559/checks?check_run_id=685749339

@oliver-sanders
Copy link
Member

oliver-sanders commented May 20, 2020

This is definitely a unit-test problem rather than an integration-test.

Unit-testing this isn't especially easy due to complex objects getting in the way, it would be a lot easier if the code was functional, however, it is still doable:

Create a Mock object, then have a quick scan down the code searching for self. to see what you have to bolt onto it to get to the required branch in the code. You usually only need a few things:

# untested

def test_queue_thinggy(caplog):
    config = Mock()
    config.Q_DEFAULT = 'default'
    config.cfg = {
        'scheduling': {
            'queues': {
                'default': {}
            }
        },
        'runtime': {}
    }
    config.runtime = {
        'descendents': []
    }

    caplog.set_level(logging.INFO, logger='cylc')
    Config.configure_queues(config)
    assert caplog.reccord_tuples = [
        # expected log messages
    ]

Some examples of this mocking based approach to testing methods here: https://github.com/cylc/cylc-flow/tree/master/cylc/flow/tests/main_loop

@hjoliver
Copy link
Member Author

Ha, there's already a test_queue_config function in tests/test_config.py (using caplog too) ... and what's more, git blame says I wrote it. I think I need my brain looked at 🤣 It's not quite as clean as your suggestion as it uses a predefined SuiteConfig object (with a bunch of mocked bits inside) but it'll do.

@hjoliver
Copy link
Member Author

Rebased to pick up the off-topic style fix; unit test added.

members = bar
[[dependencies]]
# foo and bar not used
graph = "beef => wellington"
Copy link
Member

Choose a reason for hiding this comment

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

🍌

@oliver-sanders oliver-sanders merged commit d7caab4 into cylc:master May 21, 2020
@dpmatthews dpmatthews modified the milestones: cylc-8.0.0, cylc-8.0a2 May 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
could be better Not exactly a bug, but not ideal. small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants