根据 Chrome 开发工具,我获取 html 部分的请求具有源头https://site-name-here.com和请求头 GET。
我的存储桶设置了以下 JSON 文件:
[
{
"origin": ["https://site-name-here.com"],
"responseHeader": ["content-type"],
"method": ["GET"],
"maxAgeSeconds": 3600
}
]
Run Code Online (Sandbox Code Playgroud)
但是,每当 angular 尝试获取视图时,我都会收到以下错误: XMLHttpRequest cannot load https://storage.googleapis.com/bucket-name/view-path.html?. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://site-name-here.com' is therefore not allowed access.
我还提供来自 Cloud Storage 的 javascript 和 css 文件,但它们工作正常,我假设是因为 CSS 没有 CORS 限制,而且我在 Angular 中使用 $sceDelegateProvider.resourceUrlWhitelist() 作为脚本?
编辑:现在工作,我假设有些东西被缓存了,它为我提供了一个旧版本。
cross-domain cors google-cloud-storage gsutil google-cloud-platform
根据Google Cloud 文档,如果我是具有“计算实例管理员”角色的项目成员,我应该能够使用 gcloud 工具连接到项目中的任何实例。
在 Google Cloud 控制台的项目 IAM 页面上,我已明确添加具有“计算实例管理员 (v1)”角色的用户名,但我仍然无法连接到由我们的某些自动化功能创建的实例。
[username]:~/src/infrastructure$ gcloud compute ssh [instance id]
Unauthorized use is strictly prohibited. All access and activity
is subject to logging and monitoring.
Permission denied (publickey).
ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255].
Run Code Online (Sandbox Code Playgroud)
我似乎能够连接到的唯一实例是我创建的实例。
这里可能出了什么问题?
附带说明一下,根据此文档,我应该能够手动将 RSA 公钥添加到实例,然后使用 SSH 进行连接。
我将公钥添加~/.ssh/google_compute_engine.pub到实例元数据中,然后尝试使用 SSH,但没有成功。
[username]:~/src/infrastructure$ ssh -i ~/.ssh/google_compute_engine [public ip of instance]
Unauthorized use is strictly prohibited. All access and activity is subject to logging …Run Code Online (Sandbox Code Playgroud) 我是深度学习的新手,我想使用预训练 (EAST) 模型从 AI Platform Serving 提供服务,开发人员提供了以下文件:
我想把它转换成 TensorFlow.pb格式。有没有办法做到这一点?我从这里拿了模型
完整代码可在此处获得。
我查了一下here,它显示了以下代码来转换它:
从 tensorflow/models/research/
INPUT_TYPE=image_tensor
PIPELINE_CONFIG_PATH={path to pipeline config file}
TRAINED_CKPT_PREFIX={path to model.ckpt}
EXPORT_DIR={path to folder that will be used for export}
python object_detection/export_inference_graph.py \
--input_type=${INPUT_TYPE} \
--pipeline_config_path=${PIPELINE_CONFIG_PATH} \
--trained_checkpoint_prefix=${TRAINED_CKPT_PREFIX} \
--output_directory=${EXPORT_DIR}
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚要传递什么值:
我正在使用托管 CloudRun 部署一个带有concurrency=1. 部署后,我将并行触发四个长时间运行的请求。大多数情况下,一切正常——但偶尔,我会在几秒钟内面对来自其中一个节点的 500 个;日志仅提供主题中提供的错误消息。
使用带指数退避的重试并没有改善这种情况;重试也以 500 秒结束。StackDriver 日志也不提供更多信息。
可能相关的gcloud beta run deploy论点:
--memory 2Gi --concurrency 1 --timeout 8m --platform managed
错误消息的确切含义是什么——我该如何解决这个问题?
我想允许用户模拟服务帐户来对长时间运行的进程执行操作。但是,所有代码示例都说明了一个服务帐户模拟另一个服务帐户。
用户可以直接冒充服务帐号吗?如果是这样,怎么办?
我正在遵循这个示例代码。
初始化一个无权访问列表桶的源凭证:
from google.oauth2 import service_acccount
target_scopes = [
'https://www.googleapis.com/auth/devstorage.read_only']
source_credentials = (
service_account.Credentials.from_service_account_file(
'/path/to/svc_account.json',
scopes=target_scopes))
Run Code Online (Sandbox Code Playgroud)
现在使用源凭据来获取凭据以模拟另一个服务帐户:
from google.auth import impersonated_credentials
target_credentials = impersonated_credentials.Credentials(
source_credentials=source_credentials,
target_principal='impersonated-account@_project_.iam.gserviceaccount.com',
target_scopes = target_scopes,
lifetime=500)
Run Code Online (Sandbox Code Playgroud) impersonation service-accounts google-cloud-platform google-iam google-cloud-iam
我正在尝试安装 python3 virtualenv。当我尝试运行 virtualenv 时,我收到以下消息。
virtualenv
Command 'virtualenv' not found, but can be installed with:
apt install python3-virtualenv
Run Code Online (Sandbox Code Playgroud)
但是如果我运行 install 命令,我会收到以下错误。
apt install python3-virtualenv
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python3-virtualenv
Run Code Online (Sandbox Code Playgroud)
对于python3 -m venv,我收到了要使用安装的消息,apt-get install python3-venv
但是当我尝试安装时,我收到了相同的消息。
sudo apt-get install python3-venv
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package python3-venv is not available, but is referred to by another package.
This may mean …Run Code Online (Sandbox Code Playgroud) 我在 Google Cloud 上启用了一个项目、计费和 Cloud Speech to Text API。然后我下载了一个 .json 文件。然后我尝试在 PyCharm 中执行这个基本代码。
import os
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] ="instant-medium-282.json"
from google.cloud import speech_v1
from google.cloud.speech_v1 import enums
client = speech_v1.SpeechClient()
encoding = enums.RecognitionConfig.AudioEncoding.FLAC
sample_rate_hertz = 44100
language_code = 'en-US'
config = {'encoding': encoding, 'sample_rate_hertz': sample_rate_hertz, 'language_code': language_code}
uri = 'gs://bucket_name/file_name.flac'
audio = {'uri': uri}
response = client.recognize(config, audio)
Run Code Online (Sandbox Code Playgroud)
但是,我不断收到此错误:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/google/api_core/grpc_helpers.py", line 57, in error_remapped_callable
return callable_(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/grpc/_channel.py", line 826, in __call__
return _end_unary_response_blocking(state, call, …Run Code Online (Sandbox Code Playgroud) google-cloud-platform google-cloud-billing google-speech-to-text-api
我正在将云存储与 App Engine Flex 结合使用。部署成功后,我突然开始收到此错误消息
错误发生在我的 Flask 应用程序中的这些行中。
from google.cloud import storage, datastore
client = storage.Client()
Run Code Online (Sandbox Code Playgroud)
File "/home/vmagent/app/main.py", line 104, in _load_db
client = storage.Client()
File "/env/lib/python3.6/site-packages/google/cloud/storage/client.py", line 110, in __init__
project=project, credentials=credentials, _http=_http
File "/env/lib/python3.6/site-packages/google/cloud/client.py", line 250, in __init__
Client.__init__(self, credentials=credentials, client_options=client_options, _http=_http)
File "/env/lib/python3.6/site-packages/google/cloud/client.py", line 143, in __init__
scopes = client_options.scopes or self.SCOPE
AttributeError: 'ClientOptions' object has no attribute 'scopes'
Run Code Online (Sandbox Code Playgroud)
这与基于大量 SO 线程对 grpcio 和 google-api-core 以及 google-cloud-storage 软件包进行的重大升级有关。但是,我无法弄清楚这是在哪里发生的。
我的requirements.txt如下:
setuptools>=40.3
grpcio<=1.27.2
google-api-core<1.17.0
Flask
gevent>=0.13
gunicorn>=19.7.1
numpy>=1.18.0
numpy-financial …Run Code Online (Sandbox Code Playgroud) python python-3.x google-cloud-storage google-cloud-platform grpc-python
我正在尝试为 Oauth 同意屏幕注册我的应用程序,以便我可以创建 OAuth 客户端 ID。即使我已正确提交所有内容,我仍然在表单末尾收到此验证错误。
保存您的应用程序时出错
并且此错误未说明表单中的哪个输入无效。同样在开发工具窗口的网络选项卡中,每次我提交请求时,我都可以看到正在发起 POST 请求,但失败并显示以下错误。
{"error":{"code":3,"message":"The request failed because one of the field of the resource is invalid.","details":[{"@type":"type.googleapis.com/google.rpc.PreconditionFailure","violations":[{"type":"client_auth_config","subject":"?error_code=9&error_field_name=UpdateBrandWithMaskRequest.brand_id&error_field_value=0"}]}]}}.
非常感谢有关如何解决此问题的任何建议。我也就这个问题联系了谷歌支持,但截至目前,他们说一切正常,清除缓存和 cookie,但它不起作用。我在此处附上了我正在使用的同意配置向导的捕获。
几个月来,我们一直在完全托管的 CloudRun 上使用 NestJS 和 TypeORM 运行服务,没有出现任何问题。昨天下午Improper path /cloudsql/{SQL_CONNECTION_NAME} to connect to Postgres Cloud SQL instance "{SQL_CONNECTION_NAME}",我们的日志开始出现错误。
我们没有围绕此时间戳进行任何服务器/SQL 更改。目前对服务没有影响,所以我们不确定这是否是一个严重的问题。
这个错误不是来自我们的代码,我们的第三方模块不应该知道我们是否使用 Cloud SQL,所以我不知道这个错误来自哪里。
我的假设是 Cloud SQL 代理或 Cloud Run 中使用的任何 SQL 客户端都会导致此错误。在使用“gcloud run deploy”CLI 命令进行部署时,我们使用 --add-cloudsql-instances 标志。
问题链接在这里
postgresql google-cloud-sql google-cloud-platform typeorm google-cloud-run
python ×2
python-3.x ×2
cors ×1
cross-domain ×1
gcloud ×1
google-iam ×1
google-oauth ×1
grpc-python ×1
gsutil ×1
postgresql ×1
serverless ×1
ssh ×1
tensorflow ×1
typeorm ×1
ubuntu-20.04 ×1
virtualenv ×1