Skip to content

Commit

Permalink
feat: pyhf patchset inspect (#1412)
Browse files Browse the repository at this point in the history
* pyhf patchset inspect
  • Loading branch information
lukasheinrich committed Apr 22, 2021
1 parent 15c49b3 commit 671ed56
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/pyhf/cli/patchset.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,22 @@ def verify(background_only, patchset):
patchset.verify(ws)

click.echo("All good.")


@cli.command()
@click.argument('patchset', default='-')
def inspect(patchset):
"""
Inspect the PatchSet (e.g. list individual patches).
Returns:
None
"""
with click.open_file(patchset, 'r') as fstream:
patchset_spec = json.load(fstream)

patchset = PatchSet(patchset_spec)
click.secho(f'\n {len(patchset.patches)} patches found in Patchset')
click.secho('---------------------------------\n')
for p in patchset.patches:
click.echo(p.name)
6 changes: 6 additions & 0 deletions tests/test_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,12 @@ def test_missing_contrib_download(caplog):
caplog.clear()


def test_patchset_inspect(datadir, script_runner):
command = f'pyhf patchset inspect {datadir.join("example_patchset.json").strpath}'
ret = script_runner.run(*shlex.split(command))
assert 'patch_channel1_signal_syst1' in ret.stdout


@pytest.mark.parametrize('output_file', [False, True])
@pytest.mark.parametrize('with_metadata', [False, True])
def test_patchset_extract(datadir, tmpdir, script_runner, output_file, with_metadata):
Expand Down

0 comments on commit 671ed56

Please sign in to comment.