Skip to content

Commit

Permalink
Fix a bug preventing cylc vip --workflow-name=foo from working. (#5349
Browse files Browse the repository at this point in the history
)

* Fix a bug preventing `cylc vip --workflow-name=foo` from working.
`--workflow-name foo` was fine.
Caused by removal of unwanted sys.argv for Cylc VIP not removing
items not exactly matching items in the Command line options arguments.

* response to review
  • Loading branch information
wxtim authored Feb 17, 2023
1 parent 1584fd9 commit c8696bb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ ones in. -->

### Fixes

[#5349](https://github.com/cylc/cylc-flow/pull/5349) - Bugfix: `cylc vip --workflow-name`
only worked when used with a space, not an `=`.

[#5367](https://github.com/cylc/cylc-flow/pull/5367) - Enable using
Rose options (`-O`, `-S` & `-D`) with `cylc view`.

Expand Down
4 changes: 4 additions & 0 deletions cylc/flow/option_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,7 @@ def cleanup_sysargv(
for x in compound_script_opts
}
# Filter out non-cylc-play options.
args = [i.split('=')[0] for i in sys.argv]
for unwanted_opt in (set(options.__dict__)) - set(script_opts_by_dest):
for arg in compound_opts_by_dest[unwanted_opt].args:
if arg in sys.argv:
Expand All @@ -831,6 +832,9 @@ def cleanup_sysargv(
not in ['store_true', 'store_false']
):
sys.argv.pop(index)
elif arg in args:
index = args.index(arg)
sys.argv.pop(index)

# replace compound script name:
sys.argv[1] = script_name
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/test_option_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,19 @@ def test_combine_options(inputs, expect):
'play --foo something myworkflow'.split(),
id='no path given'
),
param(
'vip --bar=something'.split(),
{
'script_name': 'play',
'workflow_id': 'myworkflow',
'compound_script_opts': [
OptionSettings(['--bar', '-b'])],
'script_opts': [],
'source': './myworkflow',
},
'play myworkflow'.split(),
id='removes --key=value'
),
]
)
def test_cleanup_sysargv(monkeypatch, argv_before, kwargs, expect):
Expand Down

0 comments on commit c8696bb

Please sign in to comment.