我在Google的不同文档中看到了这两种用法:
from google.cloud import pubsub
Run Code Online (Sandbox Code Playgroud)
发现于:
而
from google.cloud import pubsub_v1
Run Code Online (Sandbox Code Playgroud)
找到:
我正在使用Google表格API的Python客户端来构建电子表格。我可以创建一个新工作表并更新其中的值,但是我无法合并所需标题行的单元格。
top_header_format = [
{'mergeCells': {
'mergeType': 'MERGE_COLUMNS',
'range': {
'endColumnIndex': 3,
'endRowIndex': 1,
'sheetId': '112501875',
'startColumnIndex': 0,
'startRowIndex': 0
}
}},
{'mergeCells': {
'mergeType': 'MERGE_COLUMNS',
'range': {
'endColumnIndex': 5,
'endRowIndex': 1,
'sheetId': '112501875',
'startColumnIndex': 3,
'startRowIndex': 0
}
}}
]
service.spreadsheets().batchUpdate(
spreadsheetId=spreadsheet_id,
body={'requests': top_header_format}
).execute()
Run Code Online (Sandbox Code Playgroud)
这是我正在运行的代码。没有错误。响应的答复为空,并且电子表格没有合并的单元格。文档在这里。
我有一个 Keras .h5 模型,我一直在本地训练它,但是现在希望通过 Google Cloud ML-Engine 自动化整个过程。
我已将所有 GCloud Storage 存储桶设置为可从应用程序访问,并且我已阅读有关配置作业以提交Keras模型以在 GCloud ML-Engine 中进行训练的信息。但是,所有这些教程(包括 google cloud ml-engine 上的文档)都声明要运行作业最好从命令行运行gcloud ml-engine jobs submit training。
不过,我知道 Google Cloud 有一个 Python 客户端库,但它的文档似乎有点不透明。
有人知道我是否可以完全从 python 文件本身提交模型的训练(通过直接 API 调用或通过 Google 客户端库)?我问是因为我希望把它变成一个完全自动化的、托管的 Flask 网络应用程序,用于模型训练,所以它需要尽可能地放手。
python google-cloud-platform keras google-cloud-ml google-python-api
该gsutil命令具有优化大文件上传/下载速度的选项。例如
GSUtil:parallel_composite_upload_threshold=150M
GSUtil:sliced_object_download_max_components=8
Run Code Online (Sandbox Code Playgroud)
请参阅此页面以供参考。
google.cloud.storagepython API中的等价物是什么?我在这个文档中没有找到相关参数。
一般来说,客户端API和gsutil功能上是否一一对应?
我正在尝试通过 API 获取 gsuite 警报。我已经根据他们的文档创建了一个服务帐户,并将该服务帐户分配给我的谷歌云功能。
我不想使用环境变量或上传凭据以及源代码,但我想利用函数使用的默认服务帐户。
from googleapiclient.discovery import build
def get_credentials():
# if one knows credentials file location(when one uploads the json credentials file or specify them in environment variable) one can easily get the credentials by specify the path.
# In case of google cloud functions atleast I couldn't find it the path as the GOOGLE_APPLICATION_CREDENTIALS is empty in python runtime
# the below code work find if one uncomments the below line
#credentials = ServiceAccountCredentials.from_json_keyfile_name(key_file_location) …Run Code Online (Sandbox Code Playgroud) python service-accounts google-cloud-platform google-cloud-functions google-python-api
我正在使用 BigQuery Python API 创建表,并想为该表设置一个到期日期,以便该表会在特定天数后自动删除。
这是我的代码:
client = bq.Client()
job_config = bq.QueryJobConfig()
dataset_id = dataset
table_ref = client.dataset(dataset_id).table(filename)
job_config.destination = table_ref
job_config.write_disposition = 'WRITE_TRUNCATE'
dt = datetime.now() + timedelta(seconds=259200)
unixtime = (dt - datetime(1970,1,1)).total_seconds()
expiration_time = unixtime
job_config.expires = expiration_time
query_job = client.query(query, job_config=job_config)
query_job.result()
Run Code Online (Sandbox Code Playgroud)
问题是过期参数似乎不起作用。当我在用户界面中检查表详细信息时,到期日期仍然是“从不”。
我正在将 python 客户端库用于 Google Storage API,并且我有一个文件 pythonScript.py,其中包含以下内容:
# Imports the Google Cloud client library
from google.cloud import storage
# Instantiates a client
storage_client = storage.Client()
# The name for the new bucket
bucket_name = 'my-new-bucket'
# Creates the new bucket
bucket = storage_client.create_bucket(bucket_name)
print('Bucket {} created.'.format(bucket.name))
Run Code Online (Sandbox Code Playgroud)
当我尝试运行它时,我在终端中得到了这个:
回溯(最近一次调用):文件“pythonScript.py”,第 11 行,存储桶 = storage_client.create_bucket(bucket_name) 文件“/home/joel/MATI/env/lib/python3.5/site-packages/google/ cloud/storage/client.py”,第 218 行,在 create_bucket bucket.create(client=self) 文件中“/home/joel/MATI/env/lib/python3.5/site-packages/google/cloud/storage/bucket .py”,第 199 行,在 create data=properties, _target_object=self) 文件“/home/joel/MATI/env/lib/python3.5/site-packages/google/cloud/_http.py”,第 293 行,在 api_request 中引发 exceptions.from_http_response(response) google.cloud.exceptions.Conflict: 409 POST https://www.googleapis.com/storage/v1/b?project=avid-folder-180918:抱歉,该名称不可用. 请尝试不同的。
我不知道为什么,因为我确实为我的项目启用了 GSS API,而且默认配置似乎是正确的。的输出 …