I'm trying to automate the model deployment in GCP AI Platform. I.e., after a model is trained successfully, I package and upload the model and source package to GCS, and deploy it as a new version and set as default. I have this at the end of my training script. I need this because the model retrains periodically.
In the training script, the packaging and uploading (calling gsutil
with subprocess
) worked fine but I ran into permission issues when trying to deploy a new version. I've tried to
- call
gcloud ai-platform
withsubprocess
- call
discovery.build('ml', 'v1').projects().models().versions().create()
fromgooglecloudapis
directly - invoke a Cloud Function that does the above
Any way I receive the error
ResponseError: status=[403], code=[Forbidden], message=[Request had insufficient authentication scopes.]
I've added enough permissions to the service account for AI Platform (service-xxxxxxxxx@cloud-ml.google.com.iam.gserviceaccount.com
, Google Cloud ML Engine Service Agent), but it didn't work.
It seems inside the training instances a different account is used. discovery.build('ml', 'v1')._http.credentials._service_account
returns default
instead of an email.
Before I go on to use Cloud Function to monitor the export from the training script, I'd like to ask if I missed anything or if there're any other options?
Thanks.