MCPcopy Index your code
hub / github.com/Kaggle/docker-python / set_gcloud_credentials

Method set_gcloud_credentials

patches/kaggle_secrets.py:86–106  ·  view source on GitHub ↗

Set user credentials attached to the current kernel and optionally the project & account name to the `gcloud` CLI. Example usage: client = UserSecretsClient() client.set_gcloud_credentials(project="my-gcp-project", account="me@my-org.com") !gcloud ai-pla

(self, project=None, account=None)

Source from the content-addressed store, hash-verified

84 raise
85
86 def set_gcloud_credentials(self, project=None, account=None):
87 """Set user credentials attached to the current kernel and optionally the project & account name to the `gcloud` CLI.
88
89 Example usage:
90 client = UserSecretsClient()
91 client.set_gcloud_credentials(project="my-gcp-project", account="me@my-org.com")
92
93 !gcloud ai-platform jobs list
94 """
95 creds = self.get_gcloud_credential()
96 creds_path = self._write_credentials_file(creds)
97
98 subprocess.run(['gcloud', 'config', 'set', 'auth/credential_file_override', creds_path])
99
100 if project:
101 os.environ['GOOGLE_CLOUD_PROJECT'] = project
102 subprocess.run(['gcloud', 'config', 'set', 'project', project])
103
104 if account:
105 os.environ['GOOGLE_ACCOUNT'] = account
106 subprocess.run(['gcloud', 'config', 'set', 'account', account])
107
108 def set_tensorflow_credential(self, credential):
109 """Sets the credential for use by Tensorflow"""

Callers 1

test_fnMethod · 0.95

Calls 2

get_gcloud_credentialMethod · 0.95

Tested by 1

test_fnMethod · 0.76