-
Notifications
You must be signed in to change notification settings - Fork 88
/
create_bucket.py
38 lines (28 loc) · 1.12 KB
/
create_bucket.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
from minio import Minio
from minio.error import InvalidResponseError
accessID = os.environ.get('AWS_ACCESS_KEY_ID')
accessSecret = os.environ.get('AWS_SECRET_ACCESS_KEY')
minioUrl = os.environ.get('MLFLOW_S3_ENDPOINT_URL')
bucketName = os.environ.get('AWS_BUCKET_NAME')
if accessID == None:
print('[!] AWS_ACCESS_KEY_ID environment variable is empty! run \'source .env\' to load it from the .env file')
exit(1)
if accessSecret == None:
print('[!] AWS_SECRET_ACCESS_KEY environment variable is empty! run \'source .env\' to load it from the .env file')
exit(1)
if minioUrl == None:
print('[!] MLFLOW_S3_ENDPOINT_URL environment variable is empty! run \'source .env\' to load it from the .env file')
exit(1)
if bucketName == None:
print('[!] AWS_BUCKET_NAME environment variable is empty! run \'source .env\' to load it from the .env file')
exit(1)
minioUrlHostWithPort = minioUrl.split('//')[1]
print('[*] minio url: ',minioUrlHostWithPort)
s3Client = Minio(
minioUrlHostWithPort,
access_key=accessID,
secret_key=accessSecret,
secure=False
)
s3Client.make_bucket(bucketName)