-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dataproc config for serverless in profile and fix quoting #578
Merged
colin-rogers-dbt
merged 24 commits into
main
from
feature/configure-serverless-dataproc-batch
Mar 9, 2023
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
1a46e8e
Support configuring GCP Dataproc serverless jobs
7eff828
Fixes and tests
c0ed862
Do not reinvent protobuf parsing.
131b2a3
ws
83d338f
Fix unit tests to run without gcloud credentials.
ed5f297
Merge branch 'main' into feature/configure-serverless-dataproc-batch
torkjel 74d1386
Merge branch 'main' into feature/configure-serverless-dataproc-batch
torkjel c266040
formatting
6af4601
Merge branch 'main' into feature/configure-serverless-dataproc-batch
torkjel 6f4be78
Merge branch 'main' into feature/configure-serverless-dataproc-batch
torkjel 867f624
Merge branch 'main' into feature/configure-serverless-dataproc-batch
torkjel b8e4fac
Merge branch 'main' into feature/configure-serverless-dataproc-batch
colin-rogers-dbt 2ef6f1c
Update dev-requirements.txt
colin-rogers-dbt d82ca54
Merge branch 'main' into feature/configure-serverless-dataproc-batch
ChenyuLInx f9960e6
Merge branch 'main' into feature/configure-serverless-dataproc-batch
Fleid b37f6cf
merge forked branch
colin-rogers-dbt 74bffe0
fix quote policy for py models, add python-test to tox.ini and cleanu…
colin-rogers-dbt c1695bc
have mypy install types
colin-rogers-dbt 7f8b528
add changie
colin-rogers-dbt da52414
add types-protobuf to dev-requirements.txt
colin-rogers-dbt 309b833
remove mypy install
colin-rogers-dbt 066eb78
Merge branch 'main' into feature/configure-serverless-dataproc-batch
colin-rogers-dbt 7d29ff0
Merge branch 'main' into feature/configure-serverless-dataproc-batch
colin-rogers-dbt 7436f55
remove branch update from dev-requirements.txt
colin-rogers-dbt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Features | ||
body: add dataproc serverless config to profile | ||
time: 2023-03-03T13:25:09.02695-08:00 | ||
custom: | ||
Author: colin-rogers-dbt torkjel | ||
Issue: "530" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% macro bigquery__resolve_model_name(input_model_name) -%} | ||
{{ input_model_name | string | replace('`', '') | replace('"', '\"') }} | ||
{%- endmacro -%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from unittest.mock import patch | ||
|
||
from dbt.adapters.bigquery.python_submissions import ServerlessDataProcHelper | ||
from google.cloud import dataproc_v1 | ||
|
||
from .test_bigquery_adapter import BaseTestBigQueryAdapter | ||
|
||
# Test application of dataproc_batch configuration to a | ||
# google.cloud.dataproc_v1.Batch object. | ||
# This reuses the machinery from BaseTestBigQueryAdapter to get hold of the | ||
# parsed credentials | ||
class TestConfigureDataprocBatch(BaseTestBigQueryAdapter): | ||
|
||
@patch('dbt.adapters.bigquery.connections.get_bigquery_defaults', return_value=('credentials', 'project_id')) | ||
def test_update_dataproc_serverless_batch(self, mock_get_bigquery_defaults): | ||
adapter = self.get_adapter('dataproc-serverless-configured') | ||
mock_get_bigquery_defaults.assert_called_once() | ||
|
||
credentials = adapter.acquire_connection('dummy').credentials | ||
self.assertIsNotNone(credentials) | ||
|
||
batchConfig = credentials.dataproc_batch | ||
self.assertIsNotNone(batchConfig) | ||
|
||
raw_batch_config = self.raw_profile['outputs']['dataproc-serverless-configured']['dataproc_batch'] | ||
raw_environment_config = raw_batch_config['environment_config'] | ||
raw_execution_config = raw_environment_config['execution_config'] | ||
raw_labels: dict[str, any] = raw_batch_config['labels'] | ||
raw_rt_config = raw_batch_config['runtime_config'] | ||
|
||
raw_batch_config = self.raw_profile['outputs']['dataproc-serverless-configured']['dataproc_batch'] | ||
|
||
batch = dataproc_v1.Batch() | ||
|
||
ServerlessDataProcHelper._update_batch_from_config(raw_batch_config, batch) | ||
|
||
# google's protobuf types expose maps as dict[str, str] | ||
to_str_values = lambda d: dict([(k, str(v)) for (k, v) in d.items()]) | ||
|
||
self.assertEqual(batch.environment_config.execution_config.service_account, raw_execution_config['service_account']) | ||
self.assertFalse(batch.environment_config.execution_config.network_uri) | ||
self.assertEqual(batch.environment_config.execution_config.subnetwork_uri, raw_execution_config['subnetwork_uri']) | ||
self.assertEqual(batch.environment_config.execution_config.network_tags, raw_execution_config['network_tags']) | ||
self.assertEqual(batch.labels, to_str_values(raw_labels)) | ||
self.assertEqual(batch.runtime_config.properties, to_str_values(raw_rt_config['properties'])) | ||
|
||
|
||
@patch('dbt.adapters.bigquery.connections.get_bigquery_defaults', return_value=('credentials', 'project_id')) | ||
def test_default_dataproc_serverless_batch(self, mock_get_bigquery_defaults): | ||
adapter = self.get_adapter('dataproc-serverless-default') | ||
mock_get_bigquery_defaults.assert_called_once() | ||
|
||
credentials = adapter.acquire_connection('dummy').credentials | ||
self.assertIsNotNone(credentials) | ||
|
||
batchConfig = credentials.dataproc_batch | ||
self.assertIsNone(batchConfig) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: does this go beyond flake8 and black line length?