@@ -85,12 +85,16 @@ def list_artifacts(self, run, category=None):
85
85
params = {'run' : run }
86
86
87
87
response = requests .get (f"{ self ._url } /api/artifacts" , headers = self ._headers , params = params )
88
- response .raise_for_status ()
88
+
89
+ if response .status_code == 404 :
90
+ if 'detail' in response .json ():
91
+ if response .json ()['detail' ] == 'run does not exist' :
92
+ raise Exception ('Run does not exist' )
89
93
90
94
if response .status_code == 200 :
91
95
return response .json ()
92
96
93
- return None
97
+ raise Exception ( response . text )
94
98
95
99
def get_artifact (self , run , name , allow_pickle = False ):
96
100
"""
@@ -99,7 +103,13 @@ def get_artifact(self, run, name, allow_pickle=False):
99
103
params = {'run' : run , 'name' : name }
100
104
101
105
response = requests .get (f"{ self ._url } /api/artifacts" , headers = self ._headers , params = params )
102
- response .raise_for_status ()
106
+
107
+ if response .status_code == 404 :
108
+ if 'detail' in response .json ():
109
+ if response .json ()['detail' ] == 'run does not exist' :
110
+ raise Exception ('Run does not exist' )
111
+ elif response .json ()['detail' ] == 'artifact does not exist' :
112
+ raise Exception ('Artifact does not exist' )
103
113
104
114
if response .status_code != 200 :
105
115
return None
@@ -123,7 +133,13 @@ def get_artifact_as_file(self, run, name, path='./'):
123
133
params = {'run' : run , 'name' : name }
124
134
125
135
response = requests .get (f"{ self ._url } /api/artifacts" , headers = self ._headers , params = params )
126
- response .raise_for_status ()
136
+
137
+ if response .status_code == 404 :
138
+ if 'detail' in response .json ():
139
+ if response .json ()['detail' ] == 'run does not exist' :
140
+ raise Exception ('Run does not exist' )
141
+ elif response .json ()['detail' ] == 'artifact does not exist' :
142
+ raise Exception ('Artifact does not exist' )
127
143
128
144
if response .status_code == 200 :
129
145
if response .json ():
@@ -132,6 +148,9 @@ def get_artifact_as_file(self, run, name, path='./'):
132
148
'filename' : os .path .basename (name ),
133
149
'path' : path })
134
150
151
+ else :
152
+ raise Exception (response .text )
153
+
135
154
def get_artifacts_as_files (self ,
136
155
run ,
137
156
path = None ,
@@ -147,7 +166,11 @@ def get_artifacts_as_files(self,
147
166
params ['category' ] = category
148
167
149
168
response = requests .get (f"{ self ._url } /api/artifacts" , headers = self ._headers , params = params )
150
- response .raise_for_status ()
169
+
170
+ if response .status_code == 404 :
171
+ if 'detail' in response .json ():
172
+ if response .json ()['detail' ] == 'run does not exist' :
173
+ raise Exception ('Run does not exist' )
151
174
152
175
if not path :
153
176
path = './'
@@ -182,3 +205,6 @@ def get_artifacts_as_files(self,
182
205
with ProcessPoolExecutor (CONCURRENT_DOWNLOADS ) as executor :
183
206
for item in downloads :
184
207
executor .submit (downloader , item )
208
+
209
+ else :
210
+ raise Exception (response .text )
0 commit comments