我正在尝试调整 Amazon SageMaker 上的开源项目 mmfashion,该项目需要 CEPH 模块作为后端。不幸的是
pip install ceph
不起作用。唯一的解决方法是通过在我的容器中运行来手动构建 ceph 源代码:
!git clone git://github.com/ceph/ceph
!git submodule update --init --recursive
这确实允许我成功导入
ceph
。但当涉及到来自 Amazon S3 的数据时,它会抛出以下错误:
AttributeError: module 'ceph' has no attribute 'S3Client'
是否有人将 CEPH 与 Amazon S3 Bucket 集成,或者在同一行中就如何解决这个问题提出了建议?
您可以使用 ceph S3 api 连接到 AWS 存储桶,这是连接到任何 S3 api 的简单 python 示例脚本:
import boto
import boto.s3.connection
access_key = 'put your access key here!'
secret_key = 'put your secret key here!'
conn = boto.connect_s3(
aws_access_key_id = access_key,
aws_secret_access_key = secret_key,
host = 'objects.dreamhost.com',
#is_secure=False, # uncomment if you are not using ssl
calling_format = boto.s3.connection.OrdinaryCallingFormat(),
)
然后您将能够列出存储桶:
for bucket in conn.get_all_buckets():
print "{name}\t{created}".format(
name = bucket.name,
created = bucket.creation_date,
)