The Cloud ML instructions show how to obtain the service account using shell commands. How can I do this programmatically in Python? e.g. in Datalab?
You can use Google Cloud's Python client libraries to issue the getConfig request.
from googleapiclient import discovery
from googleapiclient import http
from oauth2client.client import GoogleCredentials
credentials = GoogleCredentials.get_application_default()
ml_client = discovery.build(
'ml',
'v1beta1',
requestBuilder=http.HttpRequest,
credentials=credentials)
p = ml_client.projects()
config = p.getConfig(name="projects/my-project").execute()
SERVICE_ACCOUNT = config["serviceAccount"]