Permission denied on `submitting ML job through api client`
See original GitHub issueHere is my code that I am trying run for submitting a ML training job through API client. I have used this before (roughly a year ago) and worked.
from googleapiclient import discovery
from googleapiclient import http
from google.oauth2 import service_account
def submit_training_job(training_inputs, gcp_project, job_name, gcp_ser_acc):
"""
submit training job
@params {
training_inputs : a json containing all inputs for submitting a training job
gcp_project: name of the project in google cloud platform
job_name: a job name
gcp_ser_acc: GCP service account
}
@returns {
response: a json object
}
"""
credentials = service_account.Credentials.from_service_account_info(gcp_ser_acc)
project_id = 'projects/{}'.format(gcp_project)
cloudml = discovery.build(
'ml',
'v1',
requestBuilder=http.HttpRequest,
credentials=credentials)
job_spec = {'jobId': job_name, 'trainingInput': training_inputs}
request = cloudml.projects().jobs().create(body=job_spec, parent=project_id)
print('request = ', request)
response = request.execute()
return response
However, I can’t get it worked and getting the following errors:
Traceback (most recent call last):
File ".\deploy-cloud.py", line 132, in <module>
response = submit_training_job(training_inputs, parsed.gcp_proj, job_name, config['GCP_SERVICE_ACC'])
File ".\deploy-cloud.py", line 52, in submit_training_job
response = request.execute()
File "C:\Users\UserName\Anaconda3\lib\site-packages\googleapiclient\_helpers.py", line 130, in positional_wrapper
return wrapped(*args, **kwargs)
File "C:\Users\UserName\Anaconda3\lib\site-packages\googleapiclient\http.py", line 856, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://ml.googleapis.com/v1/projects/GCP_PROJECT_NAME/jobs?alt=json returned "Permission denied on resource project GCP_PROJECT_NAME.". Details: "[{'@type': 'type.googleapis.com/google.rpc.Help', 'links': [{'description': 'Google developer console API key', 'url': 'https://console.developers.google.com/project/GCP_PROJECT_NAME/apiui/credential'}]}]">
I have created the service account
with full rights. So why does it complain about the permission?
Can anyone points out what is happening?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Permission Denied using Google AiPlatform ModelServiceClient
The model definitely exists and has finished training. I have given myself admin rights in the aiplatform service account. In the guide, they...
Read more >Request app permissions - Android Developers
Overview · Develop a TV input service · Work with channel data ... Advanced topics. Extensions API · ML Kit Analyzer · Rotations...
Read more >Error messages | Document AI - Google Cloud
Permission denied To diagnose this error, try opening the service account key file from the folder from which you're attempting to call the...
Read more >Troubleshoot AWS Glue job returning 403 access denied error
The AWS Identity and Access Management (IAM) role doesn't have the required permissions to access the bucket. The Amazon S3 bucket policies don' ......
Read more >Firebase IAM permissions
Permissions are granted to your project members via roles. A role is a collection of permissions. When you assign a role to a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
All good . It is working now. The issue was the wrong spelling of my project name.
Thanks @busunkim96 and @SurferJeffAtGoogle for stopping by.
What is the value of the
gcp_project
parameter passed to your function?