pyhf.contrib.utils.download#

pyhf.contrib.utils.download(archive_url, output_directory, force=False, compress=False)[source]#

Download the patchset archive from the remote URL and extract it in a directory at the path given.

Example

>>> from pyhf.contrib.utils import download
>>> download("https://doi.org/10.17182/hepdata.90607.v3/r3", "1Lbb-likelihoods")  
>>> import os
>>> sorted(os.listdir("1Lbb-likelihoods"))  
['BkgOnly.json', 'README.md', 'patchset.json']
>>> download("https://doi.org/10.17182/hepdata.90607.v3/r3", "1Lbb-likelihoods.tar.gz", compress=True)  
>>> import glob
>>> glob.glob("1Lbb-likelihoods.tar.gz")  
['1Lbb-likelihoods.tar.gz']
Parameters:
  • archive_url (str) – The URL of the PatchSet archive to download.

  • output_directory (str) – Name of the directory to unpack the archive into.

  • force (bool) – Force download from non-approved host. Default is False.

  • compress (bool) – Keep the archive in a compressed tar.gz form. Default is False.

Raises:

InvalidArchiveHost – if the provided archive host name is not known to be valid