Skip to content

Commit 335886a

Browse files
authored
test(data-science): add error checking, change machine type (GoogleCloudPlatform#4535)
1 parent e5048c8 commit 335886a

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

data-science-onramp/data-cleaning/clean_test.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
import re
33
import uuid
44

5+
from google.api_core.exceptions import NotFound
56
from google.cloud import bigquery
67
from google.cloud import dataproc_v1 as dataproc
78
from google.cloud import storage
9+
810
import pandas as pd
911
import pytest
1012

@@ -33,8 +35,12 @@
3335
"zone_uri": "",
3436
"metadata": {"PIP_PACKAGES": "google-cloud-storage"},
3537
},
36-
"master_config": {"num_instances": 1, "machine_type_uri": "n1-standard-8"},
37-
"worker_config": {"num_instances": 6, "machine_type_uri": "n1-standard-8"},
38+
# We recommend these settings for running our code
39+
# We use a less robust machine type for testing purposes
40+
# "master_config": {"num_instances": 1, "machine_type_uri": "n1-standard-8"},
41+
# "worker_config": {"num_instances": 6, "machine_type_uri": "n1-standard-8"},
42+
"master_config": {"num_instances": 1, "machine_type_uri": "n1-standard-4"},
43+
"worker_config": {"num_instances": 2, "machine_type_uri": "n1-standard-4"},
3844
"software_config": {
3945
"image_version": CLUSTER_IMAGE,
4046
# Change optional component to "ANACONDA" when this issue is resolved:
@@ -77,7 +83,10 @@ def setup_and_teardown_table():
7783
yield
7884

7985
# Delete dataset
80-
bq_client.delete_dataset(BQ_DATASET, delete_contents=True)
86+
try:
87+
bq_client.delete_dataset(BQ_DATASET, delete_contents=True)
88+
except NotFound as e:
89+
print(f"Ignoring NotFound upon cleanup, details: {e}")
8190

8291

8392
@pytest.fixture(autouse=True)

data-science-onramp/data-ingestion/setup_test.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import re
88
import uuid
99

10+
from google.api_core.exceptions import NotFound
1011
from google.cloud import bigquery
1112
from google.cloud import dataproc_v1 as dataproc
1213
from google.cloud import storage
@@ -36,8 +37,12 @@
3637
"cluster_name": DATAPROC_CLUSTER,
3738
"config": {
3839
"gce_cluster_config": {"zone_uri": ""},
39-
"master_config": {"num_instances": 1, "machine_type_uri": "n1-standard-8"},
40-
"worker_config": {"num_instances": 6, "machine_type_uri": "n1-standard-8"},
40+
# We recommend these configs when running the full code
41+
# We use a less robust machine type for the tests
42+
# "master_config": {"num_instances": 1, "machine_type_uri": "n1-standard-8"},
43+
# "worker_config": {"num_instances": 6, "machine_type_uri": "n1-standard-8"},
44+
"master_config": {"num_instances": 1, "machine_type_uri": "n1-standard-4"},
45+
"worker_config": {"num_instances": 2, "machine_type_uri": "n1-standard-4"},
4146
"software_config": {
4247
"image_version": CLUSTER_IMAGE,
4348
"optional_components": [5],
@@ -102,7 +107,10 @@ def setup_and_teardown_bq_dataset():
102107
yield
103108

104109
# Delete Dataset
105-
bq_client.delete_dataset(BQ_DATASET, delete_contents=True)
110+
try:
111+
bq_client.delete_dataset(BQ_DATASET, delete_contents=True)
112+
except NotFound as e:
113+
print(f"Ignoring NotFound on cleanup, details: {e}")
106114

107115

108116
def get_blob_from_path(path):

0 commit comments

Comments
 (0)