Skip to content

ENH: Add progress_bar_type argument in read_gbq #29858

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

Merged
merged 14 commits into from
Dec 8, 2019

Conversation

charlesdong1991
Copy link
Member

@charlesdong1991 charlesdong1991 commented Nov 26, 2019

@charlesdong1991 charlesdong1991 changed the title Add progress_bar_type argument in read_gbq ENH: Add progress_bar_type argument in read_gbq Nov 26, 2019
@WillAyd
Copy link
Member

WillAyd commented Nov 27, 2019

Should we just add kwargs here to pass along instead? I think there are a few other keywords that aren't specifically stated; probably easier to just pass through

@jreback
Copy link
Contributor

jreback commented Nov 27, 2019

Should we just add kwargs here to pass along instead? I think there are a few other keywords that aren't specifically stated; probably easier to just pass through

no

explicit is better than implicit

@jreback
Copy link
Contributor

jreback commented Nov 29, 2019

cc @tswast

does this require a min version?

pandas/io/gbq.py Outdated
@@ -152,6 +176,8 @@ def read_gbq(
# START: new kwargs. Don't populate unless explicitly set.
if use_bqstorage_api is not None:
kwargs["use_bqstorage_api"] = use_bqstorage_api

kwargs["progress_bar_type"] = progress_bar_type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid breaking people with pandas-gbq < 0.12.0, only populate the progress_bar_type kwargs if explicitly set.

Suggested change
kwargs["progress_bar_type"] = progress_bar_type
if progress_bar_type is not None:
kwargs["progress_bar_type"] = progress_bar_type

Copy link
Member Author

@charlesdong1991 charlesdong1991 Dec 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @tswast for your reviews!!

pandas/io/gbq.py Outdated
@@ -27,6 +27,7 @@ def read_gbq(
use_bqstorage_api=None,
private_key=None,
verbose=None,
progress_bar_type="tqdm",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's default to None until there have been a few more pandas-gbq releases with this feature.

Suggested change
progress_bar_type="tqdm",
progress_bar_type=None,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed!! thanks!!

@@ -27,6 +27,7 @@ def read_gbq(
use_bqstorage_api=None,
private_key=None,
verbose=None,
progress_bar_type=None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
progress_bar_type=None,
progress_bar_type: Optional[str] = None,

might as well put what you have in the doc as an annotation

monkeypatch.setattr("pandas_gbq.read_gbq", mock_read_gbq)
pd.read_gbq("SELECT 1", progress_bar_type=progress_bar)

if progress_bar:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this test be simplified to just call with the argument? Some of the monkey patching seems to be testing non-pandas behavior

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is ok, its the same type of test we use for other kwargs

@jreback jreback added this to the 1.0 milestone Dec 8, 2019
@jreback jreback merged commit 102dc61 into pandas-dev:master Dec 8, 2019
@jreback
Copy link
Contributor

jreback commented Dec 8, 2019

thanks @charlesdong1991

@tswast also happy to take a new min version of pandas-gbq if you need / want for 1.0

proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH: Add progress_bar_type argument for read_gbq
4 participants