Repository navigation
feat: Added encryption_spec_key_name to all relevant resources #256
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
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
713bca2
Added encryption_spec_key_name to Dataset and subclasses
ivanmkc-google d6efe27
Added tests
ivanmkc-google be4fa78
fix: Fixed encryption key name arg order
ivanmkc-google 39415b0
feat: Added encryption_spec_key_name to aiplatform.init
ivanmkc-google 613ed56
feat: Added test for aiplatform init with encryption key name
ivanmkc-google b4369a8
fix: Added docstrings
ivanmkc-google 272450c
fix: Docstring fixes
ivanmkc-google 8f016d0
feat: Added CMEK support for Endpoint and tests
ivanmkc-google 0984814
feat: Added CMEK support for BatchPredictionJob
ivanmkc-google 02f595f
feat: Added CMEK support for Training Pipeline, _TrainingJob, _Custom…
ivanmkc-google 1e24d41
Added CMEK support for TrainingJobs
ivanmkc-google 3a531e8
fix: Fixed tests and docstrings
ivanmkc-google d9b4546
fix: Fixed CMEK tests to test for Model encryption as well
ivanmkc-google 7646caf
fix: Fixed lint issues
ivanmkc-google e046d04
fix: Moved default encryption key setting to sync functions
ivanmkc-google 53f1e93
fix: Added comment about potential bug
ivanmkc-google 25c3ef4
fix: Fixed Dataset encryption spec defaulting location to a sync method
ivanmkc-google 127bd14
fix: Lint and format fixes
ivanmkc-google f9d3a1f
fix: Fixed tests and Models CMEK integration
ivanmkc-google 7345bb3
fix: Ran linter
ivanmkc-google 67880b2
fix: Fixed docstrings
ivanmkc-google 1bd7d15
fix: Improved docstrings
ivanmkc-google 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ | |
| from google.auth.exceptions import GoogleAuthError | ||
| from google.cloud.aiplatform import utils | ||
| from google.cloud.aiplatform import constants | ||
| from google.cloud.aiplatform_v1beta1.types import encryption_spec as gca_encryption_spec | ||
|
|
||
|
|
||
| class _Config: | ||
|
|
@@ -40,6 +41,7 @@ def __init__(self): | |
| self._location = None | ||
| self._staging_bucket = None | ||
| self._credentials = None | ||
| self._encryption_spec_key_name = None | ||
|
|
||
| def init( | ||
| self, | ||
|
|
@@ -49,6 +51,7 @@ def init( | |
| experiment: Optional[str] = None, | ||
| staging_bucket: Optional[str] = None, | ||
| credentials: Optional[auth_credentials.Credentials] = None, | ||
| encryption_spec_key_name: Optional[str] = None, | ||
| ): | ||
| """Updates common initalization parameters with provided options. | ||
|
|
||
|
|
@@ -59,9 +62,18 @@ def init( | |
| experiment (str): The experiment to assign | ||
| staging_bucket (str): The default staging bucket to use to stage artifacts | ||
| when making API calls. In the form gs://... | ||
| credentials (google.auth.crendentials.Crendentials): The default custom | ||
| credentials (google.auth.crendentials.Credentials): The default custom | ||
| credentials to use when making API calls. If not provided crendentials | ||
| will be ascertained from the environment. | ||
| encryption_spec_key_name (Optional[str]): | ||
| Optional. The Cloud KMS resource identifier of the customer | ||
| managed encryption key used to protect a resource. Has the | ||
| form: | ||
| ``projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key``. | ||
| The key needs to be in the same region as where the compute | ||
| resource is created. | ||
|
|
||
| If set, this resource and all sub-resources will be secured by this key. | ||
| """ | ||
| if project: | ||
| self._project = project | ||
|
|
@@ -75,6 +87,25 @@ def init( | |
| self._staging_bucket = staging_bucket | ||
| if credentials: | ||
| self._credentials = credentials | ||
| if encryption_spec_key_name: | ||
| self._encryption_spec_key_name = encryption_spec_key_name | ||
|
|
||
| def get_encryption_spec( | ||
| self, encryption_spec_key_name: Optional[str] | ||
| ) -> Optional[gca_encryption_spec.EncryptionSpec]: | ||
|
ivanmkc marked this conversation as resolved.
|
||
| """Creates a gca_encryption_spec.EncryptionSpec instance from the given key name. | ||
| If the provided key name is None, it uses the default key name if provided. | ||
|
Member
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. Needs Args and Returns section.
Contributor
Author
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 need to improve my docstring game. Thanks |
||
|
|
||
| Args: | ||
| encryption_spec_key_name (Optional[str]): The default encryption key name to use when creating resources. | ||
| """ | ||
| kms_key_name = encryption_spec_key_name or self.encryption_spec_key_name | ||
| encryption_spec = None | ||
| if kms_key_name: | ||
| encryption_spec = gca_encryption_spec.EncryptionSpec( | ||
| kms_key_name=kms_key_name | ||
| ) | ||
| return encryption_spec | ||
|
|
||
| @property | ||
| def project(self) -> str: | ||
|
|
@@ -126,6 +157,11 @@ def credentials(self) -> Optional[auth_credentials.Credentials]: | |
| logger.removeFilter(logging_warning_filter) | ||
| return credentials | ||
|
|
||
| @property | ||
| def encryption_spec_key_name(self) -> Optional[str]: | ||
| """Default encryption spec key name, if provided.""" | ||
| return self._encryption_spec_key_name | ||
|
|
||
| def get_client_options( | ||
| self, location_override: Optional[str] = None, prediction_client: bool = False, | ||
| ) -> client_options.ClientOptions: | ||
|
|
||
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.