Skip to content

Commit 76b4483

Browse files
authored
Merge pull request #258 from roboflow/fix/make-tqdm-logging-controllable-via-envvar
Added an environment variable to silence TQDM output
2 parents aa309a5 + 2a48213 commit 76b4483

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

roboflow/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def get_conditional_configuration_variable(key, default):
7575
DEFAULT_JOB_NAME = "Annotated via API"
7676

7777
RF_WORKSPACES = get_conditional_configuration_variable("workspaces", default={})
78+
TQDM_DISABLE = os.getenv("TQDM_DISABLE", None)
7879

7980

8081
def load_roboflow_api_key(workspace_url=None):

roboflow/core/version.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
API_URL,
1818
APP_URL,
1919
DEMO_KEYS,
20+
TQDM_DISABLE,
2021
TYPE_CLASSICATION,
2122
TYPE_INSTANCE_SEGMENTATION,
2223
TYPE_KEYPOINT_DETECTION,
@@ -740,9 +741,10 @@ def bar_progress(current, total, width=80):
740741
# write the zip file to the desired location
741742
with open(location + "/roboflow.zip", "wb") as f:
742743
total_length = int(response.headers.get("content-length"))
744+
desc = None if TQDM_DISABLE else f"Downloading Dataset Version Zip in {location} to {format}:"
743745
for chunk in tqdm(
744746
response.iter_content(chunk_size=1024),
745-
desc=f"Downloading Dataset Version Zip in {location} to {format}:",
747+
desc=desc,
746748
total=int(total_length / 1024) + 1,
747749
):
748750
if chunk:
@@ -766,10 +768,11 @@ def __extract_zip(self, location, format):
766768
Raises:
767769
RuntimeError: If there is an error unzipping the file
768770
""" # noqa: E501 // docs
771+
desc = None if TQDM_DISABLE else f"Extracting Dataset Version Zip to {location} in {format}:"
769772
with zipfile.ZipFile(location + "/roboflow.zip", "r") as zip_ref:
770773
for member in tqdm(
771774
zip_ref.infolist(),
772-
desc=f"Extracting Dataset Version Zip to {location} in {format}:",
775+
desc=desc,
773776
):
774777
try:
775778
zip_ref.extract(member, location)

0 commit comments

Comments
 (0)