Skip to content

Commit

Permalink
Move import inside of download function
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewfeickert committed Sep 13, 2020
1 parent 97c98e4 commit 3b78d18
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/pyhf/cli/contrib.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
from io import BytesIO
from pathlib import Path

try:
import requests
except ModuleNotFoundError:
pass

from .. import exceptions

logging.basicConfig()
Expand Down Expand Up @@ -59,6 +54,17 @@ def download(archive_url, output_directory, verbose, force):
Raises:
:class:`~pyhf.exceptions.InvalidArchiveHost`: if the provided archive host name is not known to be valid
"""
try:
import requests
except ModuleNotFoundError as excep:
exception_info = (
str(excep)
+ "\nInstallation of the contrib extra is required for: pyhf contrib download"
+ "\nPlease install with: python -m pip install pyhf[contrib]\n"
)
print(exception_info)
raise

if not force:
valid_hosts = ["www.hepdata.net", "doi.org"]
netloc = urlparse(archive_url).netloc
Expand Down

0 comments on commit 3b78d18

Please sign in to comment.