Skip to content

Commit

Permalink
remove tqdm import check function and import at top
Browse files Browse the repository at this point in the history
  • Loading branch information
aktech committed Apr 27, 2018
1 parent 23c98b0 commit 2dfd111
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions pandas_gbq/gbq.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
BIGQUERY_INSTALLED_VERSION = None
SHOW_VERBOSE_DEPRECATION = False

try:
import tqdm # noqa
except ImportError:
tqdm = None


def _check_google_client_version():
global BIGQUERY_INSTALLED_VERSION, SHOW_VERBOSE_DEPRECATION
Expand Down Expand Up @@ -561,9 +566,8 @@ def load_data(
chunks = load.load_chunks(self.client, dataframe, dataset_id,
table_id, chunksize=chunksize,
schema=schema)
if progress_bar and self._check_if_tqdm_exists():
from tqdm import tqdm
chunks = tqdm(chunks)
if progress_bar and tqdm:
chunks = tqdm.tqdm(chunks)
for remaining_rows in chunks:
logger.info("\rLoad is {0}% Complete".format(
((total_rows - remaining_rows) * 100) / total_rows))
Expand All @@ -572,13 +576,6 @@ def load_data(

logger.info("\n")

def _check_if_tqdm_exists(self):
try:
import tqdm # noqa
return True
except ImportError:
return False

def schema(self, dataset_id, table_id):
"""Retrieve the schema of the table
Expand Down

0 comments on commit 2dfd111

Please sign in to comment.