-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BigQuery: Add tqdm progress bar for downloads #7552
Changes from 1 commit
d309212
c6efe1b
b23d581
3c1f008
c0e3a39
0693789
9506caa
a7d9d59
25f4e13
4aafefe
62e3d58
bed0694
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,11 @@ | |
except ImportError: # pragma: NO COVER | ||
pandas = None | ||
|
||
try: | ||
import tqdm | ||
except ImportError: # pragma: NO COVER | ||
tqdm = None | ||
|
||
from google.api_core.page_iterator import HTTPIterator | ||
|
||
import google.cloud._helpers | ||
|
@@ -1336,11 +1341,15 @@ def _to_dataframe_tabledata_list(self, dtypes): | |
frames = [] | ||
|
||
# report progress if tqdm installed | ||
try: | ||
from tqdm import tqdm | ||
pbar = tqdm(desc="Downloading", total=self.total_rows, unit="rows") | ||
except (ImportError, KeyError, TypeError): | ||
pbar = None | ||
pbar = None | ||
if tqdm is not None: | ||
try: | ||
pbar = tqdm.tqdm( | ||
desc="Downloading", total=self.total_rows, unit="rows" | ||
) | ||
except (KeyError, TypeError): | ||
# tqdm error | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like this comment to explain a little more why these errors might happen. And more importantly why we are letting them pass (because a broken progress bar shouldn't stop us from downloading results). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My thinking here was to protect from something like an interface change in |
||
pass | ||
|
||
for page in iter(self.pages): | ||
frames.append(self._to_dataframe_dtypes(page, column_names, dtypes)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a
progress_bar_type
(string) parameter toto_dataframe
and check that it also is not None.It should default to
None
for now, until we update the magics module to support turning it off in theContext
and also update the magics to use thetqdm_notebook
option instead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think defaulting to
'tqdm'
is fine. When @alixhami tests notebooks, he can setgoogle.cloud.bigquery.table.tqdm = None
like you do in your tests.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should default to
None
because otherwise it will throw errors for users who don't havetqdm
installed who aren't using the parameter.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in the latest commits.