使用2.11.0版本运行DataFlow流作业。 几个小时后,我收到以下身份验证错误:
File "streaming_twitter.py",line 188,in <lambda>
File "streaming_twitter.py",line 102,in estimate
File "streaming_twitter.py",line 84,in estimate_aiplatform
File "streaming_twitter.py",line 42,in get_service
File "/usr/local/lib/python2.7/dist-packages/googleapiclient/_helpers.py",line 130,in positional_wrapper return wrapped(*args,**kwargs)
File "/usr/local/lib/python2.7/dist-packages/googleapiclient/discovery.py",line 227,in build credentials=credentials)
File "/usr/local/lib/python2.7/dist-packages/googleapiclient/_helpers.py",line 363,in build_from_document credentials = _auth.default_credentials()
File "/usr/local/lib/python2.7/dist-packages/googleapiclient/_auth.py",in default_credentials credentials,_ = google.auth.default()
File "/usr/local/lib/python2.7/dist-packages/google/auth/_default.py",line 306,in default raise exceptions.DefaultCredentialsError(_HELP_MESSAGE) DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application.
此数据流作业对AI平台预测执行API请求 似乎是身份验证令牌即将到期。
代码段:
def get_service():
# If it hasn't been instantiated yet: do it now
return discovery.build('ml','v1',discoveryServiceUrl=DISCOVERY_SERVICE,cache_discovery=True)
我尝试在服务功能中添加以下几行:
os.environ[
"GOOGLE_APPLICATION_CREDENTIALS"] = "/tmp/key.json"
但是我得到了
DefaultCredentialsError: File "/tmp/key.json" was not found. [while running 'generatedPtransform-930']
我认为是因为文件不在DataFlow机器中。
另一个选择是在构建方法中使用developerKey
参数,但AI Platform预测似乎不支持该参数,我得到了错误:
Expected OAuth 2 access token,login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project."> [while running 'generatedPtransform-22624']
要了解如何解决它以及最佳实践是什么?
有什么建议吗?