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

`cylc config -i` traceback

Open MetRonnie opened this issue 1 year ago • 0 comments

Description

Trying cylc config --item <item> for an item that is not set in flow.cylc causes traceback.

Reproducible Example

[scheduling]
    [[graph]]
        R1 = foo
[runtime]
    [[foo]]
        [[[simulation]]]
            fail cycle points = all
$ cylc config myworkflow -i '[runtime][foo]execution retry delays'
Traceback (most recent call last):
  File "~/cylc/flow/parsec/config.py", line 145, in get
    cfg = cfg[key]
  File "~/cylc/flow/parsec/OrderedDict.py", line 38, in __getitem__
    return OrderedDict.__getitem__(self, key)
KeyError: 'execution retry delays'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "~/.conda/envs/cylc8.1/bin/cylc", line 8, in <module>
    sys.exit(main())
  File "~/cylc/flow/scripts/cylc.py", line 699, in main
    execute_cmd(command, *cmd_args)
  File "~/cylc/flow/scripts/cylc.py", line 330, in execute_cmd
    entry_point.load()(*args)
  File "~/cylc/flow/terminal.py", line 276, in wrapper
    wrapped_function(*wrapped_args, **wrapped_kwargs)
  File "~/cylc/flow/scripts/config.py", line 158, in main
    asyncio.run(_main(parser, options, *ids))
  File "~/.conda/envs/cylc8.1/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "~/.conda/envs/cylc8.1/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "~/cylc/flow/scripts/config.py", line 212, in _main
    config.pcfg.idump(
  File "~/cylc/flow/parsec/config.py", line 177, in idump
    self.mdump(mkeys, sparse, prefix, oneline, none_str, handle=handle)
  File "~/cylc/flow/parsec/config.py", line 195, in mdump
    self.dump(keys, sparse, prefix, none_str, handle=handle)
  File "~/cylc/flow/parsec/config.py", line 202, in dump
    cfg = self.get(keys, sparse)
  File "~/cylc/flow/parsec/config.py", line 149, in get
    key in self.spec.get(*parents)
  File "~/cylc/flow/context_node.py", line 149, in get
    node = node[name]
  File "~/cylc/flow/context_node.py", line 134, in __getitem__
    return self._children.__getitem__(name)
KeyError: 'foo'

Note the second lot of traceback is particularly confusing as it seems to say foo is not in the config even though it is.

Expected Behaviour

Either a short error message saying e.g. "item not set" or just an empty result like you get when using the --defaults option

MetRonnie avatar Mar 07 '24 11:03 MetRonnie