1

I am currently generating a dataframe on a RPYC server and what to send this to the client when requested. When I send it across the server it is sent as a netref object. I want to be able to store this as a local variable on the client-side and not as a reference. It seems that RPYC has a built-in pickle protocol which I have tried to use with little success. The end goal is to be able to plot this dataframe on the client-side. The data acquisition for the dataframe is hardware-specific and for the sake of the current question have just loaded the sample data in as a csv.

Here is the server code

import rpyc
from rpyc.utils.server import ThreadedServer # or ForkingServer
import pandas as pd

class MyService(rpyc.Service):
   
        
    def exposed_Dataframe_send(self):
        
        resultsDF = pd.read_csv("Shared/PMBUS_Logging.csv")
        print(type(resultsDF))
        return resultsDF
      

if __name__ == "__main__":
    server = ThreadedServer(MyService, port=18861, protocol_config={
    'allow_public_attrs': True, "allow_pickle":True
})
server.start()

The client code

import rpyc
c = rpyc.connect("localhost", 18861, config={"allow_public_attrs": True, "allow_pickle":True})

x = c.root.Dataframe_send()
print(x)
print(type(x))

x.plot(figsize=[20,15])

Any help is appreciated

1 Answers1

0

On the client you get not the real object but a netref of the dataframe which works almost exactly as the real dataframe. I tried it and on the client I can do:

obj = x.iloc[10]

Which gives me the proper result. If you want to re-create native dataframe on the client, you can get the data and convert:

import pandas as pd
...
x = c.root.Dataframe_send()
js = x.to_json(orient='split')
df = pd.read_json(js, orient='split')
df.plot(figsize=[20,15])

Then if it still does not work, the problem is elsewhere.

A. Genchev
  • 369
  • 3
  • 7