From 88f9d55586c6b0ee2b86e6f47f09f6c8c860c1f0 Mon Sep 17 00:00:00 2001 From: Jon Duckworth Date: Mon, 8 Feb 2021 12:47:23 -0500 Subject: [PATCH] Auto-detect progressbar type Use tqdm.auto to get a progressbar appropriate to the environment (e.g tqdm.notebook.tqdm for Jupyter Notebook). Falls back to standard tqdm.tqdm if an ImportError is encountered (as described in tqdm/tqdm#1082) --- radiant_mlhub/client.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/radiant_mlhub/client.py b/radiant_mlhub/client.py index 1ef40e2..80223d5 100644 --- a/radiant_mlhub/client.py +++ b/radiant_mlhub/client.py @@ -8,7 +8,12 @@ import urllib.parse from requests.exceptions import HTTPError -from tqdm import tqdm + +try: + from tqdm.auto import tqdm +except ImportError: # pragma: no cover + # Handles this issue: https://github.com/tqdm/tqdm/issues/1082 + from tqdm import tqdm # type: ignore [no-redef] from .session import get_session from .exceptions import EntityDoesNotExist, MLHubException