Skip to content

Commit 00a4d44

Browse files
committed
[BUG] Clean up extra datasets.
Towards #215
1 parent d923dc8 commit 00a4d44

File tree

2 files changed

+27
-42
lines changed

2 files changed

+27
-42
lines changed

.travis.yml

+3-42
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,6 @@ language: python
22

33
matrix:
44
include:
5-
- os: linux
6-
python: 2.7
7-
env: PYTHON=2.7 PANDAS=0.19.2 COVERAGE='false' LINT='true'
8-
- os: linux
9-
python: 3.5
10-
env: PYTHON=3.5 PANDAS=0.18.1 COVERAGE='true' LINT='false'
11-
# https://github.com/pydata/pandas-gbq/issues/189
12-
# - os: linux
13-
# python: 3.6
14-
# env: PYTHON=3.6 PANDAS=0.20.1 COVERAGE='false' LINT='false'
155
- os: linux
166
python: 3.6
177
env: PYTHON=3.6 PANDAS=MASTER COVERAGE='false' LINT='true'
@@ -24,37 +14,8 @@ before_install:
2414
install:
2515
# Upgrade setuptools and pip to work around
2616
# https://github.com/pypa/setuptools/issues/885
27-
- pip install --upgrade setuptools
28-
- pip install --upgrade pip
29-
- REQ="ci/requirements-${PYTHON}-${PANDAS}" ;
30-
if [ -f "$REQ.pip" ]; then
31-
pip install --upgrade nox-automation ;
32-
else
33-
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
34-
bash miniconda.sh -b -p $HOME/miniconda ;
35-
export PATH="$HOME/miniconda/bin:$PATH" ;
36-
hash -r ;
37-
conda config --set always_yes yes --set changeps1 no ;
38-
conda config --add channels pandas ;
39-
conda config --add channels conda-forge ;
40-
conda update -q conda ;
41-
conda info -a ;
42-
conda create -q -n test-environment python=$PYTHON ;
43-
source activate test-environment ;
44-
conda install -q setuptools ;
45-
conda install -q pandas=$PANDAS;
46-
conda install -q --file "$REQ.conda";
47-
conda list ;
48-
python setup.py install ;
49-
fi
17+
- pip install --upgrade setuptools pip
18+
- pip install --upgrade google-cloud-bigquery
5019

5120
script:
52-
- if [[ $PYTHON == '2.7' ]]; then nox -s test27 ; fi
53-
- if [[ $PYTHON == '3.5' ]]; then nox -s test35 ; fi
54-
- if [[ $PYTHON == '3.6' ]] && [[ "$PANDAS" == "MASTER" ]]; then nox -s test36master ; fi
55-
- REQ="ci/requirements-${PYTHON}-${PANDAS}" ;
56-
if [ -f "$REQ.conda" ]; then
57-
pytest --quiet -m 'not local_auth' -v tests ;
58-
fi
59-
- if [[ $COVERAGE == 'true' ]]; then nox -s cover ; fi
60-
- if [[ $LINT == 'true' ]]; then nox -s lint ; fi
21+
- python cleanup.py

cleanup.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
import os
3+
import os.path
4+
5+
from google.cloud import bigquery
6+
7+
credentials_path = os.path.join(
8+
os.environ["TRAVIS_BUILD_DIR"], "ci", "travis_gbq.json"
9+
)
10+
11+
project_id = os.environ.get("GBQ_PROJECT_ID") or os.environ.get(
12+
"GOOGLE_CLOUD_PROJECT"
13+
)
14+
15+
client = bigquery.Client.from_service_account_json(
16+
credentials_path, project=project_id
17+
)
18+
19+
all_datasets = list(client.list_datasets())
20+
for dataset in all_datasets:
21+
if 'pandas_gbq_' not in dataset.dataset_id:
22+
print('Skipping dataset {}'.format(dataset.dataset_id))
23+
continue
24+
client.delete_dataset(dataset.reference, delete_contents=True)

0 commit comments

Comments
 (0)