diff --git a/dvc/remote/http.py b/dvc/remote/http.py index c12c6e940..5ff067e09 100644 --- a/dvc/remote/http.py +++ b/dvc/remote/http.py @@ -3,7 +3,6 @@ from __future__ import unicode_literals from dvc.scheme import Schemes from dvc.utils.compat import open -import requests import logging from dvc.progress import Tqdm @@ -79,6 +78,8 @@ class RemoteHTTP(RemoteBASE): return etag def _request(self, method, url, **kwargs): + import requests + kwargs.setdefault("allow_redirects", True) kwargs.setdefault("timeout", self.REQUEST_TIMEOUT) diff --git a/dvc/remote/ssh/__init__.py b/dvc/remote/ssh/__init__.py index 233f133ee..e4cc4cac5 100644 --- a/dvc/remote/ssh/__init__.py +++ b/dvc/remote/ssh/__init__.py @@ -24,9 +24,6 @@ from dvc.scheme import Schemes from dvc.remote.pool import get_connection from dvc.progress import Tqdm -from .connection import SSHConnection - - logger = logging.getLogger(__name__) @@ -139,6 +136,8 @@ class RemoteSSH(RemoteBASE): ) self.password = password + from .connection import SSHConnection + return get_connection( SSHConnection, host, diff --git a/dvc/updater.py b/dvc/updater.py index 388d8c94b..5f82f8ef1 100644 --- a/dvc/updater.py +++ b/dvc/updater.py @@ -4,7 +4,6 @@ import sys import os import time import logging -import requests import colorama from pkg_resources import parse_version @@ -82,6 +81,7 @@ class Updater(object): # pragma: no cover def _get_latest_version(self): import json + import requests try: r = requests.get(self.URL, timeout=self.TIMEOUT_GET) diff --git a/dvc/utils/http.py b/dvc/utils/http.py index b2ecf4bb3..b714a1767 100644 --- a/dvc/utils/http.py +++ b/dvc/utils/http.py @@ -1,8 +1,6 @@ from contextlib import contextmanager import io -import requests - from dvc.utils.compat import FileNotFoundError @@ -28,6 +26,7 @@ def open_url(url, mode="r", encoding=None): @contextmanager def iter_url(url, chunk_size=io.DEFAULT_BUFFER_SIZE): """Iterate over chunks requested from url.""" + import requests def request(headers=None): the_url = url() if callable(url) else url