Skip to content

Commit 671ed56

Browse files
feat: pyhf patchset inspect (#1412)
* pyhf patchset inspect
1 parent 15c49b3 commit 671ed56

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/pyhf/cli/patchset.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,22 @@ def verify(background_only, patchset):
123123
patchset.verify(ws)
124124

125125
click.echo("All good.")
126+
127+
128+
@cli.command()
129+
@click.argument('patchset', default='-')
130+
def inspect(patchset):
131+
"""
132+
Inspect the PatchSet (e.g. list individual patches).
133+
134+
Returns:
135+
None
136+
"""
137+
with click.open_file(patchset, 'r') as fstream:
138+
patchset_spec = json.load(fstream)
139+
140+
patchset = PatchSet(patchset_spec)
141+
click.secho(f'\n {len(patchset.patches)} patches found in Patchset')
142+
click.secho('---------------------------------\n')
143+
for p in patchset.patches:
144+
click.echo(p.name)

tests/test_scripts.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,12 @@ def test_missing_contrib_download(caplog):
626626
caplog.clear()
627627

628628

629+
def test_patchset_inspect(datadir, script_runner):
630+
command = f'pyhf patchset inspect {datadir.join("example_patchset.json").strpath}'
631+
ret = script_runner.run(*shlex.split(command))
632+
assert 'patch_channel1_signal_syst1' in ret.stdout
633+
634+
629635
@pytest.mark.parametrize('output_file', [False, True])
630636
@pytest.mark.parametrize('with_metadata', [False, True])
631637
def test_patchset_extract(datadir, tmpdir, script_runner, output_file, with_metadata):

0 commit comments

Comments
 (0)