@@ -99,7 +99,10 @@ def __init__(
99
99
self ._closed_event = asyncio .Event ()
100
100
101
101
def __repr__ (self ) -> str :
102
- return f"<{ self .__class__ .__name__ } { self .id } [{ self .run_id } ] on { self .local_address } >"
102
+ return f"<{ self .__class__ .__name__ } : id={ self .id !r} , run_id={ self .run_id !r} , local_address={ self .local_address !r} , closed={ self .closed !r} , transferred={ self .transferred !r} >"
103
+
104
+ def __str__ (self ) -> str :
105
+ return f"{ self .__class__ .__name__ } <{ self .id } [{ self .run_id } ]> on { self .local_address } "
103
106
104
107
def __hash__ (self ) -> int :
105
108
return self .run_id
@@ -162,9 +165,7 @@ def raise_if_closed(self) -> None:
162
165
if self .closed :
163
166
if self ._exception :
164
167
raise self ._exception
165
- raise ShuffleClosedError (
166
- f"Shuffle { self .id } has been closed on { self .local_address } "
167
- )
168
+ raise ShuffleClosedError (f"{ self } has already been closed" )
168
169
169
170
async def inputs_done (self ) -> None :
170
171
self .raise_if_closed ()
@@ -346,7 +347,7 @@ async def _receive(self, data: list[tuple[ArrayRechunkShardID, bytes]]) -> None:
346
347
async def add_partition (self , data : np .ndarray , partition_id : NDIndex ) -> int :
347
348
self .raise_if_closed ()
348
349
if self .transferred :
349
- raise RuntimeError (f"Cannot add more partitions to shuffle { self } " )
350
+ raise RuntimeError (f"Cannot add more partitions to { self } " )
350
351
351
352
def _ () -> dict [str , list [tuple [ArrayRechunkShardID , bytes ]]]:
352
353
"""Return a mapping of worker addresses to a list of tuples of shard IDs
@@ -511,7 +512,7 @@ def _repartition_buffers(self, data: list[bytes]) -> dict[NDIndex, list[bytes]]:
511
512
async def add_partition (self , data : pd .DataFrame , partition_id : int ) -> int :
512
513
self .raise_if_closed ()
513
514
if self .transferred :
514
- raise RuntimeError (f"Cannot add more partitions to shuffle { self } " )
515
+ raise RuntimeError (f"Cannot add more partitions to { self } " )
515
516
516
517
def _ () -> dict [str , list [tuple [int , bytes ]]]:
517
518
out = split_by_worker (
@@ -586,6 +587,12 @@ def __init__(self, worker: Worker) -> None:
586
587
self .closed = False
587
588
self ._executor = ThreadPoolExecutor (self .worker .state .nthreads )
588
589
590
+ def __str__ (self ) -> str :
591
+ return f"ShuffleWorkerExtension on { self .worker .address } "
592
+
593
+ def __repr__ (self ) -> str :
594
+ return f"<ShuffleWorkerExtension, worker={ self .worker .address_safe !r} , closed={ self .closed } >"
595
+
589
596
# Handlers
590
597
##########
591
598
# NOTE: handlers are not threadsafe, but they're called from async comms, so that's okay
@@ -695,11 +702,11 @@ async def _get_shuffle_run(
695
702
shuffle = await self ._refresh_shuffle (
696
703
shuffle_id = shuffle_id ,
697
704
)
698
- if run_id < shuffle . run_id :
699
- raise RuntimeError ( "Stale shuffle" )
700
- elif run_id > shuffle . run_id :
701
- # This should never happen
702
- raise RuntimeError ("Invalid shuffle state " )
705
+
706
+ if shuffle . run_id > run_id :
707
+ raise RuntimeError ( f" { run_id = } stale, got { shuffle } " )
708
+ elif shuffle . run_id < run_id :
709
+ raise RuntimeError (f" { run_id = } invalid, got { shuffle } " )
703
710
704
711
if shuffle ._exception :
705
712
raise shuffle ._exception
@@ -729,9 +736,7 @@ async def _get_or_create_shuffle(
729
736
)
730
737
731
738
if self .closed :
732
- raise ShuffleClosedError (
733
- f"{ self .__class__ .__name__ } already closed on { self .worker .address } "
734
- )
739
+ raise ShuffleClosedError (f"{ self } has already been closed" )
735
740
if shuffle ._exception :
736
741
raise shuffle ._exception
737
742
return shuffle
@@ -790,9 +795,7 @@ async def _refresh_shuffle(
790
795
assert result ["status" ] == "OK"
791
796
792
797
if self .closed :
793
- raise ShuffleClosedError (
794
- f"{ self .__class__ .__name__ } already closed on { self .worker .address } "
795
- )
798
+ raise ShuffleClosedError (f"{ self } has already been closed" )
796
799
if shuffle_id in self .shuffles :
797
800
existing = self .shuffles [shuffle_id ]
798
801
if existing .run_id >= result ["run_id" ]:
0 commit comments