Skip to content
This repository was archived by the owner on Mar 17, 2024. It is now read-only.

Commit dbd4e0d

Browse files
committed
Temp fix for connecting to minio
1 parent ab51804 commit dbd4e0d

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

components/studio/models/helpers.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,13 @@ def create_client(S3_storage, secure_mode=True):
103103
def set_artifact(artifact_name, artifact_file, bucket, S3_storage, is_file=False, secure_mode=True):
104104
""" Instance must be a byte-like object. """
105105
client = create_client(S3_storage, secure_mode)
106-
found = client.bucket_exists(bucket)
106+
107+
try:
108+
found = client.bucket_exists(bucket)
109+
except Exception as err:
110+
print('EXCEPTION LOG: Client could not verify if bucket exists')
111+
return False
112+
107113
if not found:
108114
try:
109115
client.make_bucket(bucket)
@@ -112,11 +118,16 @@ def set_artifact(artifact_name, artifact_file, bucket, S3_storage, is_file=False
112118
return False
113119

114120
if is_file == True:
115-
client.fput_object(bucket, artifact_name, artifact_file)
121+
try:
122+
client.fput_object(bucket, artifact_name, artifact_file)
123+
except Exception as e:
124+
print('Client method fput_object failed')
125+
return False
116126
else:
117127
try:
118128
client.put_object(bucket, artifact_name, io.BytesIO(artifact_file), len(artifact_file))
119129
except Exception as e:
120-
raise Exception("Could not load data into bytes {}".format(e))
130+
print('Client method put_object failed')
131+
return False
121132

122133
return True

components/studio/models/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ def post(self, request, user, project):
146146
status = set_artifact(artifact_name, model_file, model_folder_name, model_S3, is_file=is_file, secure_mode=secure_mode)
147147

148148
if not status:
149-
print("Failed to upload model to S3 storage")
150-
return False # We should show the error and redirect somewhere else
149+
messages.error(request, 'Oops, something went wrong: failed to upload model to S3 storage!')
150+
return redirect(redirect_url)
151151

152152
new_model = Model(uid=artifact_name,
153153
name=model_name,

0 commit comments

Comments
 (0)