@@ -35,12 +35,16 @@ def create_run(self, data):
35
35
"""
36
36
Create a run
37
37
"""
38
+ logger .debug ('Creating run with data: "%s"' , data )
39
+
38
40
try :
39
41
response = post (f"{ self ._url } /api/runs" , self ._headers , data )
40
42
except Exception as err :
41
43
self ._error (f"Exception creating run: { str (err )} " )
42
44
return False
43
45
46
+ logger .debug ('Got status code %d when creating run, with response: "%s"' , response .status_code , response .text )
47
+
44
48
if response .status_code == 409 :
45
49
self ._error (f"Duplicate run, name { data ['name' ]} already exists" )
46
50
elif response .status_code != 200 :
@@ -59,12 +63,16 @@ def update(self, data, run=None):
59
63
if run is not None :
60
64
data ['name' ] = run
61
65
66
+ logger .debug ('Updating run with data: "%s"' , data )
67
+
62
68
try :
63
69
response = put (f"{ self ._url } /api/runs" , self ._headers , data )
64
70
except Exception as err :
65
71
self ._error (f"Exception creating updating run: { str (err )} " )
66
72
return False
67
73
74
+ logger .debug ('Got status code %d when updating run, with response: "%s"' , response .status_code , response .text )
75
+
68
76
if response .status_code == 200 :
69
77
return True
70
78
@@ -78,12 +86,16 @@ def set_folder_details(self, data, run=None):
78
86
if run is not None :
79
87
data ['run' ] = run
80
88
89
+ logger .debug ('Setting folder details with data: "%s"' , data )
90
+
81
91
try :
82
92
response = put (f"{ self ._url } /api/folders" , self ._headers , data )
83
93
except Exception as err :
84
94
self ._error (f"Exception setting folder details: { err } " )
85
95
return False
86
96
97
+ logger .debug ('Got status code %d when setting folder details, with response: "%s"' , response .status_code , response .text )
98
+
87
99
if response .status_code == 200 :
88
100
return True
89
101
@@ -97,13 +109,17 @@ def save_file(self, data, run=None):
97
109
if run is not None :
98
110
data ['run' ] = run
99
111
112
+ logger .debug ('Getting presigned URL for saving artifact, with data: "%s"' , data )
113
+
100
114
# Get presigned URL
101
115
try :
102
116
response = post (f"{ self ._url } /api/data" , self ._headers , prepare_for_api (data ))
103
117
except Exception as err :
104
118
self ._error (f"Got exception when preparing to upload file { data ['name' ]} to object storage: { str (err )} " )
105
119
return False
106
120
121
+ logger .debug ('Got status code %d when getting presigned URL, with response: "%s"' , response .status_code , response .text )
122
+
107
123
if response .status_code == 409 :
108
124
return True
109
125
@@ -116,6 +132,9 @@ def save_file(self, data, run=None):
116
132
if 'pickled' in data and 'pickledFile' not in data :
117
133
try :
118
134
response = put (url , {}, data ['pickled' ], is_json = False , timeout = UPLOAD_TIMEOUT )
135
+
136
+ logger .debug ('Got status code %d when uploading artifact' , response .status_code )
137
+
119
138
if response .status_code != 200 :
120
139
self ._error (f"Got status code { response .status_code } when uploading object { data ['name' ]} to object storage" )
121
140
return None
@@ -131,6 +150,9 @@ def save_file(self, data, run=None):
131
150
try :
132
151
with open (use_filename , 'rb' ) as fh :
133
152
response = put (url , {}, fh , is_json = False , timeout = UPLOAD_TIMEOUT )
153
+
154
+ logger .debug ('Got status code %d when uploading artifact' , response .status_code )
155
+
134
156
if response .status_code != 200 :
135
157
self ._error (f"Got status code { response .status_code } when uploading file { data ['name' ]} to object storage" )
136
158
return None
@@ -147,12 +169,16 @@ def add_alert(self, data, run=None):
147
169
if run is not None :
148
170
data ['run' ] = run
149
171
172
+ logger .debug ('Adding alert with data: "%s"' , data )
173
+
150
174
try :
151
175
response = post (f"{ self ._url } /api/alerts" , self ._headers , data )
152
176
except Exception as err :
153
177
self ._error (f"Got exception when creating an alert: { str (err )} " )
154
178
return False
155
179
180
+ logger .debug ('Got response %d when adding alert, with response: "%s"' , response .status_code , response .text )
181
+
156
182
if response .status_code in (200 , 409 ):
157
183
return True
158
184
@@ -163,12 +189,16 @@ def send_metrics(self, data):
163
189
"""
164
190
Send metrics
165
191
"""
192
+ logger .debug ('Sending metrics' )
193
+
166
194
try :
167
195
response = post (f"{ self ._url } /api/metrics" , self ._headers_mp , data , is_json = False )
168
196
except Exception as err :
169
197
self ._error (f"Exception sending metrics: { str (err )} " )
170
198
return False
171
199
200
+ logger .debug ('Got status code %d when sending metrics' , response .status_code )
201
+
172
202
if response .status_code == 200 :
173
203
return True
174
204
@@ -179,12 +209,16 @@ def send_event(self, data):
179
209
"""
180
210
Send events
181
211
"""
212
+ logger .debug ('Sending events' )
213
+
182
214
try :
183
215
response = post (f"{ self ._url } /api/events" , self ._headers_mp , data , is_json = False )
184
216
except Exception as err :
185
217
self ._error (f"Exception sending event: { str (err )} " )
186
218
return False
187
219
220
+ logger .debug ('Got status code %d when sending events' , response .status_code )
221
+
188
222
if response .status_code == 200 :
189
223
return True
190
224
@@ -195,12 +229,16 @@ def send_heartbeat(self):
195
229
"""
196
230
Send heartbeat
197
231
"""
232
+ logger .debug ('Sending heartbeat' )
233
+
198
234
try :
199
235
response = put (f"{ self ._url } /api/runs/heartbeat" , self ._headers , {'name' : self ._name })
200
236
except Exception as err :
201
237
self ._error (f"Exception creating run: { str (err )} " )
202
238
return False
203
239
240
+ logger .debug ('Got status code %d when sending heartbeat' , response .status_code )
241
+
204
242
if response .status_code == 200 :
205
243
return True
206
244
0 commit comments