-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat(bigquery): expose customer managed encryption key for ML models #9302
Merged
tswast
merged 8 commits into
googleapis:master
from
MaxxleLLC:Bigquery_expose_CMEK_functionality_for_ML_models
Oct 16, 2019
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a824f51
feat: expose customer managed encryption key for ML models
HemangChothani a5c4e37
feat: add encryptionConfiguration in _PROPERTY_TO_API_FIELD
HemangChothani c88aaf2
changes in condition
HemangChothani 2427596
change in document and parameter
HemangChothani 809e4be
create a new file for class EncryptionConfiguration
HemangChothani c705622
feat(bigquery): refactor test class of encryption configuration and c…
HemangChothani 12cab01
feat(bigquery): add unit test in table class
HemangChothani 0fc3925
feat(bigquery): add apache license in file and test to show previous …
HemangChothani 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
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 |
---|---|---|
|
@@ -21,6 +21,8 @@ | |
import google.cloud._helpers | ||
from google.cloud.bigquery_v2.gapic import enums | ||
|
||
KMS_KEY_NAME = "projects/1/locations/global/keyRings/1/cryptoKeys/1" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this is a unit test, but we're supposed to discourage use of |
||
|
||
|
||
@pytest.fixture | ||
def target_class(): | ||
|
@@ -99,6 +101,7 @@ def test_from_api_repr(target_class): | |
}, | ||
], | ||
"featureColumns": [], | ||
"encryptionConfiguration": {"kmsKeyName": KMS_KEY_NAME}, | ||
} | ||
got = target_class.from_api_repr(resource) | ||
|
||
|
@@ -116,6 +119,7 @@ def test_from_api_repr(target_class): | |
assert got.friendly_name == u"A friendly name." | ||
assert got.model_type == enums.Model.ModelType.LOGISTIC_REGRESSION | ||
assert got.labels == {"greeting": u"こんにちは"} | ||
assert got.encryption_configuration.kms_key_name == KMS_KEY_NAME | ||
assert got.training_runs[0].training_options.initial_learn_rate == 1.0 | ||
assert ( | ||
got.training_runs[0] | ||
|
@@ -160,6 +164,7 @@ def test_from_api_repr_w_minimal_resource(target_class): | |
assert got.friendly_name is None | ||
assert got.model_type == enums.Model.ModelType.MODEL_TYPE_UNSPECIFIED | ||
assert got.labels == {} | ||
assert got.encryption_configuration is None | ||
assert len(got.training_runs) == 0 | ||
assert len(got.feature_columns) == 0 | ||
assert len(got.label_columns) == 0 | ||
|
@@ -229,6 +234,17 @@ def test_from_api_repr_w_unknown_fields(target_class): | |
["labels"], | ||
{"labels": {"a-label": "a-value"}}, | ||
), | ||
( | ||
{ | ||
"friendlyName": "hello", | ||
"description": "world", | ||
"expirationTime": None, | ||
"labels": {"a-label": "a-value"}, | ||
"encryptionConfiguration": {"kmsKeyName": KMS_KEY_NAME}, | ||
}, | ||
["encryptionConfiguration"], | ||
{"encryptionConfiguration": {"kmsKeyName": KMS_KEY_NAME}}, | ||
), | ||
], | ||
) | ||
def test_build_resource(object_under_test, resource, filter_fields, expected): | ||
|
@@ -283,6 +299,18 @@ def test_replace_labels(object_under_test): | |
assert object_under_test.labels == {} | ||
|
||
|
||
def test_set_encryption_configuration(object_under_test): | ||
from google.cloud.bigquery.table import EncryptionConfiguration | ||
|
||
assert not object_under_test.encryption_configuration | ||
object_under_test.encryption_configuration = EncryptionConfiguration( | ||
kms_key_name=KMS_KEY_NAME | ||
) | ||
assert object_under_test.encryption_configuration.kms_key_name == KMS_KEY_NAME | ||
object_under_test.encryption_configuration = None | ||
assert not object_under_test.encryption_configuration | ||
|
||
|
||
def test_repr(target_class): | ||
model = target_class("my-proj.my_dset.my_model") | ||
got = repr(model) | ||
|
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.
It seems wrong for
EncryptionConfiguration
to live in thetable
module now that it's used for tables and models. Let's create a newencryption_configuration
model for this to live. (Similar toexternal_config
.)We can make an alias in the
table
module to keep this from being a breaking change.