使用python3启动数据流作业的云函数有错误(google.auth.exceptions.RefreshError:(“未能检索到...)

时间:2019-02-08 14:38:47

标签: python-3.x google-cloud-platform

i代码启动数据流作业并出现一些错误

def kickOffDataflow(input, output):
  print('Strat to create dataflow job')

  credentials = GoogleCredentials.get_application_default()
  service = build('dataflow', 'v1b3', credentials=credentials)
  BODY = {
        "environment": {
           "zone": "europe-west1-b"
        },
        "parameters": {
           "configFile": input,
           "outputFile": output,
           "mode": "cluster_test"
        },
        "jobName": DATAFLOW_JOB_NAME
  }
  request = service.projects().templates().launch(
    projectId=PROJECT_ID, gcsPath=TEMPLETE_FILE_PATH, body=BODY)
  response = request.execute()
  print(response)

这是我的错误,看来我输入的网址错误,并且我按照文档写了https://cloud.google.com/dataflow/docs/guides/templates/executing-templates

File "/env/local/lib/python3.7/site-packages/google/cloud/functions/worker.py", line 349, in run_background_function
    _function_handler.invoke_user_function(event_object)
  File "/env/local/lib/python3.7/site-packages/google/cloud/functions/worker.py", line 215, in invoke_user_function
    return call_user_function(renter code hereequest_or_event)
  File "/env/local/lib/python3.7/site-enter code herepackages/google/cloud/functions/worker.py", line 212, in call_user_function
    event_context.Context(**request_or_event.context))
  File "/user_code/main.py", line 84, in GCSTriggerFile
    checkFilePathAndGenerateConfigjson(data['name'])
  File "/user_code/main.py", line 69, in checkFilePathAndGenerateConfigjson
    updloadFileToBucket(jsonFileName, localFile, fileName)
  File "/user_code/main.py", line 48, in updloadFileToBucket
    "config/" + jsonFileName, OUT_PUT_FILE_PATH + fileName)
  File "/user_code/main.py", line 33, in kickOffDataflow
    response = request.execute()
  File "/env/local/lib/python3.7/site-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/env/local/lib/python3.7/site-packages/googleapiclient/http.py", line 846, in execute
    method=str(self.method), body=self.body, headers=self.headers)
  File "/env/local/lib/python3.7/site-packages/googleapiclient/http.py", line 164, in _retry_request
    resp, content = http.request(uri, method, *args, **kwargs)
  File "/env/local/lib/python3.7/site-packages/google_auth_httplib2.py", line 187, in request
    self._request, method, uri, request_headers)
  File "/env/local/lib/python3.7/site-packages/google/auth/credentials.py", line 122, in before_request
    self.refresh(request)
  File "/env/local/lib/python3.7/site-packages/google/auth/compute_engine/credentials.py", line 102, in refresh
    six.raise_from(new_exc, caught_exc)
  File "<string>", line 3, in raise_from
google.auth.exceptions.RefreshError: ("Failed to retrieve http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/international-gramercy-staging@appspot.gserviceaccount.com/token from the Google Compute Enginemetadata service. Status: 500 Response:\nb'Could not fetch URI /computeMetadata/v1/instance/serv`enter code here`ice-accounts/international-gramercy-staging@appspot.gserviceaccount.com/token\\n'", <google_auth_httplib2._Response object at 0x2aa4ddd881d0>)
"  

0 个答案:

没有答案