We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
use non-blocking multithreaded progress I/O
continuing discussion from #2697

- use the old non-blocking approach
  + https://github.com/iterative/dvc/blob/0.35.6/dvc/progress.py#L51
- use blocking upon completion
  + https://github.com/iterative/dvc/blob/0.35.6/dvc/progress.py#L70
- depends on https://github.com/tqdm/tqdm/issues/838 -> https://github.com/tqdm/tqdm/pull/839

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `setup.py`
Content:
```
1 import os
2 import sys
3 
4 from setuptools import find_packages
5 from setuptools import setup
6 from setuptools.command.build_py import build_py as _build_py
7 
8 import fastentrypoints  # noqa: F401
9 
10 # Prevents pkg_resources import in entry point script,
11 # see https://github.com/ninjaaron/fast-entry_points.
12 # This saves about 200 ms on startup time for non-wheel installs.
13 
14 
15 # https://packaging.python.org/guides/single-sourcing-package-version/
16 pkg_dir = os.path.dirname(os.path.abspath(__file__))
17 version_path = os.path.join(pkg_dir, "dvc", "version.py")
18 if sys.version_info[0] == 2:
19     import imp
20 
21     dvc_version = imp.load_source("dvc.version", version_path)
22 else:
23     import importlib.util
24 
25     spec = importlib.util.spec_from_file_location("dvc.version", version_path)
26     dvc_version = importlib.util.module_from_spec(spec)
27     spec.loader.exec_module(dvc_version)
28 
29 version = dvc_version.__version__  # noqa: F821
30 
31 
32 # To achieve consistency between the build version and the one provided
33 # by your package during runtime, you need to **pin** the build version.
34 #
35 # This custom class will replace the version.py module with a **static**
36 # `__version__` that your package can read at runtime, assuring consistancy.
37 #
38 # References:
39 #   - https://docs.python.org/3.7/distutils/extending.html
40 #   - https://github.com/python/mypy
41 class build_py(_build_py):
42     def pin_version(self):
43         path = os.path.join(self.build_lib, "dvc")
44         self.mkpath(path)
45         with open(os.path.join(path, "version.py"), "w") as fobj:
46             fobj.write("# AUTOGENERATED at build time by setup.py\n")
47             fobj.write('__version__ = "{}"\n'.format(version))
48 
49     def run(self):
50         self.execute(self.pin_version, ())
51         _build_py.run(self)
52 
53 
54 install_requires = [
55     "ply>=3.9",  # See https://github.com/pyinstaller/pyinstaller/issues/1945
56     "configparser>=3.5.0",
57     "future>=0.16.0",
58     "colorama>=0.3.9",
59     "configobj>=5.0.6",
60     "gitpython>=2.1.8",
61     "gitdb2>=2.0.6",  # See https://github.com/iterative/dvc/issues/1880
62     "setuptools>=34.0.0",
63     "nanotime>=0.5.2",
64     "pyasn1>=0.4.1",
65     "schema>=0.6.7",
66     "jsonpath-ng>=1.4.3",
67     "requests>=2.22.0",
68     "grandalf==0.6",
69     "asciimatics>=1.10.0",
70     "distro>=1.3.0",
71     "appdirs>=1.4.3",
72     "treelib>=1.5.5",
73     "inflect>=2.1.0",
74     "humanize>=0.5.1",
75     "ruamel.yaml>=0.16.1",
76     "funcy>=1.12",
77     "pathspec>=0.6.0",
78     "shortuuid>=0.5.0",
79     "tqdm>=4.36.1,<5",
80     "packaging>=19.0",
81     "win-unicode-console>=0.5; sys_platform == 'win32'",
82     "pywin32>=225; sys_platform == 'win32'",
83 ]
84 
85 if sys.version_info[0] == 2:
86     install_requires.append("networkx>=2.1,<2.3")
87 else:
88     install_requires.append("networkx>=2.1,<2.4")
89 
90 # Extra dependencies for remote integrations
91 
92 gs = ["google-cloud-storage==1.19.0"]
93 s3 = ["boto3==1.9.115"]
94 azure = ["azure-storage-blob==2.1.0"]
95 oss = ["oss2==2.6.1"]
96 ssh = ["paramiko>=2.5.0"]
97 # gssapi should not be included in all_remotes, because it doesn't have wheels
98 # for linux and mac, so it will fail to compile if user doesn't have all the
99 # requirements, including kerberos itself. Once all the wheels are available,
100 # we can start shipping it by default.
101 ssh_gssapi = ["paramiko[gssapi]>=2.5.0"]
102 hdfs = ["pyarrow==0.14.0"]
103 all_remotes = gs + s3 + azure + ssh + oss
104 
105 if os.name != "nt" or sys.version_info[0] != 2:
106     # NOTE: there are no pyarrow wheels for python2 on windows
107     all_remotes += hdfs
108 
109 # Extra dependecies to run tests
110 tests_requirements = [
111     "PyInstaller==3.5",
112     "wheel>=0.31.1",
113     "pydot>=1.2.4",
114     # Test requirements:
115     "pytest>=4.6.0",
116     "pytest-timeout>=1.3.3",
117     "pytest-cov>=2.6.1",
118     "pytest-xdist>=1.26.1",
119     "pytest-mock>=1.10.4",
120     "flaky>=3.5.3",
121     "mock>=3.0.0",
122     "xmltodict>=0.11.0",
123     "awscli==1.16.266",
124     "google-compute-engine==2.8.13",
125     "Pygments",  # required by collective.checkdocs,
126     "collective.checkdocs",
127     "flake8",
128     "psutil",
129     "flake8-docstrings",
130     "pydocstyle<4.0",
131     "jaraco.windows==3.9.2",
132     "mock-ssh-server>=0.6.0",
133     "moto==1.3.14.dev464",
134     "rangehttpserver==1.2.0",
135 ]
136 
137 if (sys.version_info) >= (3, 6):
138     tests_requirements.append("black==19.3b0")
139 
140 setup(
141     name="dvc",
142     version=version,
143     description="Git for data scientists - manage your code and data together",
144     long_description=open("README.rst", "r").read(),
145     author="Dmitry Petrov",
146     author_email="dmitry@dataversioncontrol.com",
147     download_url="https://github.com/iterative/dvc",
148     license="Apache License 2.0",
149     install_requires=install_requires,
150     extras_require={
151         "all": all_remotes,
152         "gs": gs,
153         "s3": s3,
154         "azure": azure,
155         "oss": oss,
156         "ssh": ssh,
157         "ssh_gssapi": ssh_gssapi,
158         "hdfs": hdfs,
159         # NOTE: https://github.com/inveniosoftware/troubleshooting/issues/1
160         ":python_version=='2.7'": [
161             "futures",
162             "pathlib2",
163             "zc.lockfile>=1.2.1",
164         ],
165         ":python_version>='3.0'": ["flufl.lock>=3.2"],
166         "tests": tests_requirements,
167     },
168     keywords="data science, data version control, machine learning",
169     python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
170     classifiers=[
171         "Development Status :: 4 - Beta",
172         "Programming Language :: Python :: 2",
173         "Programming Language :: Python :: 2.7",
174         "Programming Language :: Python :: 3",
175         "Programming Language :: Python :: 3.5",
176         "Programming Language :: Python :: 3.6",
177         "Programming Language :: Python :: 3.7",
178     ],
179     packages=find_packages(exclude=["tests"]),
180     include_package_data=True,
181     url="http://dvc.org",
182     entry_points={"console_scripts": ["dvc = dvc.main:main"]},
183     cmdclass={"build_py": build_py},
184     zip_safe=False,
185 )
186
```

Path: `dvc/progress.py`
Content:
```
1 """Manages progress bars for dvc repo."""
2 from __future__ import print_function
3 
4 import logging
5 import sys
6 
7 from funcy import merge
8 from tqdm import tqdm
9 
10 from dvc.utils import env2bool
11 
12 logger = logging.getLogger(__name__)
13 
14 
15 class Tqdm(tqdm):
16     """
17     maximum-compatibility tqdm-based progressbars
18     """
19 
20     BAR_FMT_DEFAULT = (
21         "{percentage:3.0f}%|{bar:10}|"
22         "{desc:{ncols_desc}.{ncols_desc}}{n}/{total}"
23         " [{elapsed}<{remaining}, {rate_fmt:>11}{postfix}]"
24     )
25     BAR_FMT_NOTOTAL = (
26         "{desc:{ncols_desc}.{ncols_desc}}{n}"
27         " [{elapsed}<??:??, {rate_fmt:>11}{postfix}]"
28     )
29 
30     def __init__(
31         self,
32         iterable=None,
33         disable=None,
34         level=logging.ERROR,
35         desc=None,
36         leave=False,
37         bar_format=None,
38         bytes=False,  # pylint: disable=W0622
39         file=None,
40         **kwargs
41     ):
42         """
43         bytes   : shortcut for
44             `unit='B', unit_scale=True, unit_divisor=1024, miniters=1`
45         desc  : persists after `close()`
46         level  : effective logging level for determining `disable`;
47             used only if `disable` is unspecified
48         disable  : If (default: None), will be determined by logging level.
49             May be overridden to `True` due to non-TTY status.
50             Skip override by specifying env var `DVC_IGNORE_ISATTY`.
51         kwargs  : anything accepted by `tqdm.tqdm()`
52         """
53         kwargs = kwargs.copy()
54         kwargs.setdefault("unit_scale", True)
55         if bytes:
56             bytes_defaults = dict(
57                 unit="B", unit_scale=True, unit_divisor=1024, miniters=1
58             )
59             kwargs = merge(bytes_defaults, kwargs)
60         if file is None:
61             file = sys.stderr
62         self.desc_persist = desc
63         # auto-disable based on `logger.level`
64         if disable is None:
65             disable = logger.getEffectiveLevel() > level
66         # auto-disable based on TTY
67         if (
68             not disable
69             and not env2bool("DVC_IGNORE_ISATTY")
70             and hasattr(file, "isatty")
71         ):
72             disable = not file.isatty()
73         super(Tqdm, self).__init__(
74             iterable=iterable,
75             disable=disable,
76             leave=leave,
77             desc=desc,
78             bar_format="!",
79             **kwargs
80         )
81         if bar_format is None:
82             if self.__len__():
83                 self.bar_format = self.BAR_FMT_DEFAULT
84             else:
85                 self.bar_format = self.BAR_FMT_NOTOTAL
86         else:
87             self.bar_format = bar_format
88         self.refresh()
89 
90     def update_desc(self, desc, n=1):
91         """
92         Calls `set_description_str(desc)` and `update(n)`
93         """
94         self.set_description_str(desc, refresh=False)
95         self.update(n)
96 
97     def update_to(self, current, total=None):
98         if total:
99             self.total = total  # pylint: disable=W0613,W0201
100         self.update(current - self.n)
101 
102     def close(self):
103         if self.desc_persist is not None:
104             self.set_description_str(self.desc_persist, refresh=False)
105         super(Tqdm, self).close()
106 
107     @property
108     def format_dict(self):
109         """inject `ncols_desc` to fill the display width (`ncols`)"""
110         d = super(Tqdm, self).format_dict
111         ncols = d["ncols"] or 80
112         ncols_desc = ncols - len(self.format_meter(ncols_desc=1, **d)) + 1
113         ncols_desc = max(ncols_desc, 0)
114         if ncols_desc:
115             d["ncols_desc"] = ncols_desc
116         else:
117             # work-around for zero-width description
118             d["ncols_desc"] = 1
119             d["prefix"] = ""
120         return d
121
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/dvc/progress.py b/dvc/progress.py
--- a/dvc/progress.py
+++ b/dvc/progress.py
@@ -3,6 +3,7 @@
 
 import logging
 import sys
+from threading import RLock
 
 from funcy import merge
 from tqdm import tqdm
@@ -10,6 +11,7 @@
 from dvc.utils import env2bool
 
 logger = logging.getLogger(__name__)
+tqdm.set_lock(RLock())
 
 
 class Tqdm(tqdm):
@@ -76,6 +78,7 @@
             leave=leave,
             desc=desc,
             bar_format="!",
+            lock_args=(False,),
             **kwargs
         )
         if bar_format is None:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -76,7 +76,7 @@
     "funcy>=1.12",
     "pathspec>=0.6.0",
     "shortuuid>=0.5.0",
-    "tqdm>=4.36.1,<5",
+    "tqdm>=4.38.0,<5",
     "packaging>=19.0",
     "win-unicode-console>=0.5; sys_platform == 'win32'",
     "pywin32>=225; sys_platform == 'win32'",

{"golden_diff": "diff --git a/dvc/progress.py b/dvc/progress.py\n--- a/dvc/progress.py\n+++ b/dvc/progress.py\n@@ -3,6 +3,7 @@\n \n import logging\n import sys\n+from threading import RLock\n \n from funcy import merge\n from tqdm import tqdm\n@@ -10,6 +11,7 @@\n from dvc.utils import env2bool\n \n logger = logging.getLogger(__name__)\n+tqdm.set_lock(RLock())\n \n \n class Tqdm(tqdm):\n@@ -76,6 +78,7 @@\n             leave=leave,\n             desc=desc,\n             bar_format=\"!\",\n+            lock_args=(False,),\n             **kwargs\n         )\n         if bar_format is None:\ndiff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -76,7 +76,7 @@\n     \"funcy>=1.12\",\n     \"pathspec>=0.6.0\",\n     \"shortuuid>=0.5.0\",\n-    \"tqdm>=4.36.1,<5\",\n+    \"tqdm>=4.38.0,<5\",\n     \"packaging>=19.0\",\n     \"win-unicode-console>=0.5; sys_platform == 'win32'\",\n     \"pywin32>=225; sys_platform == 'win32'\",\n", "issue": "use non-blocking multithreaded progress I/O\ncontinuing discussion from #2697\r\n\r\n- use the old non-blocking approach\r\n  + https://github.com/iterative/dvc/blob/0.35.6/dvc/progress.py#L51\r\n- use blocking upon completion\r\n  + https://github.com/iterative/dvc/blob/0.35.6/dvc/progress.py#L70\r\n- depends on https://github.com/tqdm/tqdm/issues/838 -> https://github.com/tqdm/tqdm/pull/839\n", "before_files": [{"content": "import os\nimport sys\n\nfrom setuptools import find_packages\nfrom setuptools import setup\nfrom setuptools.command.build_py import build_py as _build_py\n\nimport fastentrypoints  # noqa: F401\n\n# Prevents pkg_resources import in entry point script,\n# see https://github.com/ninjaaron/fast-entry_points.\n# This saves about 200 ms on startup time for non-wheel installs.\n\n\n# https://packaging.python.org/guides/single-sourcing-package-version/\npkg_dir = os.path.dirname(os.path.abspath(__file__))\nversion_path = os.path.join(pkg_dir, \"dvc\", \"version.py\")\nif sys.version_info[0] == 2:\n    import imp\n\n    dvc_version = imp.load_source(\"dvc.version\", version_path)\nelse:\n    import importlib.util\n\n    spec = importlib.util.spec_from_file_location(\"dvc.version\", version_path)\n    dvc_version = importlib.util.module_from_spec(spec)\n    spec.loader.exec_module(dvc_version)\n\nversion = dvc_version.__version__  # noqa: F821\n\n\n# To achieve consistency between the build version and the one provided\n# by your package during runtime, you need to **pin** the build version.\n#\n# This custom class will replace the version.py module with a **static**\n# `__version__` that your package can read at runtime, assuring consistancy.\n#\n# References:\n#   - https://docs.python.org/3.7/distutils/extending.html\n#   - https://github.com/python/mypy\nclass build_py(_build_py):\n    def pin_version(self):\n        path = os.path.join(self.build_lib, \"dvc\")\n        self.mkpath(path)\n        with open(os.path.join(path, \"version.py\"), \"w\") as fobj:\n            fobj.write(\"# AUTOGENERATED at build time by setup.py\\n\")\n            fobj.write('__version__ = \"{}\"\\n'.format(version))\n\n    def run(self):\n        self.execute(self.pin_version, ())\n        _build_py.run(self)\n\n\ninstall_requires = [\n    \"ply>=3.9\",  # See https://github.com/pyinstaller/pyinstaller/issues/1945\n    \"configparser>=3.5.0\",\n    \"future>=0.16.0\",\n    \"colorama>=0.3.9\",\n    \"configobj>=5.0.6\",\n    \"gitpython>=2.1.8\",\n    \"gitdb2>=2.0.6\",  # See https://github.com/iterative/dvc/issues/1880\n    \"setuptools>=34.0.0\",\n    \"nanotime>=0.5.2\",\n    \"pyasn1>=0.4.1\",\n    \"schema>=0.6.7\",\n    \"jsonpath-ng>=1.4.3\",\n    \"requests>=2.22.0\",\n    \"grandalf==0.6\",\n    \"asciimatics>=1.10.0\",\n    \"distro>=1.3.0\",\n    \"appdirs>=1.4.3\",\n    \"treelib>=1.5.5\",\n    \"inflect>=2.1.0\",\n    \"humanize>=0.5.1\",\n    \"ruamel.yaml>=0.16.1\",\n    \"funcy>=1.12\",\n    \"pathspec>=0.6.0\",\n    \"shortuuid>=0.5.0\",\n    \"tqdm>=4.36.1,<5\",\n    \"packaging>=19.0\",\n    \"win-unicode-console>=0.5; sys_platform == 'win32'\",\n    \"pywin32>=225; sys_platform == 'win32'\",\n]\n\nif sys.version_info[0] == 2:\n    install_requires.append(\"networkx>=2.1,<2.3\")\nelse:\n    install_requires.append(\"networkx>=2.1,<2.4\")\n\n# Extra dependencies for remote integrations\n\ngs = [\"google-cloud-storage==1.19.0\"]\ns3 = [\"boto3==1.9.115\"]\nazure = [\"azure-storage-blob==2.1.0\"]\noss = [\"oss2==2.6.1\"]\nssh = [\"paramiko>=2.5.0\"]\n# gssapi should not be included in all_remotes, because it doesn't have wheels\n# for linux and mac, so it will fail to compile if user doesn't have all the\n# requirements, including kerberos itself. Once all the wheels are available,\n# we can start shipping it by default.\nssh_gssapi = [\"paramiko[gssapi]>=2.5.0\"]\nhdfs = [\"pyarrow==0.14.0\"]\nall_remotes = gs + s3 + azure + ssh + oss\n\nif os.name != \"nt\" or sys.version_info[0] != 2:\n    # NOTE: there are no pyarrow wheels for python2 on windows\n    all_remotes += hdfs\n\n# Extra dependecies to run tests\ntests_requirements = [\n    \"PyInstaller==3.5\",\n    \"wheel>=0.31.1\",\n    \"pydot>=1.2.4\",\n    # Test requirements:\n    \"pytest>=4.6.0\",\n    \"pytest-timeout>=1.3.3\",\n    \"pytest-cov>=2.6.1\",\n    \"pytest-xdist>=1.26.1\",\n    \"pytest-mock>=1.10.4\",\n    \"flaky>=3.5.3\",\n    \"mock>=3.0.0\",\n    \"xmltodict>=0.11.0\",\n    \"awscli==1.16.266\",\n    \"google-compute-engine==2.8.13\",\n    \"Pygments\",  # required by collective.checkdocs,\n    \"collective.checkdocs\",\n    \"flake8\",\n    \"psutil\",\n    \"flake8-docstrings\",\n    \"pydocstyle<4.0\",\n    \"jaraco.windows==3.9.2\",\n    \"mock-ssh-server>=0.6.0\",\n    \"moto==1.3.14.dev464\",\n    \"rangehttpserver==1.2.0\",\n]\n\nif (sys.version_info) >= (3, 6):\n    tests_requirements.append(\"black==19.3b0\")\n\nsetup(\n    name=\"dvc\",\n    version=version,\n    description=\"Git for data scientists - manage your code and data together\",\n    long_description=open(\"README.rst\", \"r\").read(),\n    author=\"Dmitry Petrov\",\n    author_email=\"dmitry@dataversioncontrol.com\",\n    download_url=\"https://github.com/iterative/dvc\",\n    license=\"Apache License 2.0\",\n    install_requires=install_requires,\n    extras_require={\n        \"all\": all_remotes,\n        \"gs\": gs,\n        \"s3\": s3,\n        \"azure\": azure,\n        \"oss\": oss,\n        \"ssh\": ssh,\n        \"ssh_gssapi\": ssh_gssapi,\n        \"hdfs\": hdfs,\n        # NOTE: https://github.com/inveniosoftware/troubleshooting/issues/1\n        \":python_version=='2.7'\": [\n            \"futures\",\n            \"pathlib2\",\n            \"zc.lockfile>=1.2.1\",\n        ],\n        \":python_version>='3.0'\": [\"flufl.lock>=3.2\"],\n        \"tests\": tests_requirements,\n    },\n    keywords=\"data science, data version control, machine learning\",\n    python_requires=\">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*\",\n    classifiers=[\n        \"Development Status :: 4 - Beta\",\n        \"Programming Language :: Python :: 2\",\n        \"Programming Language :: Python :: 2.7\",\n        \"Programming Language :: Python :: 3\",\n        \"Programming Language :: Python :: 3.5\",\n        \"Programming Language :: Python :: 3.6\",\n        \"Programming Language :: Python :: 3.7\",\n    ],\n    packages=find_packages(exclude=[\"tests\"]),\n    include_package_data=True,\n    url=\"http://dvc.org\",\n    entry_points={\"console_scripts\": [\"dvc = dvc.main:main\"]},\n    cmdclass={\"build_py\": build_py},\n    zip_safe=False,\n)\n", "path": "setup.py"}, {"content": "\"\"\"Manages progress bars for dvc repo.\"\"\"\nfrom __future__ import print_function\n\nimport logging\nimport sys\n\nfrom funcy import merge\nfrom tqdm import tqdm\n\nfrom dvc.utils import env2bool\n\nlogger = logging.getLogger(__name__)\n\n\nclass Tqdm(tqdm):\n    \"\"\"\n    maximum-compatibility tqdm-based progressbars\n    \"\"\"\n\n    BAR_FMT_DEFAULT = (\n        \"{percentage:3.0f}%|{bar:10}|\"\n        \"{desc:{ncols_desc}.{ncols_desc}}{n}/{total}\"\n        \" [{elapsed}<{remaining}, {rate_fmt:>11}{postfix}]\"\n    )\n    BAR_FMT_NOTOTAL = (\n        \"{desc:{ncols_desc}.{ncols_desc}}{n}\"\n        \" [{elapsed}<??:??, {rate_fmt:>11}{postfix}]\"\n    )\n\n    def __init__(\n        self,\n        iterable=None,\n        disable=None,\n        level=logging.ERROR,\n        desc=None,\n        leave=False,\n        bar_format=None,\n        bytes=False,  # pylint: disable=W0622\n        file=None,\n        **kwargs\n    ):\n        \"\"\"\n        bytes   : shortcut for\n            `unit='B', unit_scale=True, unit_divisor=1024, miniters=1`\n        desc  : persists after `close()`\n        level  : effective logging level for determining `disable`;\n            used only if `disable` is unspecified\n        disable  : If (default: None), will be determined by logging level.\n            May be overridden to `True` due to non-TTY status.\n            Skip override by specifying env var `DVC_IGNORE_ISATTY`.\n        kwargs  : anything accepted by `tqdm.tqdm()`\n        \"\"\"\n        kwargs = kwargs.copy()\n        kwargs.setdefault(\"unit_scale\", True)\n        if bytes:\n            bytes_defaults = dict(\n                unit=\"B\", unit_scale=True, unit_divisor=1024, miniters=1\n            )\n            kwargs = merge(bytes_defaults, kwargs)\n        if file is None:\n            file = sys.stderr\n        self.desc_persist = desc\n        # auto-disable based on `logger.level`\n        if disable is None:\n            disable = logger.getEffectiveLevel() > level\n        # auto-disable based on TTY\n        if (\n            not disable\n            and not env2bool(\"DVC_IGNORE_ISATTY\")\n            and hasattr(file, \"isatty\")\n        ):\n            disable = not file.isatty()\n        super(Tqdm, self).__init__(\n            iterable=iterable,\n            disable=disable,\n            leave=leave,\n            desc=desc,\n            bar_format=\"!\",\n            **kwargs\n        )\n        if bar_format is None:\n            if self.__len__():\n                self.bar_format = self.BAR_FMT_DEFAULT\n            else:\n                self.bar_format = self.BAR_FMT_NOTOTAL\n        else:\n            self.bar_format = bar_format\n        self.refresh()\n\n    def update_desc(self, desc, n=1):\n        \"\"\"\n        Calls `set_description_str(desc)` and `update(n)`\n        \"\"\"\n        self.set_description_str(desc, refresh=False)\n        self.update(n)\n\n    def update_to(self, current, total=None):\n        if total:\n            self.total = total  # pylint: disable=W0613,W0201\n        self.update(current - self.n)\n\n    def close(self):\n        if self.desc_persist is not None:\n            self.set_description_str(self.desc_persist, refresh=False)\n        super(Tqdm, self).close()\n\n    @property\n    def format_dict(self):\n        \"\"\"inject `ncols_desc` to fill the display width (`ncols`)\"\"\"\n        d = super(Tqdm, self).format_dict\n        ncols = d[\"ncols\"] or 80\n        ncols_desc = ncols - len(self.format_meter(ncols_desc=1, **d)) + 1\n        ncols_desc = max(ncols_desc, 0)\n        if ncols_desc:\n            d[\"ncols_desc\"] = ncols_desc\n        else:\n            # work-around for zero-width description\n            d[\"ncols_desc\"] = 1\n            d[\"prefix\"] = \"\"\n        return d\n", "path": "dvc/progress.py"}], "after_files": [{"content": "import os\nimport sys\n\nfrom setuptools import find_packages\nfrom setuptools import setup\nfrom setuptools.command.build_py import build_py as _build_py\n\nimport fastentrypoints  # noqa: F401\n\n# Prevents pkg_resources import in entry point script,\n# see https://github.com/ninjaaron/fast-entry_points.\n# This saves about 200 ms on startup time for non-wheel installs.\n\n\n# https://packaging.python.org/guides/single-sourcing-package-version/\npkg_dir = os.path.dirname(os.path.abspath(__file__))\nversion_path = os.path.join(pkg_dir, \"dvc\", \"version.py\")\nif sys.version_info[0] == 2:\n    import imp\n\n    dvc_version = imp.load_source(\"dvc.version\", version_path)\nelse:\n    import importlib.util\n\n    spec = importlib.util.spec_from_file_location(\"dvc.version\", version_path)\n    dvc_version = importlib.util.module_from_spec(spec)\n    spec.loader.exec_module(dvc_version)\n\nversion = dvc_version.__version__  # noqa: F821\n\n\n# To achieve consistency between the build version and the one provided\n# by your package during runtime, you need to **pin** the build version.\n#\n# This custom class will replace the version.py module with a **static**\n# `__version__` that your package can read at runtime, assuring consistancy.\n#\n# References:\n#   - https://docs.python.org/3.7/distutils/extending.html\n#   - https://github.com/python/mypy\nclass build_py(_build_py):\n    def pin_version(self):\n        path = os.path.join(self.build_lib, \"dvc\")\n        self.mkpath(path)\n        with open(os.path.join(path, \"version.py\"), \"w\") as fobj:\n            fobj.write(\"# AUTOGENERATED at build time by setup.py\\n\")\n            fobj.write('__version__ = \"{}\"\\n'.format(version))\n\n    def run(self):\n        self.execute(self.pin_version, ())\n        _build_py.run(self)\n\n\ninstall_requires = [\n    \"ply>=3.9\",  # See https://github.com/pyinstaller/pyinstaller/issues/1945\n    \"configparser>=3.5.0\",\n    \"future>=0.16.0\",\n    \"colorama>=0.3.9\",\n    \"configobj>=5.0.6\",\n    \"gitpython>=2.1.8\",\n    \"gitdb2>=2.0.6\",  # See https://github.com/iterative/dvc/issues/1880\n    \"setuptools>=34.0.0\",\n    \"nanotime>=0.5.2\",\n    \"pyasn1>=0.4.1\",\n    \"schema>=0.6.7\",\n    \"jsonpath-ng>=1.4.3\",\n    \"requests>=2.22.0\",\n    \"grandalf==0.6\",\n    \"asciimatics>=1.10.0\",\n    \"distro>=1.3.0\",\n    \"appdirs>=1.4.3\",\n    \"treelib>=1.5.5\",\n    \"inflect>=2.1.0\",\n    \"humanize>=0.5.1\",\n    \"ruamel.yaml>=0.16.1\",\n    \"funcy>=1.12\",\n    \"pathspec>=0.6.0\",\n    \"shortuuid>=0.5.0\",\n    \"tqdm>=4.38.0,<5\",\n    \"packaging>=19.0\",\n    \"win-unicode-console>=0.5; sys_platform == 'win32'\",\n    \"pywin32>=225; sys_platform == 'win32'\",\n]\n\nif sys.version_info[0] == 2:\n    install_requires.append(\"networkx>=2.1,<2.3\")\nelse:\n    install_requires.append(\"networkx>=2.1,<2.4\")\n\n# Extra dependencies for remote integrations\n\ngs = [\"google-cloud-storage==1.19.0\"]\ns3 = [\"boto3==1.9.115\"]\nazure = [\"azure-storage-blob==2.1.0\"]\noss = [\"oss2==2.6.1\"]\nssh = [\"paramiko>=2.5.0\"]\n# gssapi should not be included in all_remotes, because it doesn't have wheels\n# for linux and mac, so it will fail to compile if user doesn't have all the\n# requirements, including kerberos itself. Once all the wheels are available,\n# we can start shipping it by default.\nssh_gssapi = [\"paramiko[gssapi]>=2.5.0\"]\nhdfs = [\"pyarrow==0.14.0\"]\nall_remotes = gs + s3 + azure + ssh + oss\n\nif os.name != \"nt\" or sys.version_info[0] != 2:\n    # NOTE: there are no pyarrow wheels for python2 on windows\n    all_remotes += hdfs\n\n# Extra dependecies to run tests\ntests_requirements = [\n    \"PyInstaller==3.5\",\n    \"wheel>=0.31.1\",\n    \"pydot>=1.2.4\",\n    # Test requirements:\n    \"pytest>=4.6.0\",\n    \"pytest-timeout>=1.3.3\",\n    \"pytest-cov>=2.6.1\",\n    \"pytest-xdist>=1.26.1\",\n    \"pytest-mock>=1.10.4\",\n    \"flaky>=3.5.3\",\n    \"mock>=3.0.0\",\n    \"xmltodict>=0.11.0\",\n    \"awscli==1.16.266\",\n    \"google-compute-engine==2.8.13\",\n    \"Pygments\",  # required by collective.checkdocs,\n    \"collective.checkdocs\",\n    \"flake8\",\n    \"psutil\",\n    \"flake8-docstrings\",\n    \"pydocstyle<4.0\",\n    \"jaraco.windows==3.9.2\",\n    \"mock-ssh-server>=0.6.0\",\n    \"moto==1.3.14.dev464\",\n    \"rangehttpserver==1.2.0\",\n]\n\nif (sys.version_info) >= (3, 6):\n    tests_requirements.append(\"black==19.3b0\")\n\nsetup(\n    name=\"dvc\",\n    version=version,\n    description=\"Git for data scientists - manage your code and data together\",\n    long_description=open(\"README.rst\", \"r\").read(),\n    author=\"Dmitry Petrov\",\n    author_email=\"dmitry@dataversioncontrol.com\",\n    download_url=\"https://github.com/iterative/dvc\",\n    license=\"Apache License 2.0\",\n    install_requires=install_requires,\n    extras_require={\n        \"all\": all_remotes,\n        \"gs\": gs,\n        \"s3\": s3,\n        \"azure\": azure,\n        \"oss\": oss,\n        \"ssh\": ssh,\n        \"ssh_gssapi\": ssh_gssapi,\n        \"hdfs\": hdfs,\n        # NOTE: https://github.com/inveniosoftware/troubleshooting/issues/1\n        \":python_version=='2.7'\": [\n            \"futures\",\n            \"pathlib2\",\n            \"zc.lockfile>=1.2.1\",\n        ],\n        \":python_version>='3.0'\": [\"flufl.lock>=3.2\"],\n        \"tests\": tests_requirements,\n    },\n    keywords=\"data science, data version control, machine learning\",\n    python_requires=\">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*\",\n    classifiers=[\n        \"Development Status :: 4 - Beta\",\n        \"Programming Language :: Python :: 2\",\n        \"Programming Language :: Python :: 2.7\",\n        \"Programming Language :: Python :: 3\",\n        \"Programming Language :: Python :: 3.5\",\n        \"Programming Language :: Python :: 3.6\",\n        \"Programming Language :: Python :: 3.7\",\n    ],\n    packages=find_packages(exclude=[\"tests\"]),\n    include_package_data=True,\n    url=\"http://dvc.org\",\n    entry_points={\"console_scripts\": [\"dvc = dvc.main:main\"]},\n    cmdclass={\"build_py\": build_py},\n    zip_safe=False,\n)\n", "path": "setup.py"}, {"content": "\"\"\"Manages progress bars for dvc repo.\"\"\"\nfrom __future__ import print_function\n\nimport logging\nimport sys\nfrom threading import RLock\n\nfrom funcy import merge\nfrom tqdm import tqdm\n\nfrom dvc.utils import env2bool\n\nlogger = logging.getLogger(__name__)\ntqdm.set_lock(RLock())\n\n\nclass Tqdm(tqdm):\n    \"\"\"\n    maximum-compatibility tqdm-based progressbars\n    \"\"\"\n\n    BAR_FMT_DEFAULT = (\n        \"{percentage:3.0f}%|{bar:10}|\"\n        \"{desc:{ncols_desc}.{ncols_desc}}{n}/{total}\"\n        \" [{elapsed}<{remaining}, {rate_fmt:>11}{postfix}]\"\n    )\n    BAR_FMT_NOTOTAL = (\n        \"{desc:{ncols_desc}.{ncols_desc}}{n}\"\n        \" [{elapsed}<??:??, {rate_fmt:>11}{postfix}]\"\n    )\n\n    def __init__(\n        self,\n        iterable=None,\n        disable=None,\n        level=logging.ERROR,\n        desc=None,\n        leave=False,\n        bar_format=None,\n        bytes=False,  # pylint: disable=W0622\n        file=None,\n        **kwargs\n    ):\n        \"\"\"\n        bytes   : shortcut for\n            `unit='B', unit_scale=True, unit_divisor=1024, miniters=1`\n        desc  : persists after `close()`\n        level  : effective logging level for determining `disable`;\n            used only if `disable` is unspecified\n        disable  : If (default: None), will be determined by logging level.\n            May be overridden to `True` due to non-TTY status.\n            Skip override by specifying env var `DVC_IGNORE_ISATTY`.\n        kwargs  : anything accepted by `tqdm.tqdm()`\n        \"\"\"\n        kwargs = kwargs.copy()\n        kwargs.setdefault(\"unit_scale\", True)\n        if bytes:\n            bytes_defaults = dict(\n                unit=\"B\", unit_scale=True, unit_divisor=1024, miniters=1\n            )\n            kwargs = merge(bytes_defaults, kwargs)\n        if file is None:\n            file = sys.stderr\n        self.desc_persist = desc\n        # auto-disable based on `logger.level`\n        if disable is None:\n            disable = logger.getEffectiveLevel() > level\n        # auto-disable based on TTY\n        if (\n            not disable\n            and not env2bool(\"DVC_IGNORE_ISATTY\")\n            and hasattr(file, \"isatty\")\n        ):\n            disable = not file.isatty()\n        super(Tqdm, self).__init__(\n            iterable=iterable,\n            disable=disable,\n            leave=leave,\n            desc=desc,\n            bar_format=\"!\",\n            lock_args=(False,),\n            **kwargs\n        )\n        if bar_format is None:\n            if self.__len__():\n                self.bar_format = self.BAR_FMT_DEFAULT\n            else:\n                self.bar_format = self.BAR_FMT_NOTOTAL\n        else:\n            self.bar_format = bar_format\n        self.refresh()\n\n    def update_desc(self, desc, n=1):\n        \"\"\"\n        Calls `set_description_str(desc)` and `update(n)`\n        \"\"\"\n        self.set_description_str(desc, refresh=False)\n        self.update(n)\n\n    def update_to(self, current, total=None):\n        if total:\n            self.total = total  # pylint: disable=W0613,W0201\n        self.update(current - self.n)\n\n    def close(self):\n        if self.desc_persist is not None:\n            self.set_description_str(self.desc_persist, refresh=False)\n        super(Tqdm, self).close()\n\n    @property\n    def format_dict(self):\n        \"\"\"inject `ncols_desc` to fill the display width (`ncols`)\"\"\"\n        d = super(Tqdm, self).format_dict\n        ncols = d[\"ncols\"] or 80\n        ncols_desc = ncols - len(self.format_meter(ncols_desc=1, **d)) + 1\n        ncols_desc = max(ncols_desc, 0)\n        if ncols_desc:\n            d[\"ncols_desc\"] = ncols_desc\n        else:\n            # work-around for zero-width description\n            d[\"ncols_desc\"] = 1\n            d[\"prefix\"] = \"\"\n        return d\n", "path": "dvc/progress.py"}]}