Construct a RayActorError by building the arguments.
(
self, cause: Optional[Union[RayTaskError, ActorDiedErrorContext]] = None
)
| 418 | BASE_ERROR_MSG = "The actor died unexpectedly before finishing this task." |
| 419 | |
| 420 | def __init__( |
| 421 | self, cause: Optional[Union[RayTaskError, ActorDiedErrorContext]] = None |
| 422 | ): |
| 423 | """ |
| 424 | Construct a RayActorError by building the arguments. |
| 425 | """ |
| 426 | |
| 427 | actor_id = None |
| 428 | error_msg = ActorDiedError.BASE_ERROR_MSG |
| 429 | actor_init_failed = False |
| 430 | preempted = False |
| 431 | |
| 432 | if not cause: |
| 433 | # Use the defaults above. |
| 434 | pass |
| 435 | elif isinstance(cause, RayTaskError): |
| 436 | actor_init_failed = True |
| 437 | actor_id = cause._actor_id |
| 438 | error_msg = ( |
| 439 | "The actor died because of an error" |
| 440 | " raised in its creation task, " |
| 441 | f"{cause.__str__()}" |
| 442 | ) |
| 443 | else: |
| 444 | # Indicating system-level actor failures. |
| 445 | assert isinstance(cause, ActorDiedErrorContext) |
| 446 | error_msg_lines = [ActorDiedError.BASE_ERROR_MSG] |
| 447 | error_msg_lines.append(f"\tclass_name: {cause.class_name}") |
| 448 | error_msg_lines.append(f"\tactor_id: {ActorID(cause.actor_id).hex()}") |
| 449 | # Below items are optional fields. |
| 450 | if cause.pid != 0: |
| 451 | error_msg_lines.append(f"\tpid: {cause.pid}") |
| 452 | if cause.name != "": |
| 453 | error_msg_lines.append(f"\tname: {cause.name}") |
| 454 | if cause.ray_namespace != "": |
| 455 | error_msg_lines.append(f"\tnamespace: {cause.ray_namespace}") |
| 456 | if cause.node_ip_address != "": |
| 457 | error_msg_lines.append(f"\tip: {cause.node_ip_address}") |
| 458 | error_msg_lines.append(cause.error_message) |
| 459 | if cause.never_started: |
| 460 | error_msg_lines.append( |
| 461 | "The actor never ran - it was cancelled before it started running." |
| 462 | ) |
| 463 | if ( |
| 464 | cause.node_death_info |
| 465 | and cause.node_death_info.reason |
| 466 | == NodeDeathInfo.AUTOSCALER_DRAIN_PREEMPTED |
| 467 | ): |
| 468 | preempted = True |
| 469 | error_msg = "\n".join(error_msg_lines) |
| 470 | actor_id = ActorID(cause.actor_id).hex() |
| 471 | super().__init__(actor_id, error_msg, actor_init_failed, preempted) |
| 472 | |
| 473 | @staticmethod |
| 474 | def from_task_error(task_error: RayTaskError): |