1717from .partition import PandasOnRayFramePartition
1818
1919import ray
20+ from ray .services import get_node_ip_address
2021
2122
2223class PandasOnRayFrameAxisPartition (PandasFrameAxisPartition ):
23- def __init__ (self , list_of_blocks ):
24+ def __init__ (self , list_of_blocks , bind_ip = False ):
2425 # Unwrap from BaseFramePartition object for ease of use
2526 for obj in list_of_blocks :
2627 obj .drain_call_queue ()
2728 self .list_of_blocks = [obj .oid for obj in list_of_blocks ]
29+ if bind_ip :
30+ self .list_of_ips = [obj .ip for obj in list_of_blocks ]
2831
2932 partition_type = PandasOnRayFramePartition
3033 instance_type = ray .ObjectID
@@ -44,7 +47,7 @@ def deploy_axis_func(
4447 maintain_partitioning ,
4548 )
4649 + tuple (partitions ),
47- num_returns = num_splits * 3 if lengths is None else len (lengths ) * 3 ,
50+ num_returns = num_splits * 4 if lengths is None else len (lengths ) * 4 ,
4851 )
4952
5053 @classmethod
@@ -62,13 +65,13 @@ def deploy_func_between_two_axis_partitions(
6265 kwargs ,
6366 )
6467 + tuple (partitions ),
65- num_returns = num_splits * 3 ,
68+ num_returns = num_splits * 4 ,
6669 )
6770
6871 def _wrap_partitions (self , partitions ):
6972 return [
70- self .partition_type (partitions [ i ], partitions [ i + 1 ], partitions [ i + 2 ] )
71- for i in range ( 0 , len ( partitions ), 3 )
73+ self .partition_type (object_id , length , width , ip )
74+ for ( object_id , length , width , ip ) in zip ( * [ iter ( partitions )] * 4 )
7275 ]
7376
7477
@@ -92,20 +95,27 @@ class PandasOnRayFrameRowPartition(PandasOnRayFrameAxisPartition):
9295
9396@ray .remote
9497def deploy_ray_func (func , * args ): # pragma: no cover
95- """Run a function on a remote partition.
96-
97- Note: Ray functions are not detected by codecov (thus pragma: no cover)
98+ """
99+ Run a function on a remote partition.
98100
99- Args:
100- func: The function to run.
101+ Parameters
102+ ----------
103+ func : callable
104+ The function to run.
101105
102- Returns:
106+ Returns
107+ -------
103108 The result of the function `func`.
109+
110+ Notes
111+ -----
112+ Ray functions are not detected by codecov (thus pragma: no cover)
104113 """
105114 result = func (* args )
115+ ip = get_node_ip_address ()
106116 if isinstance (result , pandas .DataFrame ):
107- return result , len (result ), len (result .columns )
117+ return result , len (result ), len (result .columns ), ip
108118 elif all (isinstance (r , pandas .DataFrame ) for r in result ):
109- return [i for r in result for i in [r , len (r ), len (r .columns )]]
119+ return [i for r in result for i in [r , len (r ), len (r .columns ), ip ]]
110120 else :
111- return [i for r in result for i in [r , None , None ]]
121+ return [i for r in result for i in [r , None , None , ip ]]
0 commit comments