mirror of
https://github.com/pytorch/pytorch.git
synced 2025-11-02 14:34:54 +08:00
Revert "Dynamo, FX, Inductor Progress Bars (#88384)"
This reverts commit db0ce4acf3c84d54e468154ead6d773539a2b597. Reverted https://github.com/pytorch/pytorch/pull/88384 on behalf of https://github.com/malfet due to Broke test_public_bindings across the board
This commit is contained in:
70
torch/hub.py
70
torch/hub.py
@ -16,42 +16,44 @@ from urllib.request import urlopen, Request
|
||||
from urllib.parse import urlparse # noqa: F401
|
||||
from torch.serialization import MAP_LOCATION
|
||||
|
||||
class Faketqdm(object): # type: ignore[no-redef]
|
||||
|
||||
def __init__(self, total=None, disable=False,
|
||||
unit=None, *args, **kwargs):
|
||||
self.total = total
|
||||
self.disable = disable
|
||||
self.n = 0
|
||||
# Ignore all extra *args and **kwargs lest you want to reinvent tqdm
|
||||
|
||||
def update(self, n):
|
||||
if self.disable:
|
||||
return
|
||||
|
||||
self.n += n
|
||||
if self.total is None:
|
||||
sys.stderr.write("\r{0:.1f} bytes".format(self.n))
|
||||
else:
|
||||
sys.stderr.write("\r{0:.1f}%".format(100 * self.n / float(self.total)))
|
||||
sys.stderr.flush()
|
||||
|
||||
def close(self):
|
||||
self.disable = True
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
if self.disable:
|
||||
return
|
||||
|
||||
sys.stderr.write('\n')
|
||||
|
||||
try:
|
||||
from tqdm import tqdm # If tqdm is installed use it, otherwise use the fake wrapper
|
||||
from tqdm.auto import tqdm # automatically select proper tqdm submodule if available
|
||||
except ImportError:
|
||||
tqdm = Faketqdm
|
||||
try:
|
||||
from tqdm import tqdm
|
||||
except ImportError:
|
||||
# fake tqdm if it's not installed
|
||||
class tqdm(object): # type: ignore[no-redef]
|
||||
|
||||
def __init__(self, total=None, disable=False,
|
||||
unit=None, unit_scale=None, unit_divisor=None):
|
||||
self.total = total
|
||||
self.disable = disable
|
||||
self.n = 0
|
||||
# ignore unit, unit_scale, unit_divisor; they're just for real tqdm
|
||||
|
||||
def update(self, n):
|
||||
if self.disable:
|
||||
return
|
||||
|
||||
self.n += n
|
||||
if self.total is None:
|
||||
sys.stderr.write("\r{0:.1f} bytes".format(self.n))
|
||||
else:
|
||||
sys.stderr.write("\r{0:.1f}%".format(100 * self.n / float(self.total)))
|
||||
sys.stderr.flush()
|
||||
|
||||
def close(self):
|
||||
self.disable = True
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
if self.disable:
|
||||
return
|
||||
|
||||
sys.stderr.write('\n')
|
||||
|
||||
__all__ = [
|
||||
'download_url_to_file',
|
||||
|
||||
Reference in New Issue
Block a user