R function not sourcing from python using pyrserve

103 views
Skip to first unread message

jediinsights

unread,
Aug 7, 2013, 3:42:21 AM8/7/13
to pyrs...@googlegroups.com
I have a function initSession which is sourced in Rserv.conf when Rserve starts:

    # Function to source session init file. Python calls this for initializing a session.
    initSession <- function(){
    print(file.InitSession) # this works
    source(file.InitSession)
    }

Within file.InitSession (a .R file) I have a bunch of steps:

    # these are the sample contents of file.InitSession
    print("In init Session script.") ### THIS DOES NOT WORK. DOES NOT PRINT!!
    
    module = "init_session"
    assign("PID__", PROCESSID__, envir = .GlobalEnv) #PROCESSID__ is var created in R using pyrserve
    # and other statements


In python it spits out this error:

    Traceback (most recent call last):
      File "/opt/insightjedi/django-code/Statistics/rConnectors.py", line 53, in init_R_Session
        self.rConnection.eval("initSession()")  ## ----- added line
      File "/usr/local/lib/python2.7/dist-packages/pyRserve/rconn.py", line 37, in decoCheckIfClosed
        return func(self, *args, **kw)
      File "/usr/local/lib/python2.7/dist-packages/pyRserve/rconn.py", line 103, in eval
        return rparse(src, atomicArray=atomicArray)
      File "/usr/local/lib/python2.7/dist-packages/pyRserve/rparser.py", line 469, in rparse
        return rparser.parse()
      File "/usr/local/lib/python2.7/dist-packages/pyRserve/rparser.py", line 304, in parse
        self.lexer.readHeader()
      File "/usr/local/lib/python2.7/dist-packages/pyRserve/rparser.py", line 83, in readHeader
        self.responseCode = struct.unpack(b'<i', self.read(3) + b'\x00')[0]
      File "/usr/local/lib/python2.7/dist-packages/pyRserve/rparser.py", line 128, in read
        raise EndOfDataError()
    EndOfDataError

Any idea why this happens? I have all directories set at full access. (777)


    > R.Version()
    $platform
    [1] "x86_64-apple-darwin9.8.0"
    
    $arch
    [1] "x86_64"
    
    $os
    [1] "darwin9.8.0"
    
    $system
    [1] "x86_64, darwin9.8.0"
    
    $status
    [1] ""
    
    $major
    [1] "2"
    
    $minor
    [1] "15.2"
    
    $year
    [1] "2012"
    
    $month
    [1] "10"
    
    $day
    [1] "26"
    
    $`svn rev`
    [1] "61015"
    
    $language
    [1] "R"
    
    $version.string
    [1] "R version 2.15.2 (2012-10-26)"
    
    $nickname
    [1] "Trick or Treat"

pyRserve version 0.7.1

And I really hope someone creates a pyRserve tag with reputation>1500. I cant and my guess is questions get all routed to as python questions. Even if you have to copy and paste my question, that is fine.

Ralph Heinkel

unread,
Aug 7, 2013, 4:38:41 AM8/7/13
to pyrs...@googlegroups.com
Hi jediinsights,

I'm
trying to reproduce your problem. For me it seems to work fine, but I'm not sure about your exact setup. Can you send me a minimalistic R file which is sourced at Rserve startup (including the Rserv.conf entry), and a minimalistic R file which is then sourced by Python and then causes your problems?

Ralph

jediinsights

unread,
Aug 8, 2013, 9:59:43 AM8/8/13
to pyrs...@googlegroups.com
Hi Ralph:
I will post details about how to reproduce the problem shortly.
Thanks,
Dipayan
Reply all
Reply to author
Forward
0 new messages