cylc-flow icon indicating copy to clipboard operation
cylc-flow copied to clipboard

Cylc Config json output mode

Open wxtim opened this issue 1 year ago • 5 comments

Add the following command to Cylc Config:

$ cylc config --json

Required for https://github.com/cylc/cylc-sphinx-extensions/pull/81.

Check List

  • [x] I have read CONTRIBUTING.md and added my name as a Code Contributor.
  • [x] Contains logically grouped changes (else tidy your branch by rebase).
  • [x] Does not contain off-topic changes (use other PRs for other changes).
  • [x] Applied any dependency changes to both setup.cfg (and conda-environment.yml if present).
  • [x] Tests are included (or explain why tests are not needed).
  • [x] Changelog entry included if this is a change that can affect users
  • [x] Cylc-Doc pull request opened if required at cylc/cylc-doc/pull/XXXX.
  • [x] If this is a bug fix, PR should be raised against the relevant ?.?.x branch.

wxtim avatar Aug 01 '24 07:08 wxtim

Lint failing

MetRonnie avatar Aug 23 '24 10:08 MetRonnie

Drafted pending other work this not being a priority compared to bugfixes.

wxtim avatar Aug 28 '24 08:08 wxtim

Workflow with implicit task foo

$ cylc config myworkflow -i '[runtime][foo]' --null-value=meow --json
Traceback (most recent call last):
  File "~/.conda/envs/cylc8/bin/cylc", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "~/github/cylc-flow/cylc/flow/scripts/cylc.py", line 703, in main
    execute_cmd(command, *cmd_args)
  File "~/github/cylc-flow/cylc/flow/scripts/cylc.py", line 334, in execute_cmd
    entry_point.load()(*args)
  File "~/github/cylc-flow/cylc/flow/terminal.py", line 298, in wrapper
    wrapped_function(*wrapped_args, **wrapped_kwargs)
  File "~/github/cylc-flow/cylc/flow/scripts/config.py", line 189, in main
    asyncio.run(_main(parser, options, *ids))
  File "~/.conda/envs/cylc8/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "~/.conda/envs/cylc8/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/.conda/envs/cylc8/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "~/github/cylc-flow/cylc/flow/scripts/config.py", line 245, in _main
    config.pcfg.idump(
  File "~/github/cylc-flow/cylc/flow/parsec/config.py", line 186, in idump
    self.jdump(mkeys, sparse, oneline, none_str, handle=handle)
  File "~/github/cylc-flow/cylc/flow/parsec/config.py", line 215, in jdump
    cfg.repl_val(cfg, None, none_str)
    ^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'repl_val'

MetRonnie avatar Aug 29 '24 13:08 MetRonnie

This PR could probably be merged now, however, IMO it's best to keep pairs of PRs open (i.e. unmerged) until the upstream PR has been merged as review comments there could force changes here. Will review together with the upstream PR when both are ready.

The upstream PR is currently a draft, so I'll mark this as draft for now to match.

oliver-sanders avatar Oct 07 '24 12:10 oliver-sanders

I will get back to this one day, but it's a feature, not a bug...

wxtim avatar Oct 09 '24 08:10 wxtim