Skip to content

Commit c0c6487

Browse files
committed
Added an environment variable to silence TQDM output
1 parent 3de713a commit c0c6487

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

roboflow/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +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-
78+
TQDM_DESCRIPTIONS = os.getenv("TQDM_DESCRIPTIONS", "true")
7979

8080
def load_roboflow_api_key(workspace_url=None):
8181
if os.getenv("ROBOFLOW_API_KEY") is not None:

roboflow/core/version.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
TYPE_OBJECT_DETECTION,
2424
TYPE_SEMANTIC_SEGMENTATION,
2525
UNIVERSE_URL,
26+
TQDM_DESCRIPTIONS
2627
)
2728
from roboflow.core.dataset import Dataset
2829
from roboflow.models.classification import ClassificationModel
@@ -740,9 +741,13 @@ 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+
if TQDM_DESCRIPTIONS == "false":
745+
desc = None
746+
else:
747+
desc = f"Downloading Dataset Version Zip in {location} to {format}:"
743748
for chunk in tqdm(
744749
response.iter_content(chunk_size=1024),
745-
desc=f"Downloading Dataset Version Zip in {location} to {format}:",
750+
desc=desc,
746751
total=int(total_length / 1024) + 1,
747752
):
748753
if chunk:
@@ -766,10 +771,14 @@ def __extract_zip(self, location, format):
766771
Raises:
767772
RuntimeError: If there is an error unzipping the file
768773
""" # noqa: E501 // docs
774+
if TQDM_DESCRIPTIONS == "false":
775+
desc = None
776+
else:
777+
desc = f"Extracting Dataset Version Zip to {location} in {format}:"
769778
with zipfile.ZipFile(location + "/roboflow.zip", "r") as zip_ref:
770779
for member in tqdm(
771780
zip_ref.infolist(),
772-
desc=f"Extracting Dataset Version Zip to {location} in {format}:",
781+
desc=desc,
773782
):
774783
try:
775784
zip_ref.extract(member, location)

0 commit comments

Comments
 (0)