Created
September 8, 2020 14:21
-
-
Save kaushalvivek/9f1905e25a28526dfeaaecf80ef5c361 to your computer and use it in GitHub Desktop.
Based on @SeanPLeary's python notebook to do the same. Link : https://github.com/SeanPLeary/mlflow-minio-h2o-example/blob/master/minio_create_bucket.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from minio import Minio | |
from minio.error import ResponseError | |
import json | |
import os | |
minioClient = Minio(os.environ['MLFLOW_S3_ENDPOINT_URL'].split('//')[1], | |
access_key=os.environ['AWS_ACCESS_KEY_ID'], | |
secret_key=os.environ['AWS_SECRET_ACCESS_KEY'], | |
secure=False) | |
minioClient.list_buckets() | |
try: | |
minioClient.make_bucket('mlflow') | |
except ResponseError as err: | |
print(err) | |
buckets = minioClient.list_buckets() | |
for bucket in buckets: | |
print(bucket.name, bucket.creation_date) | |
policy = {"Version":"2012-10-17", | |
"Statement":[ | |
{ | |
"Sid":"", | |
"Effect":"Allow", | |
"Principal":{"AWS":"*"}, | |
"Action":"s3:GetBucketLocation", | |
"Resource":"arn:aws:s3:::mlflow" | |
}, | |
{ | |
"Sid":"", | |
"Effect":"Allow", | |
"Principal":{"AWS":"*"}, | |
"Action":"s3:ListBucket", | |
"Resource":"arn:aws:s3:::mlflow" | |
}, | |
{ | |
"Sid":"", | |
"Effect":"Allow", | |
"Principal":{"AWS":"*"}, | |
"Action":"s3:GetObject", | |
"Resource":"arn:aws:s3:::mlflow/*" | |
}, | |
{ | |
"Sid":"", | |
"Effect":"Allow", | |
"Principal":{"AWS":"*"}, | |
"Action":"s3:PutObject", | |
"Resource":"arn:aws:s3:::mlflow/*" | |
} | |
]} | |
minioClient.set_bucket_policy('mlflow', json.dumps(policy)) | |
# List all object paths in bucket that begin with my-prefixname. | |
objects = minioClient.list_objects('mlflow', prefix='my', | |
recursive=True) | |
for obj in objects: | |
print(obj.bucket_name, obj.object_name.encode('utf-8'), obj.last_modified, | |
obj.etag, obj.size, obj.content_type) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment