-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
ENH: Add progress_bar_type argument in read_gbq #29858
Conversation
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 |
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 |
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.
To avoid breaking people with pandas-gbq < 0.12.0
, only populate the progress_bar_type
kwargs if explicitly set.
kwargs["progress_bar_type"] = progress_bar_type | |
if progress_bar_type is not None: | |
kwargs["progress_bar_type"] = progress_bar_type |
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.
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", |
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 default to None
until there have been a few more pandas-gbq
releases with this feature.
progress_bar_type="tqdm", | |
progress_bar_type=None, |
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.
changed!! thanks!!
@@ -27,6 +27,7 @@ def read_gbq( | |||
use_bqstorage_api=None, | |||
private_key=None, | |||
verbose=None, | |||
progress_bar_type=None, |
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.
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: |
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.
Can this test be simplified to just call with the argument? Some of the monkey patching seems to be testing non-pandas behavior
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.
this is ok, its the same type of test we use for other kwargs
thanks @charlesdong1991 @tswast also happy to take a new min version of pandas-gbq if you need / want for 1.0 |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff