Skip to content

Commit e146cf7

Browse files
committed
bugfix: enforce gcloud vars
1 parent b263db4 commit e146cf7

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

v03_pipeline/lib/tasks/dataproc/create_dataproc_cluster.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ def complete(self) -> bool:
167167
return cluster.status.state == RUNNING_STATE
168168

169169
def run(self):
170+
if not Env.GCLOUD_PROJECT or not Env.GCLOUD_REGION or not Env.GCLOUD_ZONE:
171+
msg = 'Environment Variables GCLOUD_PROJECT, GCLOUD_REGION, GCLOUD_ZONE are required for running the pipeline on dataproc.'
172+
raise RuntimeError(msg)
170173
operation = self.client.create_cluster(
171174
request={
172175
'project_id': Env.GCLOUD_PROJECT,

v03_pipeline/lib/tasks/dataproc/create_dataproc_cluster_test.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
)
1313

1414

15+
@patch.multiple(
16+
'v03_pipeline.lib.tasks.dataproc.create_dataproc_cluster.Env',
17+
GCLOUD_PROJECT='proj',
18+
GCLOUD_REGION='us-a',
19+
GCLOUD_ZONE='us-a-1',
20+
)
1521
@patch(
1622
'v03_pipeline.lib.tasks.dataproc.create_dataproc_cluster.get_service_account_credentials',
1723
return_value=SimpleNamespace(
@@ -26,7 +32,7 @@ class CreateDataprocClusterTaskTest(unittest.TestCase):
2632
def test_dataset_type_unsupported(
2733
self,
2834
mock_cluster_controller: Mock,
29-
_: Mock,
35+
*_: Mock,
3036
) -> None:
3137
task = CreateDataprocClusterTask(
3238
reference_genome=ReferenceGenome.GRCh38,
@@ -38,7 +44,7 @@ def test_dataset_type_unsupported(
3844
def test_spinup_cluster_already_exists_failed(
3945
self,
4046
mock_cluster_controller: Mock,
41-
_: Mock,
47+
*_: Mock,
4248
) -> None:
4349
mock_client = mock_cluster_controller.return_value
4450
mock_client.get_cluster.return_value = SimpleNamespace(
@@ -61,7 +67,7 @@ def test_spinup_cluster_already_exists_failed(
6167
def test_spinup_cluster_already_exists_success(
6268
self,
6369
mock_cluster_controller: Mock,
64-
_: Mock,
70+
*_: Mock,
6571
) -> None:
6672
mock_client = mock_cluster_controller.return_value
6773
mock_client.get_cluster.return_value = SimpleNamespace(
@@ -85,7 +91,7 @@ def test_spinup_cluster_doesnt_exist_failed(
8591
self,
8692
mock_logger: Mock,
8793
mock_cluster_controller: Mock,
88-
_: Mock,
94+
*_: Mock,
8995
) -> None:
9096
mock_client = mock_cluster_controller.return_value
9197
mock_client.get_cluster.side_effect = google.api_core.exceptions.NotFound(
@@ -111,7 +117,7 @@ def test_spinup_cluster_doesnt_exist_success(
111117
self,
112118
mock_logger: Mock,
113119
mock_cluster_controller: Mock,
114-
_: Mock,
120+
*_: Mock,
115121
) -> None:
116122
mock_client = mock_cluster_controller.return_value
117123
mock_client.get_cluster.side_effect = google.api_core.exceptions.NotFound(

0 commit comments

Comments
 (0)