Skip to content

Commit

Permalink
Move receive_dataframe to IO
Browse files Browse the repository at this point in the history
  • Loading branch information
bmcdonald3 committed Jul 28, 2023
1 parent 92c8610 commit 796e614
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 42 deletions.
42 changes: 0 additions & 42 deletions arkouda/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
from arkouda.sorting import argsort, coargsort
from arkouda.strings import Strings
from arkouda.timeclass import Datetime
from arkouda.io import _build_objects

# This is necessary for displaying DataFrames with BitVector columns,
# because pandas _html_repr automatically truncates the number of displayed bits
Expand All @@ -49,7 +48,6 @@
"intersect",
"invert_permutation",
"intx",
"receive_dataframe",
]


Expand Down Expand Up @@ -2823,43 +2821,3 @@ def invert_permutation(perm):
if (unique(perm).size != perm.size) and (perm.size != rng + 1):
raise ValueError("The array is not a permutation.")
return coargsort([perm, arange(perm.size)])


def receive_dataframe(hostname : str, port):
"""
Receive a pdarray sent by `dataframe.transfer()`.
Parameters
----------
hostname : str
The hostname of the dataframe that sent the array
port : int_scalars
The port to send the dataframe over. This needs to be an
open port (i.e., not one that the Arkouda server is
running on). This will open up `numLocales` ports,
each of which in succession, so will use ports of the
range {port..(port+numLocales)} (e.g., running an
Arkouda server of 4 nodes, port 1234 is passed as
`port`, Arkouda will use ports 1234, 1235, 1236,
and 1237 to send the array data).
This port much match the port passed to the call to
`pdarray.send_array()`.
Returns
-------
pdarray
The dataframe sent from the sending server to the
current receiving server.
Raises
------
ValueError
Raised if the op is not within the pdarray.BinOps set
TypeError
Raised if other is not a pdarray or the pdarray.dtype is not
a supported dtype
"""
rep_msg = generic_msg(cmd="receiveDataframe", args={"hostname": hostname,
"port" : port})
rep = json.loads(rep_msg)
return DataFrame(_build_objects(rep))
41 changes: 41 additions & 0 deletions arkouda/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"snapshot",
"restore",
"receive",
"receive_dataframe",
]

ARKOUDA_HDF5_FILE_METADATA_GROUP = "_arkouda_metadata"
Expand Down Expand Up @@ -2026,3 +2027,43 @@ def receive(hostname : str, port):
"port" : port})
rep = json.loads(rep_msg)
return _build_objects(rep)


def receive_dataframe(hostname : str, port):
"""
Receive a pdarray sent by `dataframe.transfer()`.
Parameters
----------
hostname : str
The hostname of the dataframe that sent the array
port : int_scalars
The port to send the dataframe over. This needs to be an
open port (i.e., not one that the Arkouda server is
running on). This will open up `numLocales` ports,
each of which in succession, so will use ports of the
range {port..(port+numLocales)} (e.g., running an
Arkouda server of 4 nodes, port 1234 is passed as
`port`, Arkouda will use ports 1234, 1235, 1236,
and 1237 to send the array data).
This port much match the port passed to the call to
`pdarray.send_array()`.
Returns
-------
pdarray
The dataframe sent from the sending server to the
current receiving server.
Raises
------
ValueError
Raised if the op is not within the pdarray.BinOps set
TypeError
Raised if other is not a pdarray or the pdarray.dtype is not
a supported dtype
"""
rep_msg = generic_msg(cmd="receiveDataframe", args={"hostname": hostname,
"port" : port})
rep = json.loads(rep_msg)
return DataFrame(_build_objects(rep))

0 comments on commit 796e614

Please sign in to comment.