google ml-engine云存储为文件
google ml-engine cloud storage as a file
我在 Python 使用 Google Cloud ML-Engine 工作。我找到的文档表明数据存储应该使用 Buckets 和 Blob
https://cloud.google.com/ml-engine/docs/tensorflow/working-with-cloud-storage
但是,我的大部分代码以及它调用的库都适用于文件。我可以在我的 ml-engine 代码中以某种方式将 Google 存储视为文件系统吗?
我希望我的代码读起来像
with open(<something>) as f:
for line in f:
dosomething(line)
请注意,在 ml-engine 中,不会创建和配置 VM 实例。所以我不能用 Filestore 挂载我自己的共享文件系统。
让云存储显示为文件系统的唯一方法是 mount a bucket as a file system:
You can use the Google Cloud Storage FUSE tool to mount a Cloud
Storage bucket to your Compute Engine instance. The mounted bucket
behaves similarly to a persistent disk even though Cloud Storage
buckets are object storage.
但如果您不能创建和配置 VM,则无法执行此操作。
Note that in ml-engine one does not create and configure VM instances.
这不完全正确。我看到 ML 引擎支持 building custom containers,这通常是安装和配置 OS 级依赖项的方式。但仅限于培训领域,所以如果你的需求在那个领域,可能值得一试。
我假设您已经检查过该库不支持通过已经打开的类似文件的处理程序进行访问(如果不支持,那么可能感兴趣的是 )
对于后来者,这里是答案
from tensorflow.python.lib.io import file_io
这是一个例子
with file_io.FileIO("gc://bucket_name/foobar.txt","w") as f:
f.write("FOO")
f.flush()
print("Write foobar.txt")
with file_io.FileIO("gc://bucket_name/foobar.txt","r") as f:
for line in f:
print("Read foobar.txt: "+line)
我在 Python 使用 Google Cloud ML-Engine 工作。我找到的文档表明数据存储应该使用 Buckets 和 Blob
https://cloud.google.com/ml-engine/docs/tensorflow/working-with-cloud-storage
但是,我的大部分代码以及它调用的库都适用于文件。我可以在我的 ml-engine 代码中以某种方式将 Google 存储视为文件系统吗?
我希望我的代码读起来像
with open(<something>) as f:
for line in f:
dosomething(line)
请注意,在 ml-engine 中,不会创建和配置 VM 实例。所以我不能用 Filestore 挂载我自己的共享文件系统。
让云存储显示为文件系统的唯一方法是 mount a bucket as a file system:
You can use the Google Cloud Storage FUSE tool to mount a Cloud Storage bucket to your Compute Engine instance. The mounted bucket behaves similarly to a persistent disk even though Cloud Storage buckets are object storage.
但如果您不能创建和配置 VM,则无法执行此操作。
Note that in ml-engine one does not create and configure VM instances.
这不完全正确。我看到 ML 引擎支持 building custom containers,这通常是安装和配置 OS 级依赖项的方式。但仅限于培训领域,所以如果你的需求在那个领域,可能值得一试。
我假设您已经检查过该库不支持通过已经打开的类似文件的处理程序进行访问(如果不支持,那么可能感兴趣的是
对于后来者,这里是答案
from tensorflow.python.lib.io import file_io
这是一个例子
with file_io.FileIO("gc://bucket_name/foobar.txt","w") as f:
f.write("FOO")
f.flush()
print("Write foobar.txt")
with file_io.FileIO("gc://bucket_name/foobar.txt","r") as f:
for line in f:
print("Read foobar.txt: "+line)