added buckets exist check
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
"""Definition of connect function."""
|
"""Definition of connect function."""
|
||||||
|
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
from typing import Literal
|
from typing import Literal
|
||||||
|
|
||||||
@@ -38,7 +39,14 @@ def connect(
|
|||||||
secret_key=minio_secret_key,
|
secret_key=minio_secret_key,
|
||||||
secure=False,
|
secure=False,
|
||||||
)
|
)
|
||||||
# ensure bucket exists
|
# ensure buckets exists
|
||||||
if not client.bucket_exists(bucket_name=minio_bucket_name):
|
bucket_list = [
|
||||||
client.make_bucket(bucket_name=minio_bucket_name)
|
'images',
|
||||||
|
'models',
|
||||||
|
]
|
||||||
|
for bucket_name in bucket_list:
|
||||||
|
if not client.bucket_exists(bucket_name=bucket_name):
|
||||||
|
logging.info('creating bucket: %s', bucket_name)
|
||||||
|
client.make_bucket(bucket_name=minio_bucket_name)
|
||||||
|
logging.debug('finished')
|
||||||
return client
|
return client
|
||||||
|
|||||||
Reference in New Issue
Block a user