Dataframe operations on Ray actors
We are trying to use pandas over ray with modin (import modin.pandas) Looking at the documentation - https://docs.ray.io/en/latest/modin/index.html#dataframe-operations, Modin Dataframe uses Ray tasks to perform data manipulations.
However, we have a use case where we need long running actors with Ray (mainly because we perform some worker initialization which is slow so we maintain long running actors which are pre-initialized). Wondering how easy would it be to switch the modin dataframes to use our custom actors without rewriting a complete backend for modin.
Hi @nikunjgit , thanks for the question! We have an API to retrieve Modin DataFrame partitions (link). Having retrieved the partitions (block-wise, row-wise or column-wise in depend on axis parameter) you can pass them to a method of the actors and call a pandas operation. Note that in that case you are depending on the numbers of actors that will perform operations in parallel. Example:
import modin.pandas as pd
from modin.distributed.dataframe.pandas import unwrap_partitions, from_partitions
import numpy as np
data = np.random.randint(0, 100, size=(2 ** 10, 2 ** 8))
df = pd.DataFrame(data)
partitions = unwrap_partitions(df, axis=0, get_ip=False) # Assume we have two row partitions
@ray.remote
class Actor1:
def process_1(partition_1):
return partition_1.abs()
@ray.remote
class Actor2:
def process_2(partition_2):
return partition_2.abs()
a1 = Actor1()
a2 = Actor2()
result = [a1.process_1(partitions[0]), a2.process_2(partitions[1])]
@nikunjgit , also, you will have to care of the partitioning of a Modin DataFrame (how to retrieve partitions) and operations that you will want to call whereas Modin is able to do it for you. There might be something else. I've already thought of possible switch between task and actor models In Modin and maybe we should try it at some point.
Hi @nikunjgit! I'm marking this issue as resolved since it hasn't been updated recently! If you have any further questions, please feel free to reopen this issue, or open a new one!