Skip to content

Comments

Fix bug when broadcasting deprecated config#7121

Merged
oliver-sanders merged 3 commits intocylc:8.6.xfrom
MetRonnie:broadcast-upg
Feb 12, 2026
Merged

Fix bug when broadcasting deprecated config#7121
oliver-sanders merged 3 commits intocylc:8.6.xfrom
MetRonnie:broadcast-upg

Conversation

@MetRonnie
Copy link
Member

@MetRonnie MetRonnie commented Dec 4, 2025

Repro

Any simple workflow

$ cylc broadcast wflow -p 1 -n foo -s '[job]execution time limit'

Traceback (most recent call last):
  File ".../bin/cylc", line 9, in <module>
    sys.exit(main())
             ^^^^^^
  File ".../lib/python3.12/site-packages/cylc/flow/scripts/cylc.py", line 646, in main
    ret = _main(opts, cmd_args)
          ^^^^^^^^^^^^^^^^^^^^^
  File ".../lib/python3.12/site-packages/cylc/flow/scripts/cylc.py", line 706, in _main
    return execute_cmd(command, *cmd_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../lib/python3.12/site-packages/cylc/flow/scripts/cylc.py", line 329, in execute_cmd
    entry_point.load()(*args)
  File ".../lib/python3.12/site-packages/cylc/flow/terminal.py", line 298, in wrapper
    wrapped_function(*wrapped_args, **wrapped_kwargs)
  File ".../lib/python3.12/site-packages/cylc/flow/scripts/broadcast.py", line 506, in main
    rets = asyncio.run(_main(options, *ids))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../lib/python3.12/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File ".../lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../lib/python3.12/asyncio/base_events.py", line 691, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File ".../lib/python3.12/site-packages/cylc/flow/scripts/broadcast.py", line 511, in _main
    return await call_multi_async(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File ".../lib/python3.12/site-packages/cylc/flow/network/multi.py", line 139, in call_multi_async
    out, err, outcome = _process_response(
                        ^^^^^^^^^^^^^^^^^^
  File ".../lib/python3.12/site-packages/cylc/flow/network/multi.py", line 227, in _process_response
    raise response
  File ".../lib/python3.12/site-packages/cylc/flow/async_util.py", line 436, in _inner
    return await coroutine(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../lib/python3.12/site-packages/cylc/flow/scripts/broadcast.py", line 476, in run
    modified_settings = result['response'][0]
                        ~~~~~~~~~~~~~~~~~~^^^
KeyError: 0

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).
  • No dependency changes
  • Tests are included
  • Changelog entry included if this is a change that can affect users
  • Docs not needed
  • If this is a bug fix, PR should be raised against the relevant ?.?.x branch.

@MetRonnie MetRonnie added this to the 8.6.2 milestone Dec 4, 2025
@MetRonnie MetRonnie self-assigned this Dec 4, 2025
@MetRonnie MetRonnie added the bug Something is wrong :( label Dec 4, 2025
@MetRonnie MetRonnie marked this pull request as ready for review December 15, 2025 18:54
@MetRonnie MetRonnie requested a review from wxtim December 16, 2025 14:45
@wxtim
Copy link
Member

wxtim commented Jan 9, 2026

@ColemanTom has spotted this in the wild....

Closes #7167

@MetRonnie MetRonnie modified the milestones: 8.6.x, 8.6.3 Jan 9, 2026
Copy link
Member

@oliver-sanders oliver-sanders left a comment

Choose a reason for hiding this comment

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

LGTM, tested as working.

Gotta couple of QA things which aren't covered by the linter, open to debate.

Comment on lines 64 to 67
self.DEPR_MSG = self.DEPR_TEMPLATE.format('broadcast')
self.OBSLT_MSG = (
"Obsolete config items were rejected by the broadcast."
)
Copy link
Member

Choose a reason for hiding this comment

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

Overloading class constants isn't the nicest pattern (actually gets flagged by flake8 C002 as redefinition of constant).

Both only get used once, so might be more appropriate to do the formatting there than storing the modified template on the instance?

Copy link
Member Author

Choose a reason for hiding this comment

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

Is that just because the variables have uppercase names? Otherwise there is nothing constant about class attributes and there can be no harm in reassigning a instance attribute that shares the same name as a class attribute

Copy link
Member

Choose a reason for hiding this comment

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

Yep. Python has no top-level concept of a constant, so there is a convention instead, we use upper case for constants and lower case for variables. Once defined a constant should not be redefined (C002).

This pattern is also using class/instance variable shadowing because we have two variables with the same name, cls.DEPR_MSG and self.DEPR_MSG which can be confusing as self.DEPR_MSG will return cls.DEPR_MSG if the instance variable is unset.

@oliver-sanders oliver-sanders merged commit 113a724 into cylc:8.6.x Feb 12, 2026
22 of 23 checks passed
@MetRonnie MetRonnie deleted the broadcast-upg branch February 12, 2026 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something is wrong :(

Projects

None yet

Development

Successfully merging this pull request may close these issues.

broadcast using deprecated settings syntax leads to ungraceful failure

3 participants