Skip to content
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

tqdm deprecation warning #1146

Closed
GergelyKalmar opened this issue Feb 20, 2022 · 8 comments
Closed

tqdm deprecation warning #1146

GergelyKalmar opened this issue Feb 20, 2022 · 8 comments
Assignees
Labels
api: bigquery Issues related to the googleapis/python-bigquery API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@GergelyKalmar
Copy link

Environment details

  • OS type and version: Ubuntu 20.04 LTS
  • Python version: 3.8.10
  • pip version: 22.0.3
  • google-cloud-bigquery version: 2.34.0

Steps to reproduce

from google.cloud import bigquery

query = bigquery.Client().query('SELECT 1')
data = query.to_dataframe(progress_bar_type='tqdm_notebook')

The snippet above causes a deprecation warning that breaks strict pytest runs (using 'filterwarnings': ['error']):

.../site-packages/google/cloud/bigquery/_tqdm_helpers.py:51: in get_progress_bar
    return tqdm.tqdm_notebook(desc=description, total=total, unit=unit)
...
        from .notebook import tqdm as _tqdm_notebook
>       warn("This function will be removed in tqdm==5.0.0\n"
             "Please use `tqdm.notebook.tqdm` instead of `tqdm.tqdm_notebook`",
             TqdmDeprecationWarning, stacklevel=2)
E       tqdm.std.TqdmDeprecationWarning: This function will be removed in tqdm==5.0.0
E       Please use `tqdm.notebook.tqdm` instead of `tqdm.tqdm_notebook`

.../site-packages/tqdm/__init__.py:25: TqdmDeprecationWarning
@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery API. label Feb 20, 2022
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Feb 21, 2022
@tswast tswast removed the triage me I really want to be triaged. label Feb 24, 2022
@tswast
Copy link
Contributor

tswast commented Feb 24, 2022

Thanks for bringing this to our attention! Seeing as we set the max tqdm version to <5.0.0, I'll mark this as "process" for now, but I do think we need to do this before tqdm 5.0.0 comes out since "extras" aren't always enforced by PyPI and in principle we should support the latest version of our dependencies.

@tswast tswast added priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Feb 24, 2022
@yoshi-automation yoshi-automation added triage me I really want to be triaged. and removed triage me I really want to be triaged. labels Feb 24, 2022
@GergelyKalmar
Copy link
Author

Thank you! It seems that this has been deprecated for years now though, the commit adding the deprecation warning is from 2019: tqdm/tqdm@49471d3#diff-c2228f13f6b0bdaf4c1012a108f937d0e0eceece0d87e60b0b3c3172f9038bedR5. It seems to be a relatively simple change, would it be possible to increase the priority a bit?

@meredithslota meredithslota added priority: p2 Moderately-important priority. Fix may not be included in next release. and removed priority: p3 Desirable enhancement or fix. May not be included in next release. labels Sep 6, 2022
@chalmerlowe chalmerlowe self-assigned this Sep 13, 2022
@GergelyKalmar
Copy link
Author

🎉 Thank you!

@GergelyKalmar
Copy link
Author

@chalmerlowe This feature seems to be completely broken now. With google-cloud-bigquery[pandas,tqdm]==3.3.5 and the reproducer above I'm getting:

Traceback (most recent call last):
  File "test.py", line 4, in <module>
    data = query.to_dataframe(progress_bar_type='tqdm_notebook')
  File ".../bigquery-test/lib/python3.8/site-packages/google/cloud/bigquery/job/query.py", line 1683, in to_dataframe
    query_result = wait_for_query(self, progress_bar_type, max_results=max_results)
  File ".../bigquery-test/lib/python3.8/site-packages/google/cloud/bigquery/_tqdm_helpers.py", line 85, in wait_for_query
    progress_bar = get_progress_bar(
  File ".../bigquery-test/lib/python3.8/site-packages/google/cloud/bigquery/_tqdm_helpers.py", line 52, in get_progress_bar
    return tqdm.notebook.tqdm(desc=description, total=total, unit=unit)
AttributeError: module 'tqdm' has no attribute 'notebook'

Note that import tqdm; tqdm.notebook.tqdm errors out, however from tqdm.notebook import tqdm works fine.

This is a pretty serious regression, would you mind issuing a patch whenever you can? Thank you!

@chalmerlowe
Copy link
Contributor

@aribray can you take a look at this?

@chalmerlowe chalmerlowe reopened this Oct 21, 2022
@aribray
Copy link
Contributor

aribray commented Nov 4, 2022

Hi @GergelyKalmar, can you pull down the latest version and send me the results of the to_dataframe() call?

@GergelyKalmar
Copy link
Author

GergelyKalmar commented Nov 7, 2022

hi @aribray, looks like the issue is now solved! Thank you very much for that.

I only have one nitpick regarding the new progress bar setup: it's a bit weird to have two progress bars, and one of them is pushed to the right when the job ID appears:

image

I suppose it would be better to have just a single progress bar on its own line (job ID should be its own line too).

If you want to make the output more complete, I've been also showing the data processed at the very end in my own bigquery magic like this:

from humanize.filesize import naturalsize
...
if args.info:
    processed = naturalsize(query.total_bytes_processed)
    display(ipywidgets.HTML(value='Data processed: ' + (
        f'<b>{processed}</b>' if not query.cache_hit
        else 'none <b>(returned from cache)</b>'
    )))

With this addition the output looks like this:

image

It might look better if you add a colon after the "Job ID" too, but that's just my subjective preference.

@brijk7 brijk7 added priority: p3 Desirable enhancement or fix. May not be included in next release. and removed priority: p2 Moderately-important priority. Fix may not be included in next release. labels Mar 2, 2023
@meredithslota
Copy link
Contributor

Looks like the original bug has been fixed but there's a remaining feature request for improving the progress bar setup; I'm going to copy the last comment to a new issue so we can examine the request but also close out this bug. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

7 participants