Skip to content

Commit

Permalink
remove _wget (#61356)
Browse files Browse the repository at this point in the history
* remove _wget

* remove _wget

* remove wget test
  • Loading branch information
lyuwenyu committed Feb 4, 2024
1 parent 22cf91f commit 4c0888d
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 52 deletions.
1 change: 0 additions & 1 deletion python/paddle/hapi/hub.py
Expand Up @@ -117,7 +117,6 @@ def _get_cache_or_reload(repo, force_reload, verbose=True, source='github'):
hub_dir,
check_exist=not force_reload,
decompress=False,
method=('wget' if source == 'gitee' else 'get'),
)
shutil.move(fpath, cached_file)

Expand Down
38 changes: 1 addition & 37 deletions python/paddle/utils/download.py
Expand Up @@ -15,14 +15,11 @@
import hashlib
import os
import os.path as osp
import shlex
import shutil
import subprocess
import sys
import tarfile
import time
import zipfile
from urllib.parse import urlparse

import httpx

Expand Down Expand Up @@ -198,40 +195,7 @@ def _get_download(url, fullname):
return False


def _wget_download(url: str, fullname: str):
try:
assert urlparse(url).scheme in (
'http',
'https',
), 'Only support https and http url'
# using wget to download url
tmp_fullname = shlex.quote(fullname + "_tmp")
url = shlex.quote(url)
# –user-agent
command = f'wget -O {tmp_fullname} -t {DOWNLOAD_RETRY_LIMIT} {url}'
subprc = subprocess.Popen(
command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
_ = subprc.communicate()

if subprc.returncode != 0:
raise RuntimeError(
f'{command} failed. Please make sure `wget` is installed or {url} exists'
)

shutil.move(tmp_fullname, fullname)

except Exception as e: # requests.exceptions.ConnectionError
logger.info(f"Downloading {url} failed with exception {str(e)}")
return False

return fullname


_download_methods = {
'get': _get_download,
'wget': _wget_download,
}
_download_methods = {'get': _get_download}


def _download(url, path, md5sum=None, method='get'):
Expand Down
15 changes: 1 addition & 14 deletions test/legacy_test/test_download.py
Expand Up @@ -120,14 +120,6 @@ def test_retry_exception(
'./test',
)

def test_wget_download_error(
self,
):
with self.assertRaises(RuntimeError):
from paddle.utils.download import _download

_download('www.baidu', './test', method='wget')

def test_download_methods(
self,
):
Expand All @@ -136,14 +128,9 @@ def test_download_methods(
"https://paddle-hapi.bj.bcebos.com/unittest/files.zip",
]

import sys

from paddle.utils.download import _download

if sys.platform == 'linux':
methods = ['wget', 'get']
else:
methods = ['get']
methods = ['get']

for url in urls:
for method in methods:
Expand Down

0 comments on commit 4c0888d

Please sign in to comment.