aind-codeocean-dispatch 0.3.0__tar.gz → 0.4.0__tar.gz

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.
Files changed (28) hide show
  1. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/CHANGELOG.md +6 -0
  2. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/PKG-INFO +1 -1
  3. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/pyproject.toml +1 -1
  4. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/src/aind_codeocean_dispatch/__init__.py +4 -0
  5. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/src/aind_codeocean_dispatch/runner.py +79 -12
  6. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/tests/fakes.py +8 -0
  7. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/tests/test_runner.py +83 -0
  8. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/uv.lock +1 -1
  9. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/.copier-answers.yml +0 -0
  10. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  11. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  12. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/.github/ISSUE_TEMPLATE/user-story.md +0 -0
  13. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/.github/dependabot.yml +0 -0
  14. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/.github/workflows/bump-call.yml +0 -0
  15. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/.github/workflows/ci-call.yml +0 -0
  16. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/.github/workflows/publish-call.yml +0 -0
  17. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/.gitignore +0 -0
  18. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/.python-version +0 -0
  19. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/CLAUDE.md +0 -0
  20. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/LICENSE +0 -0
  21. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/README.md +0 -0
  22. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/scripts/run_linters_and_checks.sh +0 -0
  23. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/src/aind_codeocean_dispatch/capsule_git.py +0 -0
  24. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/src/aind_codeocean_dispatch/capture.py +0 -0
  25. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/src/aind_codeocean_dispatch/py.typed +0 -0
  26. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/tests/__init__.py +0 -0
  27. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/tests/test_capsule_git.py +0 -0
  28. {aind_codeocean_dispatch-0.3.0 → aind_codeocean_dispatch-0.4.0}/tests/test_capture.py +0 -0
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## v0.4.0 (2026-10-15)
9
+
10
+ ### Feat
11
+
12
+ - classify failures and optionally cancel the batch on one
13
+
8
14
  ## v0.3.0 (2026-10-15)
9
15
 
10
16
  ### Feat
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: aind-codeocean-dispatch
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: Launch, monitor, and capture batches of Code Ocean capsule runs
5
5
  Project-URL: Repository, https://github.com/AllenNeuralDynamics/aind-codeocean-dispatch/
6
6
  Project-URL: Issues, https://github.com/AllenNeuralDynamics/aind-codeocean-dispatch/issues
@@ -13,7 +13,7 @@ authors = [
13
13
  ]
14
14
  classifiers = ["Programming Language :: Python :: 3"]
15
15
  readme = "README.md"
16
- version = "0.3.0"
16
+ version = "0.4.0"
17
17
 
18
18
  dependencies = [
19
19
  "aind-code-ocean-pipeline-utils>=0.7.1",
@@ -5,8 +5,10 @@ from importlib.metadata import PackageNotFoundError, version
5
5
  from .capsule_git import capsule_head_commit, head_commit, run_owner_email
6
6
  from .capture import capture_as, capture_named_by_data_description, derived_name
7
7
  from .runner import (
8
+ TRANSIENT_FAILURES,
8
9
  DispatchFailed,
9
10
  DispatchInterrupted,
11
+ Failure,
10
12
  Job,
11
13
  Outcome,
12
14
  failed_without_results,
@@ -18,8 +20,10 @@ from .runner import (
18
20
  )
19
21
 
20
22
  __all__ = [
23
+ "TRANSIENT_FAILURES",
21
24
  "DispatchFailed",
22
25
  "DispatchInterrupted",
26
+ "Failure",
23
27
  "Job",
24
28
  "Outcome",
25
29
  "capsule_head_commit",
@@ -47,8 +47,10 @@ if TYPE_CHECKING:
47
47
  from codeocean import CodeOcean
48
48
 
49
49
  __all__ = [
50
+ "TRANSIENT_FAILURES",
50
51
  "DispatchFailed",
51
52
  "DispatchInterrupted",
53
+ "Failure",
52
54
  "Job",
53
55
  "Outcome",
54
56
  "failed_without_results",
@@ -75,7 +77,15 @@ _TRANSIENT_SERVER = frozenset({500, 502, 503, 504})
75
77
  _KEY_PATTERN = re.compile(r"[A-Za-z0-9_.-]{1,64}")
76
78
  _KEY_TAG_PREFIX = "dispatch-"
77
79
 
78
- Status = Literal["captured", "completed", "reused", "failed"]
80
+ Status = Literal["captured", "completed", "reused", "failed", "cancelled"]
81
+ #: Why a job failed. ``failed_start`` means the relaunch budget ran out;
82
+ #: ``computation`` that it ran and failed; ``api_rejected`` a 4xx other than 429;
83
+ #: ``api_unavailable`` a 5xx or connection error on a call that cannot be retried.
84
+ Failure = Literal[
85
+ "failed_start", "computation", "timeout", "capture", "capture_callback", "api_rejected", "api_unavailable"
86
+ ]
87
+ #: Failures on the platform's side, which a rerun of the same job can get past.
88
+ TRANSIENT_FAILURES: frozenset[Failure] = frozenset({"failed_start", "capture", "api_unavailable"})
79
89
  _T = TypeVar("_T")
80
90
 
81
91
 
@@ -114,7 +124,8 @@ class Outcome:
114
124
  """How one job ended.
115
125
 
116
126
  ``computation_ids`` lists every launch attempt in order, so a relaunched job's
117
- failed starts stay traceable.
127
+ failed starts stay traceable. ``failure`` is set only when ``status`` is
128
+ ``"failed"``.
118
129
  """
119
130
 
120
131
  job: Job
@@ -122,11 +133,17 @@ class Outcome:
122
133
  asset_id: str | None = None
123
134
  computation_ids: tuple[str, ...] = ()
124
135
  error: str | None = None
136
+ failure: Failure | None = None
125
137
 
126
138
  @property
127
139
  def ok(self) -> bool:
128
140
  """Whether the job produced what was asked of it."""
129
- return self.status != "failed"
141
+ return self.status not in ("failed", "cancelled")
142
+
143
+ @property
144
+ def transient(self) -> bool:
145
+ """Whether the job failed for a platform reason a rerun can get past."""
146
+ return self.failure in TRANSIENT_FAILURES
130
147
 
131
148
 
132
149
  class DispatchFailed(RuntimeError):
@@ -229,11 +246,12 @@ def run_jobs(
229
246
  reuse: bool = False,
230
247
  poll_interval_s: float = 60.0,
231
248
  timeout_s: float | None = None,
249
+ cancel_on_failure: bool | Callable[[Outcome], bool] = False,
232
250
  ) -> list[Outcome]:
233
251
  """Launch *jobs*, wait for each, capture its results, and report every outcome.
234
252
 
235
- A job's failure never stops the others or raises; check the outcomes, or pass them
236
- to :func:`raise_for_failures`.
253
+ A job's failure never raises; check the outcomes, or pass them to
254
+ :func:`raise_for_failures`.
237
255
 
238
256
  Parameters
239
257
  ----------
@@ -266,6 +284,10 @@ def run_jobs(
266
284
  timeout_s : float, optional
267
285
  Give up waiting on an attempt after this long. The computation is left
268
286
  running, not stopped. ``None`` waits indefinitely.
287
+ cancel_on_failure : bool or callable, optional
288
+ Whether a failed job cancels the rest, or a predicate on its outcome. On
289
+ cancel, pending jobs are not launched and running computations are stopped
290
+ and deleted, all ending ``"cancelled"``; captures already under way finish.
269
291
 
270
292
  Returns
271
293
  -------
@@ -299,6 +321,7 @@ def run_jobs(
299
321
  reuse=reuse,
300
322
  poll_interval_s=poll_interval_s,
301
323
  timeout_s=timeout_s,
324
+ cancel_on_failure=cancel_on_failure,
302
325
  ).run()
303
326
 
304
327
 
@@ -417,6 +440,7 @@ class _Dispatcher:
417
440
  reuse: bool,
418
441
  poll_interval_s: float,
419
442
  timeout_s: float | None,
443
+ cancel_on_failure: bool | Callable[[Outcome], bool],
420
444
  ) -> None:
421
445
  self.client = client
422
446
  self.slots = [_Slot(job) for job in jobs]
@@ -429,6 +453,8 @@ class _Dispatcher:
429
453
  self.reuse = reuse
430
454
  self.poll_interval_s = poll_interval_s
431
455
  self.timeout_s = timeout_s
456
+ self.cancel_on_failure = cancel_on_failure
457
+ self.cancelled_by: str | None = None
432
458
  self.next_launch_at = 0.0
433
459
 
434
460
  def run(self) -> list[Outcome]:
@@ -477,7 +503,7 @@ class _Dispatcher:
477
503
  return
478
504
  _sleep(min(_MAX_SLEEP_S, min(due) - now))
479
505
 
480
- def _finish(self, slot: _Slot, status: Status, *, error: str | None = None) -> None:
506
+ def _finish(self, slot: _Slot, status: Status, *, error: str | None = None, failure: Failure | None = None) -> None:
481
507
  slot.phase = _Phase.DONE
482
508
  slot.outcome = Outcome(
483
509
  job=slot.job,
@@ -485,11 +511,36 @@ class _Dispatcher:
485
511
  asset_id=slot.asset_id,
486
512
  computation_ids=tuple(slot.computation_ids),
487
513
  error=error,
514
+ failure=failure,
488
515
  )
489
516
  if error is None:
490
517
  logger.info("%s: %s", slot.job.label, status)
491
518
  else:
492
- logger.error("%s: failed: %s", slot.job.label, error)
519
+ logger.error("%s: %s: %s", slot.job.label, status, error)
520
+ if status == "failed" and self.cancelled_by is None and self._should_cancel(slot.outcome):
521
+ self._cancel_rest(slot.job.label)
522
+
523
+ def _should_cancel(self, outcome: Outcome) -> bool:
524
+ if callable(self.cancel_on_failure):
525
+ return self.cancel_on_failure(outcome)
526
+ return self.cancel_on_failure
527
+
528
+ def _cancel_rest(self, failed_label: str) -> None:
529
+ """Stop every job not yet past its computation; captures under way finish."""
530
+ self.cancelled_by = failed_label
531
+ to_cancel = [slot for slot in self.slots if slot.phase in (_Phase.PENDING, _Phase.RUNNING)]
532
+ if to_cancel:
533
+ logger.warning("%s failed; cancelling %d other job(s)", failed_label, len(to_cancel))
534
+ for slot in to_cancel:
535
+ error = f"cancelled after {failed_label} failed"
536
+ if slot.phase is _Phase.RUNNING:
537
+ computation_id = slot.computation_ids[-1]
538
+ try:
539
+ # Code Ocean has no stop call; deleting stops a running computation.
540
+ self.client.computations.delete_computation(computation_id)
541
+ except (CodeOceanError, requests.RequestException) as exc:
542
+ error += f"; could not stop computation {computation_id}: {exc}"
543
+ self._finish(slot, "cancelled", error=error)
493
544
 
494
545
  def _call(self, slot: _Slot, what: str, fn: Callable[[], _T], *, idempotent: bool) -> _T | None:
495
546
  """Run one API call for *slot*; on error, schedule a retry or fail the job.
@@ -502,8 +553,14 @@ class _Dispatcher:
502
553
  except (CodeOceanError, requests.RequestException) as exc:
503
554
  delay = _retry_delay(exc, slot.api_errors, idempotent=idempotent)
504
555
  if delay is None:
505
- note = " It may have taken effect anyway; check before rerunning." if _is_ambiguous(exc) else ""
506
- self._finish(slot, "failed", error=f"{what} failed: {exc}.{note}")
556
+ ambiguous = _is_ambiguous(exc)
557
+ note = " It may have taken effect anyway; check before rerunning." if ambiguous else ""
558
+ self._finish(
559
+ slot,
560
+ "failed",
561
+ error=f"{what} failed: {exc}.{note}",
562
+ failure="api_unavailable" if ambiguous else "api_rejected",
563
+ )
507
564
  return None
508
565
  slot.api_errors += 1
509
566
  slot.next_at = _now() + delay
@@ -577,6 +634,7 @@ class _Dispatcher:
577
634
  slot,
578
635
  "failed",
579
636
  error=f"timed out after {self.timeout_s:.0f} s; computation {computation_id} left running",
637
+ failure="timeout",
580
638
  )
581
639
  else:
582
640
  slot.next_at = _now() + self.poll_interval_s
@@ -594,7 +652,8 @@ class _Dispatcher:
594
652
  self.next_launch_at = max(self.next_launch_at, slot.next_at)
595
653
  logger.warning("%s: %s; relaunching in %.0f s", slot.job.label, _describe(computation), backoff_s)
596
654
  else:
597
- self._finish(slot, "failed", error=_describe(computation))
655
+ failure: Failure = "failed_start" if self.is_failed_start(computation) else "computation"
656
+ self._finish(slot, "failed", error=_describe(computation), failure=failure)
598
657
 
599
658
  def _start_capture(self, slot: _Slot, computation: Computation) -> None:
600
659
  assert slot.job.capture is not None
@@ -603,7 +662,12 @@ class _Dispatcher:
603
662
  # Broad on purpose: one job's bad callback must not orphan the others' computations.
604
663
  except Exception as exc:
605
664
  logger.exception("%s: capture callback raised", slot.job.label)
606
- self._finish(slot, "failed", error=f"capture callback raised for computation {computation.id}: {exc!r}")
665
+ self._finish(
666
+ slot,
667
+ "failed",
668
+ error=f"capture callback raised for computation {computation.id}: {exc!r}",
669
+ failure="capture_callback",
670
+ )
607
671
  return
608
672
  if slot.job.key is not None and key_tag(slot.job.key) not in params.tags:
609
673
  params = dataclasses.replace(params, tags=[*params.tags, key_tag(slot.job.key)])
@@ -644,7 +708,10 @@ class _Dispatcher:
644
708
  logger.warning("%s: capture %s failed; capturing again", slot.job.label, asset_id)
645
709
  else:
646
710
  self._finish(
647
- slot, "failed", error=f"capture {asset_id} of computation {slot.computation_ids[-1]} failed"
711
+ slot,
712
+ "failed",
713
+ error=f"capture {asset_id} of computation {slot.computation_ids[-1]} failed",
714
+ failure="capture",
648
715
  )
649
716
  else:
650
717
  slot.next_at = _now() + _ASSET_POLL_S
@@ -104,6 +104,8 @@ class FakeComputations:
104
104
  launch_errors: dict[str, list[Exception]] = field(default_factory=dict)
105
105
  launches: list[tuple[float, str, str]] = field(default_factory=list) # (time, capsule_id, computation_id)
106
106
  max_running: int = 0
107
+ deleted: list[str] = field(default_factory=list)
108
+ delete_errors: list[Exception] = field(default_factory=list)
107
109
  _ids: itertools.count[int] = field(default_factory=itertools.count)
108
110
  _scripts: dict[str, list[Any]] = field(default_factory=dict)
109
111
  _running: set[str] = field(default_factory=set)
@@ -119,6 +121,12 @@ class FakeComputations:
119
121
  self.max_running = max(self.max_running, len(self._running))
120
122
  return self._computation(computation_id, snapshot(ComputationState.Initializing))
121
123
 
124
+ def delete_computation(self, computation_id: str) -> None:
125
+ if self.delete_errors:
126
+ raise self.delete_errors.pop(0)
127
+ self.deleted.append(computation_id)
128
+ self._running.discard(computation_id)
129
+
122
130
  def get_computation(self, computation_id: str) -> Computation:
123
131
  script = self._scripts[computation_id]
124
132
  step = script.pop(0) if len(script) > 1 else script[0]
@@ -127,6 +127,7 @@ def test_failed_start_beyond_retries_fails_with_every_attempt(clock: FakeClock)
127
127
  assert outcome.status == "failed"
128
128
  assert outcome.computation_ids == ("comp-0", "comp-1")
129
129
  assert "has_results=False" in (outcome.error or "")
130
+ assert (outcome.failure, outcome.transient) == ("failed_start", True)
130
131
 
131
132
 
132
133
  def test_failed_starts_back_off_and_hold_other_launches(clock: FakeClock) -> None:
@@ -168,6 +169,7 @@ def test_capsule_crash_is_not_relaunched(clock: FakeClock) -> None:
168
169
 
169
170
  assert [o.status for o in outcomes] == ["failed", "captured"]
170
171
  assert "exit_code=1" in (outcomes[0].error or "")
172
+ assert (outcomes[0].failure, outcomes[0].transient) == ("computation", False)
171
173
  assert len(client.computations.launches) == 2
172
174
 
173
175
 
@@ -193,6 +195,7 @@ def test_server_error_on_launch_is_not_retried(clock: FakeClock) -> None:
193
195
  assert outcome.status == "failed"
194
196
  assert "may have taken effect" in (outcome.error or "")
195
197
  assert client.computations.launches == []
198
+ assert (outcome.failure, outcome.transient) == ("api_unavailable", True)
196
199
 
197
200
 
198
201
  def test_transient_errors_on_status_checks_do_not_fail_a_running_job(clock: FakeClock) -> None:
@@ -211,6 +214,7 @@ def test_client_error_on_status_check_fails_the_job(clock: FakeClock) -> None:
211
214
  assert outcome.status == "failed"
212
215
  assert "status check failed" in (outcome.error or "")
213
216
  assert "may have taken effect" not in (outcome.error or "")
217
+ assert (outcome.failure, outcome.transient) == ("api_rejected", False)
214
218
 
215
219
 
216
220
  def test_rate_limited_capture_is_retried(clock: FakeClock) -> None:
@@ -262,6 +266,7 @@ def test_failed_capture_fails_the_job_by_default(clock: FakeClock) -> None:
262
266
 
263
267
  assert outcome.status == "failed"
264
268
  assert "capture asset-0" in (outcome.error or "")
269
+ assert (outcome.failure, outcome.transient) == ("capture", True)
265
270
 
266
271
 
267
272
  def test_timeout_fails_the_job_and_leaves_it_running(clock: FakeClock) -> None:
@@ -271,6 +276,83 @@ def test_timeout_fails_the_job_and_leaves_it_running(clock: FakeClock) -> None:
271
276
 
272
277
  assert outcome.status == "failed"
273
278
  assert "comp-0 left running" in (outcome.error or "")
279
+ assert (outcome.failure, outcome.transient) == ("timeout", False)
280
+
281
+
282
+ # -- cancelling on failure ----------------------------------------------------
283
+
284
+
285
+ def test_successful_outcomes_carry_no_failure(clock: FakeClock) -> None:
286
+ (outcome,) = run_jobs(make_client(clock, {"a": [[SUCCEEDED]]}), [job("a")])
287
+
288
+ assert (outcome.failure, outcome.transient, outcome.ok) == (None, False, True)
289
+
290
+
291
+ def test_failure_cancels_running_and_pending_jobs(clock: FakeClock) -> None:
292
+ client = make_client(clock, {"a": [[CRASHED]], "b": [[RUNNING]], "c": [[SUCCEEDED]]})
293
+
294
+ outcomes = run_jobs(client, [job("a"), job("b"), job("c")], max_in_flight=2, cancel_on_failure=True)
295
+
296
+ assert [o.status for o in outcomes] == ["failed", "cancelled", "cancelled"]
297
+ assert client.computations.deleted == ["comp-1"]
298
+ assert [capsule for _, capsule, _ in client.computations.launches] == ["a", "b"]
299
+ assert outcomes[1].computation_ids == ("comp-1",)
300
+ assert outcomes[2].computation_ids == ()
301
+ assert outcomes[1].error == "cancelled after a failed"
302
+ assert not outcomes[1].ok
303
+ assert outcomes[1].failure is None
304
+
305
+
306
+ def test_capture_under_way_finishes_when_cancelling(clock: FakeClock) -> None:
307
+ client = make_client(
308
+ clock,
309
+ {"a": [[RUNNING, CRASHED]], "b": [[SUCCEEDED]]},
310
+ capture_states=[[DataAssetState.Draft] * 10 + [DataAssetState.Ready]],
311
+ )
312
+
313
+ outcomes = run_jobs(client, [job("a"), job("b")], cancel_on_failure=True)
314
+
315
+ assert [o.status for o in outcomes] == ["failed", "captured"]
316
+ assert client.computations.deleted == []
317
+
318
+
319
+ def test_cancel_predicate_decides_per_failure(clock: FakeClock) -> None:
320
+ client = make_client(clock, {"a": [[FAILED_START]], "b": [[RUNNING, SUCCEEDED]]})
321
+
322
+ outcomes = run_jobs(
323
+ client, [job("a"), job("b")], start_retries=0, cancel_on_failure=lambda outcome: not outcome.transient
324
+ )
325
+
326
+ assert [o.status for o in outcomes] == ["failed", "captured"]
327
+
328
+
329
+ def test_failed_stop_is_reported_on_the_cancelled_job(clock: FakeClock) -> None:
330
+ client = make_client(clock, {"a": [[CRASHED]], "b": [[RUNNING]]})
331
+ client.computations.delete_errors = [http_error(503)]
332
+
333
+ outcomes = run_jobs(client, [job("a"), job("b")], cancel_on_failure=True)
334
+
335
+ assert outcomes[1].status == "cancelled"
336
+ assert "could not stop computation comp-1" in (outcomes[1].error or "")
337
+
338
+
339
+ def test_failures_continue_by_default(clock: FakeClock) -> None:
340
+ client = make_client(clock, {"a": [[CRASHED]], "b": [[RUNNING, SUCCEEDED]]})
341
+
342
+ outcomes = run_jobs(client, [job("a"), job("b")])
343
+
344
+ assert [o.status for o in outcomes] == ["failed", "captured"]
345
+ assert client.computations.deleted == []
346
+
347
+
348
+ def test_raise_for_failures_lists_cancelled_jobs(clock: FakeClock) -> None:
349
+ client = make_client(clock, {"a": [[CRASHED]], "b": [[RUNNING]]})
350
+ outcomes = run_jobs(client, [job("a"), job("b")], cancel_on_failure=True)
351
+
352
+ with pytest.raises(DispatchFailed) as info:
353
+ raise_for_failures(outcomes)
354
+
355
+ assert [o.job.label for o in info.value.failures] == ["a", "b"]
274
356
 
275
357
 
276
358
  # -- reuse --------------------------------------------------------------------
@@ -343,6 +425,7 @@ def test_capture_callback_error_fails_only_that_job(clock: FakeClock) -> None:
343
425
  outcomes = run_jobs(client, jobs)
344
426
 
345
427
  assert [o.status for o in outcomes] == ["failed", "captured"]
428
+ assert outcomes[0].failure == "capture_callback"
346
429
 
347
430
 
348
431
  def test_duplicate_labels_are_rejected(clock: FakeClock) -> None:
@@ -17,7 +17,7 @@ wheels = [
17
17
 
18
18
  [[package]]
19
19
  name = "aind-codeocean-dispatch"
20
- version = "0.3.0"
20
+ version = "0.4.0"
21
21
  source = { editable = "." }
22
22
  dependencies = [
23
23
  { name = "aind-code-ocean-pipeline-utils" },