edsl 0.1.51__py3-none-any.whl → 0.1.52__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,5 +5,6 @@ class JobsStatus(Enum):
5
5
  QUEUED = "queued"
6
6
  RUNNING = "running"
7
7
  COMPLETED = "completed"
8
+ PARTIALLY_FAILED = "partially_failed"
8
9
  FAILED = "failed"
9
10
  CANCELLED = "cancelled"
@@ -113,7 +113,7 @@ class JobsRemoteInferenceHandler:
113
113
  logger.add_info("job_uuid", job_uuid)
114
114
 
115
115
  logger.update(
116
- f"Job details are available at your Coop account {self.remote_inference_url}",
116
+ f"Job details are available at your Coop account. [Go to Remote Inference page]({self.remote_inference_url})",
117
117
  status=JobsStatus.RUNNING,
118
118
  )
119
119
  progress_bar_url = (
@@ -121,7 +121,7 @@ class JobsRemoteInferenceHandler:
121
121
  )
122
122
  logger.add_info("progress_bar_url", progress_bar_url)
123
123
  logger.update(
124
- f"View job progress here: {progress_bar_url}", status=JobsStatus.RUNNING
124
+ f"View job progress [here]({progress_bar_url})", status=JobsStatus.RUNNING
125
125
  )
126
126
 
127
127
  return RemoteJobInfo(
@@ -169,7 +169,7 @@ class JobsRemoteInferenceHandler:
169
169
  message="Job cancelled by the user.", status=JobsStatus.CANCELLED
170
170
  )
171
171
  job_info.logger.update(
172
- f"See {self.expected_parrot_url}/home/remote-inference for more details.",
172
+ f"See [Remote Inference page]({self.expected_parrot_url}/home/remote-inference) for more details.",
173
173
  status=JobsStatus.CANCELLED,
174
174
  )
175
175
 
@@ -182,22 +182,45 @@ class JobsRemoteInferenceHandler:
182
182
  reason = remote_job_data.get("reason")
183
183
 
184
184
  if reason == "insufficient funds":
185
- latest_error_report_url = "Error: Insufficient balance to start the job"
186
- print("Error: Insufficient balance to start the job")
185
+ job_info.logger.update(
186
+ f"Error: Insufficient balance to start the job. Add funds to your account at the [Credits page]({self.expected_parrot_url}/home/credits)",
187
+ status=JobsStatus.FAILED,
188
+ )
187
189
 
188
190
  if latest_error_report_url:
189
191
  job_info.logger.add_info("error_report_url", latest_error_report_url)
190
192
 
191
193
  job_info.logger.update("Job failed.", status=JobsStatus.FAILED)
192
194
  job_info.logger.update(
193
- f"See {self.expected_parrot_url}/home/remote-inference for more details.",
195
+ f"See [Remote Inference page]({self.expected_parrot_url}/home/remote-inference) for more details.",
194
196
  status=JobsStatus.FAILED,
195
197
  )
196
198
  job_info.logger.update(
197
- f"Need support? Visit Discord: {RemoteJobConstants.DISCORD_URL}",
199
+ f"Need support? [Visit Discord]({RemoteJobConstants.DISCORD_URL})",
198
200
  status=JobsStatus.FAILED,
199
201
  )
200
202
 
203
+ def _handle_partially_failed_job(
204
+ self, job_info: RemoteJobInfo, remote_job_data: RemoteInferenceResponse
205
+ ) -> None:
206
+ "Handles a partially failed job by logging the error and updating the job status."
207
+ latest_error_report_url = remote_job_data.get("latest_error_report_url")
208
+
209
+ if latest_error_report_url:
210
+ job_info.logger.add_info("error_report_url", latest_error_report_url)
211
+
212
+ job_info.logger.update(
213
+ "Job completed with partial results.", status=JobsStatus.PARTIALLY_FAILED
214
+ )
215
+ job_info.logger.update(
216
+ f"See [Remote Inference page]({self.expected_parrot_url}/home/remote-inference) for more details.",
217
+ status=JobsStatus.PARTIALLY_FAILED,
218
+ )
219
+ job_info.logger.update(
220
+ f"Need support? [Visit Discord]({RemoteJobConstants.DISCORD_URL})",
221
+ status=JobsStatus.PARTIALLY_FAILED,
222
+ )
223
+
201
224
  def _sleep_for_a_bit(self, job_info: RemoteJobInfo, status: str) -> None:
202
225
  import time
203
226
  from datetime import datetime
@@ -212,6 +235,7 @@ class JobsRemoteInferenceHandler:
212
235
  def _fetch_results_and_log(
213
236
  self,
214
237
  job_info: RemoteJobInfo,
238
+ job_status: Literal["failed", "partial_failed", "completed"],
215
239
  results_uuid: str,
216
240
  remote_job_data: RemoteInferenceResponse,
217
241
  object_fetcher: Callable,
@@ -221,10 +245,17 @@ class JobsRemoteInferenceHandler:
221
245
  results = object_fetcher(results_uuid, expected_object_type="results")
222
246
  results_url = remote_job_data.get("results_url")
223
247
  job_info.logger.add_info("results_url", results_url)
224
- job_info.logger.update(
225
- f"Job completed and Results stored on Coop: {results_url}",
226
- status=JobsStatus.COMPLETED,
227
- )
248
+
249
+ if job_status == "completed":
250
+ job_info.logger.update(
251
+ f"Job completed and Results stored on Coop. [View Results]({results_url})",
252
+ status=JobsStatus.COMPLETED,
253
+ )
254
+ elif job_status == "partial_failed":
255
+ job_info.logger.update(
256
+ f"View partial results [here]({results_url})",
257
+ status=JobsStatus.PARTIALLY_FAILED,
258
+ )
228
259
  results.job_uuid = job_info.job_uuid
229
260
  results.results_uuid = results_uuid
230
261
  return results
@@ -244,13 +275,16 @@ class JobsRemoteInferenceHandler:
244
275
  return None, reason
245
276
 
246
277
  elif status == "failed" or status == "completed" or status == "partial_failed":
247
- if status == "failed" or status == "partial_failed":
278
+ if status == "failed":
248
279
  self._handle_failed_job(job_info, remote_job_data)
280
+ elif status == "partial_failed":
281
+ self._handle_partially_failed_job(job_info, remote_job_data)
249
282
 
250
283
  results_uuid = remote_job_data.get("results_uuid")
251
284
  if results_uuid:
252
285
  results = self._fetch_results_and_log(
253
286
  job_info=job_info,
287
+ job_status=status,
254
288
  results_uuid=results_uuid,
255
289
  remote_job_data=remote_job_data,
256
290
  object_fetcher=object_fetcher,