Skip to content

Commit

Permalink
Remove test proxy suggestion (#2073)
Browse files Browse the repository at this point in the history
Summary:
... so that we can clone and install the packages in an environment where direct https/http access is not available.

Pull Request resolved: #2073

Reviewed By: aaronenyeshi

Differential Revision: D51756089

Pulled By: xuzhao9

fbshipit-source-id: 3ffc2fcf5c23aed05625bcd4796f6576435770e4
  • Loading branch information
xuzhao9 authored and facebook-github-bot committed Dec 1, 2023
1 parent 0f27ba1 commit 641b8bc
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 29 deletions.
5 changes: 1 addition & 4 deletions install.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@
import subprocess
import os
import sys
from utils import TORCH_DEPS, proxy_suggestion, get_pkg_versions, _test_https
from utils import TORCH_DEPS, get_pkg_versions
from userbenchmark import list_userbenchmarks
from pathlib import Path

REPO_ROOT = Path(__file__).parent

def pip_install_requirements(requirements_txt="requirements.txt"):
if not _test_https():
print(proxy_suggestion)
sys.exit(-1)
try:
subprocess.run([sys.executable, '-m', 'pip', 'install', '-q', '-r', requirements_txt],
check=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
Expand Down
15 changes: 1 addition & 14 deletions torchbenchmark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,14 @@ def __exit__(self, exc_type, exc_value, traceback):
pass

with add_path(str(REPO_PATH)):
from utils import TORCH_DEPS, get_pkg_versions, proxy_suggestion
from utils import TORCH_DEPS, get_pkg_versions

this_dir = pathlib.Path(__file__).parent.absolute()
model_dir = 'models'
internal_model_dir = "fb"
canary_model_dir = "canary_models"
install_file = 'install.py'


def _test_https(test_url: str = 'https://github.com', timeout: float = 0.5) -> bool:
try:
request.urlopen(test_url, timeout=timeout)
except OSError:
return False
return True


def _install_deps(model_path: str, verbose: bool = True) -> Tuple[bool, Any]:
from .util.env_check import get_pkg_versions
run_args = [
Expand Down Expand Up @@ -135,10 +126,6 @@ def _is_canary_model(model_name: str) -> bool:
return False

def setup(models: List[str] = [], verbose: bool = True, continue_on_fail: bool = False, test_mode: bool = False, allow_canary: bool = False) -> bool:
if not _test_https():
print(proxy_suggestion)
sys.exit(-1)

failures = {}
models = list(map(lambda p: p.lower(), models))
model_paths = filter(lambda p: True if not models else os.path.basename(p).lower() in models, _list_model_paths())
Expand Down
11 changes: 0 additions & 11 deletions utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@

TORCH_DEPS = ['torch', 'torchvision', 'torchaudio']

proxy_suggestion = "Unable to verify https connectivity, " \
"required for setup.\n" \
"Do you need to use a proxy?"

class add_path():
def __init__(self, path):
self.path = path
Expand All @@ -30,10 +26,3 @@ def get_pkg_versions(packages: List[str], reload: bool=False) -> Dict[str, str]:
module = importlib.reload(module)
versions[module.__name__] = module.__version__
return versions

def _test_https(test_url: str = 'https://github.com', timeout: float = 0.5) -> bool:
try:
request.urlopen(test_url, timeout=timeout)
except OSError:
return False
return True

0 comments on commit 641b8bc

Please sign in to comment.