prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  tqdm deprecation warning
  #### 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
  ```
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `google/cloud/bigquery/_tqdm_helpers.py`
  Content:
  ```
  1 # Copyright 2019 Google LLC
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #     http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 
  15 """Shared helper functions for tqdm progress bar."""
  16 
  17 import concurrent.futures
  18 import time
  19 import typing
  20 from typing import Optional
  21 import warnings
  22 
  23 try:
  24     import tqdm  # type: ignore
  25 except ImportError:  # pragma: NO COVER
  26     tqdm = None
  27 
  28 if typing.TYPE_CHECKING:  # pragma: NO COVER
  29     from google.cloud.bigquery import QueryJob
  30     from google.cloud.bigquery.table import RowIterator
  31 
  32 _NO_TQDM_ERROR = (
  33     "A progress bar was requested, but there was an error loading the tqdm "
  34     "library. Please install tqdm to use the progress bar functionality."
  35 )
  36 
  37 _PROGRESS_BAR_UPDATE_INTERVAL = 0.5
  38 
  39 
  40 def get_progress_bar(progress_bar_type, description, total, unit):
  41     """Construct a tqdm progress bar object, if tqdm is installed."""
  42     if tqdm is None:
  43         if progress_bar_type is not None:
  44             warnings.warn(_NO_TQDM_ERROR, UserWarning, stacklevel=3)
  45         return None
  46 
  47     try:
  48         if progress_bar_type == "tqdm":
  49             return tqdm.tqdm(desc=description, total=total, unit=unit)
  50         elif progress_bar_type == "tqdm_notebook":
  51             return tqdm.tqdm_notebook(desc=description, total=total, unit=unit)
  52         elif progress_bar_type == "tqdm_gui":
  53             return tqdm.tqdm_gui(desc=description, total=total, unit=unit)
  54     except (KeyError, TypeError):
  55         # Protect ourselves from any tqdm errors. In case of
  56         # unexpected tqdm behavior, just fall back to showing
  57         # no progress bar.
  58         warnings.warn(_NO_TQDM_ERROR, UserWarning, stacklevel=3)
  59     return None
  60 
  61 
  62 def wait_for_query(
  63     query_job: "QueryJob",
  64     progress_bar_type: Optional[str] = None,
  65     max_results: Optional[int] = None,
  66 ) -> "RowIterator":
  67     """Return query result and display a progress bar while the query running, if tqdm is installed.
  68 
  69     Args:
  70         query_job:
  71             The job representing the execution of the query on the server.
  72         progress_bar_type:
  73             The type of progress bar to use to show query progress.
  74         max_results:
  75             The maximum number of rows the row iterator should return.
  76 
  77     Returns:
  78         A row iterator over the query results.
  79     """
  80     default_total = 1
  81     current_stage = None
  82     start_time = time.time()
  83 
  84     progress_bar = get_progress_bar(
  85         progress_bar_type, "Query is running", default_total, "query"
  86     )
  87     if progress_bar is None:
  88         return query_job.result(max_results=max_results)
  89 
  90     i = 0
  91     while True:
  92         if query_job.query_plan:
  93             default_total = len(query_job.query_plan)
  94             current_stage = query_job.query_plan[i]
  95             progress_bar.total = len(query_job.query_plan)
  96             progress_bar.set_description(
  97                 "Query executing stage {} and status {} : {:0.2f}s".format(
  98                     current_stage.name,
  99                     current_stage.status,
  100                     time.time() - start_time,
  101                 ),
  102             )
  103         try:
  104             query_result = query_job.result(
  105                 timeout=_PROGRESS_BAR_UPDATE_INTERVAL, max_results=max_results
  106             )
  107             progress_bar.update(default_total)
  108             progress_bar.set_description(
  109                 "Query complete after {:0.2f}s".format(time.time() - start_time),
  110             )
  111             break
  112         except concurrent.futures.TimeoutError:
  113             query_job.reload()  # Refreshes the state via a GET request.
  114             if current_stage:
  115                 if current_stage.status == "COMPLETE":
  116                     if i < default_total - 1:
  117                         progress_bar.update(i + 1)
  118                         i += 1
  119             continue
  120 
  121     progress_bar.close()
  122     return query_result
  123
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/google/cloud/bigquery/_tqdm_helpers.py b/google/cloud/bigquery/_tqdm_helpers.py
  --- a/google/cloud/bigquery/_tqdm_helpers.py
  +++ b/google/cloud/bigquery/_tqdm_helpers.py
  @@ -22,6 +22,7 @@
   
   try:
       import tqdm  # type: ignore
  +
   except ImportError:  # pragma: NO COVER
       tqdm = None
   
  @@ -48,7 +49,7 @@
           if progress_bar_type == "tqdm":
               return tqdm.tqdm(desc=description, total=total, unit=unit)
           elif progress_bar_type == "tqdm_notebook":
  -            return tqdm.tqdm_notebook(desc=description, total=total, unit=unit)
  +            return tqdm.notebook.tqdm(desc=description, total=total, unit=unit)
           elif progress_bar_type == "tqdm_gui":
               return tqdm.tqdm_gui(desc=description, total=total, unit=unit)
       except (KeyError, TypeError):
  
verification_info: {"golden_diff": "diff --git a/google/cloud/bigquery/_tqdm_helpers.py b/google/cloud/bigquery/_tqdm_helpers.py\n--- a/google/cloud/bigquery/_tqdm_helpers.py\n+++ b/google/cloud/bigquery/_tqdm_helpers.py\n@@ -22,6 +22,7 @@\n \n try:\n     import tqdm  # type: ignore\n+\n except ImportError:  # pragma: NO COVER\n     tqdm = None\n \n@@ -48,7 +49,7 @@\n         if progress_bar_type == \"tqdm\":\n             return tqdm.tqdm(desc=description, total=total, unit=unit)\n         elif progress_bar_type == \"tqdm_notebook\":\n-            return tqdm.tqdm_notebook(desc=description, total=total, unit=unit)\n+            return tqdm.notebook.tqdm(desc=description, total=total, unit=unit)\n         elif progress_bar_type == \"tqdm_gui\":\n             return tqdm.tqdm_gui(desc=description, total=total, unit=unit)\n     except (KeyError, TypeError):\n", "issue": "tqdm deprecation warning\n#### Environment details\r\n\r\n  - OS type and version: Ubuntu 20.04 LTS\r\n  - Python version: 3.8.10\r\n  - pip version: 22.0.3\r\n  - `google-cloud-bigquery` version: 2.34.0\r\n\r\n#### Steps to reproduce\r\n\r\n```\r\nfrom google.cloud import bigquery\r\n\r\nquery = bigquery.Client().query('SELECT 1')\r\ndata = query.to_dataframe(progress_bar_type='tqdm_notebook')\r\n```\r\n\r\nThe snippet above causes a deprecation warning that breaks strict pytest runs (using `'filterwarnings': ['error']`):\r\n```\r\n.../site-packages/google/cloud/bigquery/_tqdm_helpers.py:51: in get_progress_bar\r\n    return tqdm.tqdm_notebook(desc=description, total=total, unit=unit)\r\n...\r\n        from .notebook import tqdm as _tqdm_notebook\r\n>       warn(\"This function will be removed in tqdm==5.0.0\\n\"\r\n             \"Please use `tqdm.notebook.tqdm` instead of `tqdm.tqdm_notebook`\",\r\n             TqdmDeprecationWarning, stacklevel=2)\r\nE       tqdm.std.TqdmDeprecationWarning: This function will be removed in tqdm==5.0.0\r\nE       Please use `tqdm.notebook.tqdm` instead of `tqdm.tqdm_notebook`\r\n\r\n.../site-packages/tqdm/__init__.py:25: TqdmDeprecationWarning\r\n```\n", "before_files": [{"content": "# Copyright 2019 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Shared helper functions for tqdm progress bar.\"\"\"\n\nimport concurrent.futures\nimport time\nimport typing\nfrom typing import Optional\nimport warnings\n\ntry:\n    import tqdm  # type: ignore\nexcept ImportError:  # pragma: NO COVER\n    tqdm = None\n\nif typing.TYPE_CHECKING:  # pragma: NO COVER\n    from google.cloud.bigquery import QueryJob\n    from google.cloud.bigquery.table import RowIterator\n\n_NO_TQDM_ERROR = (\n    \"A progress bar was requested, but there was an error loading the tqdm \"\n    \"library. Please install tqdm to use the progress bar functionality.\"\n)\n\n_PROGRESS_BAR_UPDATE_INTERVAL = 0.5\n\n\ndef get_progress_bar(progress_bar_type, description, total, unit):\n    \"\"\"Construct a tqdm progress bar object, if tqdm is installed.\"\"\"\n    if tqdm is None:\n        if progress_bar_type is not None:\n            warnings.warn(_NO_TQDM_ERROR, UserWarning, stacklevel=3)\n        return None\n\n    try:\n        if progress_bar_type == \"tqdm\":\n            return tqdm.tqdm(desc=description, total=total, unit=unit)\n        elif progress_bar_type == \"tqdm_notebook\":\n            return tqdm.tqdm_notebook(desc=description, total=total, unit=unit)\n        elif progress_bar_type == \"tqdm_gui\":\n            return tqdm.tqdm_gui(desc=description, total=total, unit=unit)\n    except (KeyError, TypeError):\n        # Protect ourselves from any tqdm errors. In case of\n        # unexpected tqdm behavior, just fall back to showing\n        # no progress bar.\n        warnings.warn(_NO_TQDM_ERROR, UserWarning, stacklevel=3)\n    return None\n\n\ndef wait_for_query(\n    query_job: \"QueryJob\",\n    progress_bar_type: Optional[str] = None,\n    max_results: Optional[int] = None,\n) -> \"RowIterator\":\n    \"\"\"Return query result and display a progress bar while the query running, if tqdm is installed.\n\n    Args:\n        query_job:\n            The job representing the execution of the query on the server.\n        progress_bar_type:\n            The type of progress bar to use to show query progress.\n        max_results:\n            The maximum number of rows the row iterator should return.\n\n    Returns:\n        A row iterator over the query results.\n    \"\"\"\n    default_total = 1\n    current_stage = None\n    start_time = time.time()\n\n    progress_bar = get_progress_bar(\n        progress_bar_type, \"Query is running\", default_total, \"query\"\n    )\n    if progress_bar is None:\n        return query_job.result(max_results=max_results)\n\n    i = 0\n    while True:\n        if query_job.query_plan:\n            default_total = len(query_job.query_plan)\n            current_stage = query_job.query_plan[i]\n            progress_bar.total = len(query_job.query_plan)\n            progress_bar.set_description(\n                \"Query executing stage {} and status {} : {:0.2f}s\".format(\n                    current_stage.name,\n                    current_stage.status,\n                    time.time() - start_time,\n                ),\n            )\n        try:\n            query_result = query_job.result(\n                timeout=_PROGRESS_BAR_UPDATE_INTERVAL, max_results=max_results\n            )\n            progress_bar.update(default_total)\n            progress_bar.set_description(\n                \"Query complete after {:0.2f}s\".format(time.time() - start_time),\n            )\n            break\n        except concurrent.futures.TimeoutError:\n            query_job.reload()  # Refreshes the state via a GET request.\n            if current_stage:\n                if current_stage.status == \"COMPLETE\":\n                    if i < default_total - 1:\n                        progress_bar.update(i + 1)\n                        i += 1\n            continue\n\n    progress_bar.close()\n    return query_result\n", "path": "google/cloud/bigquery/_tqdm_helpers.py"}], "after_files": [{"content": "# Copyright 2019 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Shared helper functions for tqdm progress bar.\"\"\"\n\nimport concurrent.futures\nimport time\nimport typing\nfrom typing import Optional\nimport warnings\n\ntry:\n    import tqdm  # type: ignore\n\nexcept ImportError:  # pragma: NO COVER\n    tqdm = None\n\nif typing.TYPE_CHECKING:  # pragma: NO COVER\n    from google.cloud.bigquery import QueryJob\n    from google.cloud.bigquery.table import RowIterator\n\n_NO_TQDM_ERROR = (\n    \"A progress bar was requested, but there was an error loading the tqdm \"\n    \"library. Please install tqdm to use the progress bar functionality.\"\n)\n\n_PROGRESS_BAR_UPDATE_INTERVAL = 0.5\n\n\ndef get_progress_bar(progress_bar_type, description, total, unit):\n    \"\"\"Construct a tqdm progress bar object, if tqdm is installed.\"\"\"\n    if tqdm is None:\n        if progress_bar_type is not None:\n            warnings.warn(_NO_TQDM_ERROR, UserWarning, stacklevel=3)\n        return None\n\n    try:\n        if progress_bar_type == \"tqdm\":\n            return tqdm.tqdm(desc=description, total=total, unit=unit)\n        elif progress_bar_type == \"tqdm_notebook\":\n            return tqdm.notebook.tqdm(desc=description, total=total, unit=unit)\n        elif progress_bar_type == \"tqdm_gui\":\n            return tqdm.tqdm_gui(desc=description, total=total, unit=unit)\n    except (KeyError, TypeError):\n        # Protect ourselves from any tqdm errors. In case of\n        # unexpected tqdm behavior, just fall back to showing\n        # no progress bar.\n        warnings.warn(_NO_TQDM_ERROR, UserWarning, stacklevel=3)\n    return None\n\n\ndef wait_for_query(\n    query_job: \"QueryJob\",\n    progress_bar_type: Optional[str] = None,\n    max_results: Optional[int] = None,\n) -> \"RowIterator\":\n    \"\"\"Return query result and display a progress bar while the query running, if tqdm is installed.\n\n    Args:\n        query_job:\n            The job representing the execution of the query on the server.\n        progress_bar_type:\n            The type of progress bar to use to show query progress.\n        max_results:\n            The maximum number of rows the row iterator should return.\n\n    Returns:\n        A row iterator over the query results.\n    \"\"\"\n    default_total = 1\n    current_stage = None\n    start_time = time.time()\n\n    progress_bar = get_progress_bar(\n        progress_bar_type, \"Query is running\", default_total, \"query\"\n    )\n    if progress_bar is None:\n        return query_job.result(max_results=max_results)\n\n    i = 0\n    while True:\n        if query_job.query_plan:\n            default_total = len(query_job.query_plan)\n            current_stage = query_job.query_plan[i]\n            progress_bar.total = len(query_job.query_plan)\n            progress_bar.set_description(\n                \"Query executing stage {} and status {} : {:0.2f}s\".format(\n                    current_stage.name,\n                    current_stage.status,\n                    time.time() - start_time,\n                ),\n            )\n        try:\n            query_result = query_job.result(\n                timeout=_PROGRESS_BAR_UPDATE_INTERVAL, max_results=max_results\n            )\n            progress_bar.update(default_total)\n            progress_bar.set_description(\n                \"Query complete after {:0.2f}s\".format(time.time() - start_time),\n            )\n            break\n        except concurrent.futures.TimeoutError:\n            query_job.reload()  # Refreshes the state via a GET request.\n            if current_stage:\n                if current_stage.status == \"COMPLETE\":\n                    if i < default_total - 1:\n                        progress_bar.update(i + 1)\n                        i += 1\n            continue\n\n    progress_bar.close()\n    return query_result\n", "path": "google/cloud/bigquery/_tqdm_helpers.py"}]}