ValueError: Bucket names must start and end with a number or letter
ValueError: Bucket names must start and end with a number or letter
我正在尝试将 SavedModel 格式的张量流模型从我的 google 云存储桶加载到我的云函数中。我正在使用本教程:https://cloud.google.com/blog/products/ai-machine-learning/how-to-serve-deep-learning-models-using-tensorflow-2-0-with-cloud-functions
云函数编译正确。但是,当我向云函数发送 http 请求时,它给出了这个错误:
回溯(最近调用最后):
文件“/env/local/lib/python3.7/site-packages/google/cloud/functions/worker_v2.py”,第 402 行,在 run_http_function 结果 = _function_handler.invoke_user_function(flask.request) 文件“/env/local/lib/python3.7/site-packages/google/cloud/functions/worker_v2.py”,第 268 行,在 invoke_user_function return call_user_function(request_or_event) 文件“/env/local/lib/python3 中。 7/site-packages/google/cloud/functions/worker_v2.py”,第 261 行,在 call_user_function return self._user_function(request_or_event) 文件“/user_code/main.py”,第 29 行, 在预测 download_blob('', 'firstModel/saved_model.pb', '/tmp/model/saved_model.pb') 文件“/user_code/main.py”, 第 17 行,在 download_blob bucket = storage_client.get_bucket(bucket_name) 文件“/env/local/lib/python3.7/site-packages/google/cloud/storage/client.py”,第 356 行,在 get_bucket 存储桶中 = self._bucket_arg_to_bucket(bucket_or_name) 文件“/env/local/lib/python3.7/site-packages/google/cloud/storage/client.py”,第 225 行,在 _bucket_arg_to_bucket bucket = Bucket(self, name=bucket_or_name) 文件“/env/local/lib/python3.7/site-packages/google/cloud/storage/bucket.py", 第 581 行,在 init name = _validate_name(name) File "/env/local/lib/python3.7/ site-packages/google/cloud/storage/_helpers.py", line 67, in _validate_name raise ValueError("Bucket names must start and end with a number or letter.") ValueError: Bucket names must start and end with数字或字母。
我很困惑,因为我的存储桶标题是一串大约 20 个字符长的字母,没有任何 punctuation/special 个字符。
这是我的部分代码 运行:
if model is None:
download_blob('<terminatorbucket>', 'firstModel/saved_model.pb', '/tmp/model/saved_model.pb')
download_blob('<terminatorbucket>', 'firstModel/assets/tokens.txt', '/tmp/model/assets/tokens.txt')
download_blob('<terminatorbucket>', 'firstModel/variables/variables.index', '/tmp/model/variables/variables.index')
download_blob('<terminatorbucket>', 'firstModel/variables/variables.data-00000-of-00001', '/tmp/model/variables/variables.data-00000-of-00001')
model = tf.keras.models.load_model('/tmp/model')
def download_blob(bucket_name, source_blob_name, destination_file_name):
"""Downloads a blob from the bucket."""
storage_client = storage.Client()
bucket = storage_client.get_bucket(bucket_name)
blob = bucket.blob(source_blob_name)
blob.download_to_filename(destination_file_name)
错误消息抱怨您的存储桶名称中有尖括号,不被视为数字或字母。确保您的存储桶名称与您在云控制台中看到的完全一致。
我正在尝试将 SavedModel 格式的张量流模型从我的 google 云存储桶加载到我的云函数中。我正在使用本教程:https://cloud.google.com/blog/products/ai-machine-learning/how-to-serve-deep-learning-models-using-tensorflow-2-0-with-cloud-functions
云函数编译正确。但是,当我向云函数发送 http 请求时,它给出了这个错误:
回溯(最近调用最后):
文件“/env/local/lib/python3.7/site-packages/google/cloud/functions/worker_v2.py”,第 402 行,在 run_http_function 结果 = _function_handler.invoke_user_function(flask.request) 文件“/env/local/lib/python3.7/site-packages/google/cloud/functions/worker_v2.py”,第 268 行,在 invoke_user_function return call_user_function(request_or_event) 文件“/env/local/lib/python3 中。 7/site-packages/google/cloud/functions/worker_v2.py”,第 261 行,在 call_user_function return self._user_function(request_or_event) 文件“/user_code/main.py”,第 29 行, 在预测 download_blob('', 'firstModel/saved_model.pb', '/tmp/model/saved_model.pb') 文件“/user_code/main.py”, 第 17 行,在 download_blob bucket = storage_client.get_bucket(bucket_name) 文件“/env/local/lib/python3.7/site-packages/google/cloud/storage/client.py”,第 356 行,在 get_bucket 存储桶中 = self._bucket_arg_to_bucket(bucket_or_name) 文件“/env/local/lib/python3.7/site-packages/google/cloud/storage/client.py”,第 225 行,在 _bucket_arg_to_bucket bucket = Bucket(self, name=bucket_or_name) 文件“/env/local/lib/python3.7/site-packages/google/cloud/storage/bucket.py", 第 581 行,在 init name = _validate_name(name) File "/env/local/lib/python3.7/ site-packages/google/cloud/storage/_helpers.py", line 67, in _validate_name raise ValueError("Bucket names must start and end with a number or letter.") ValueError: Bucket names must start and end with数字或字母。
我很困惑,因为我的存储桶标题是一串大约 20 个字符长的字母,没有任何 punctuation/special 个字符。
这是我的部分代码 运行:
if model is None:
download_blob('<terminatorbucket>', 'firstModel/saved_model.pb', '/tmp/model/saved_model.pb')
download_blob('<terminatorbucket>', 'firstModel/assets/tokens.txt', '/tmp/model/assets/tokens.txt')
download_blob('<terminatorbucket>', 'firstModel/variables/variables.index', '/tmp/model/variables/variables.index')
download_blob('<terminatorbucket>', 'firstModel/variables/variables.data-00000-of-00001', '/tmp/model/variables/variables.data-00000-of-00001')
model = tf.keras.models.load_model('/tmp/model')
def download_blob(bucket_name, source_blob_name, destination_file_name):
"""Downloads a blob from the bucket."""
storage_client = storage.Client()
bucket = storage_client.get_bucket(bucket_name)
blob = bucket.blob(source_blob_name)
blob.download_to_filename(destination_file_name)
错误消息抱怨您的存储桶名称中有尖括号,不被视为数字或字母。确保您的存储桶名称与您在云控制台中看到的完全一致。