[Rpy] [ rpy-Bugs-2062627 ] R cannot initialize more than once in process

2008-09-18 Thread SourceForge.net
Bugs item #2062627, was opened at 2008-08-20 18:01
Message generated for change (Comment added) made by lgautier
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=453021&aid=2062627&group_id=48422

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Source
Group: rpy
Status: Open
>Resolution: Postponed
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: R cannot initialize more than once in process

Initial Comment:
Hello,

I am currently working with a software package (ArcGIS) that runs Python “In 
Process”.  There has been a call from our users to be able to integrate R 
functionality.  Our “Out of Proc” version allows us to call rpy over and over 
again because it is essentially re-initializing the R() instance on each run.  
But when we switch it over to the “In Proc” version we get the following error 
message: 

Traceback (most recent call last):
  File "", line 29, in 
  File "", line 8, in testPoly2Line
  File "C:\Python25\lib\site-packages\rpy.py", line 346, in r = R()
  File "C:\Python25\lib\site-packages\rpy.py", line 286, in __init__
_rpy.r_init(HAS_NUMERIC);
RuntimeError: Only one R object may be instantiated per session

The problem can be explained by the following set of issues: 1) We embed Python 
in our application for use as a scripting engine, 2) Each time a Python script 
is run in the application, it is from a new Python session (i.e. a brand new 
set of locals and globals) but in the same process, 3) When importing the 
Python R libraries, it binds the RPy .DLL into process, 4) In Python R�s 
startup, there is a static integer in _rpy.r_init used as a flag that 
determines if R has already been loaded. The rest of the function initializes 
numeric if sent the flag to do so, and throws a RuntimeError if R was 
initialized before. Since the library is still resident in memory even after 
the Python session goes away, this stays set to 1. Looking at the C 
implementation of the r_init function, this seems unnecessary and there have 
been no ill effects from patching the Python to ignore the error. After a 
cursory read over the Python, this appears to be a piece of legacy that isn�t 
necessary anymore as it does not affect anything else.

We have a hack that allows us to run it In Proc and we wanted to know if it is 
appropriate: (On Line ~ 286 of rpy.py)

   try:
   _rpy.r_init(HAS_NUMERIC)
   except RuntimeError, e:
  pass
   _rpy.set_mode(NO_DEFAULT)



So in our case, RPython�s refusal to instantiate another instance of the R() 
object by throwing a RuntimeError is considered a bug, because the binary 
library is already initialized and resident in memory, its related Python 
locals just went away and need to be allowed to reset. Ignoring the error is 
idea, but warning instead of throwing is, at the very least, preferable. 
Ideally the code in C would more resemble this:

static PyObject *
r_init(PyObject *self, PyObject *args)
{
  static int first=1;
  int i;
  
  if (!PyArg_ParseTuple(args, "i:r_init", &i))
return NULL;
  use_numeric = i;

  
  if(first==1)
{
  #ifdef WITH_NUMERIC
  if(use_numeric)
  init_numeric();
  #endif

  first=0;
}
  Py_INCREF(Py_None);
  return Py_None;
}

Thanks so much ahead of time.  Best wishes,

MJ

Mark Janikas
Product Engineer
ESRI, Geoprocessing
380 New York St.
Redlands, CA 92373
909-793-2853 (2563)
[EMAIL PROTECTED]




--

>Comment By: lgautier (lgautier)
Date: 2008-09-19 08:35

Message:

Could provide version numbers for the version you tried ?
It was fixed for rpy2 few weeks ago.

>>> import rpy2.rinterface as ri
>>> ri.initr()
0
>>> ri.initr()
0
>>> 


--

Comment By: Mark  Janikas (mark_janikas)
Date: 2008-09-16 00:08

Message:
Just found the same error in RPy2.

: R can only be initialized once.



--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=453021&aid=2062627&group_id=48422

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list


[Rpy] [ rpy-Bugs-1956434 ] rpy 1.0~rc1segfault with bioconductor packages

2008-09-18 Thread SourceForge.net
Bugs item #1956434, was opened at 2008-05-02 22:42
Message generated for change (Comment added) made by lgautier
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=453021&aid=1956434&group_id=48422

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Faheem Mitha (fmitha)
Assigned to: Nobody/Anonymous (nobody)
Summary: rpy 1.0~rc1segfault with bioconductor packages 

Initial Comment:
Hi,

I'm getting a segfault with rpy, 1.0~rc1-2 on Debian etch, with the CRAN 
backport of 2.6.2.
  Faheem.

**
Debian package info.
**
||/ NameVersion Description
+++-===-===-==
ii  python-rpy  1.0~rc1-2   Python 
interface to the GNU R language and environment
ii  r-base-core 2.6.2-1~etchcran.1  GNU R core 
of statistical computing language and environment


Script to reproduce

from rpy import r

r.library("affy")
r.library("hu6800cdf")
fnames = [u'AD8.CEL', u'L01.CEL', u'L02.CEL', u'L04.CEL', u'L05.CEL', 
u'L06.CEL']
celdat = r.ReadAffy(filenames = fnames, celfile_path = 'data')


*
Run output

[EMAIL PROTECTED]:/tmp$ python rpy_bug.py
RHOME= /usr/lib64/R
RVERSION= 2.6.2
RVER= 2062
RUSER= /home/faheem
Loading Rpy version 2062 .. Done.
Creating the R object 'r' ..  Done
Loading required package: Biobase
Loading required package: tools

Welcome to Bioconductor

  Vignettes contain introductory material. To view, type
  'openVignette()'. To cite Bioconductor, see
  'citation("Biobase")' and for packages 'citation(pkgname)'.

Loading required package: affyio
Loading required package: preprocessCore
Error: segfault from C stack overflow
Segmentation fault


R package info obtained from sessionInfo.

> sessionInfo()
R version 2.6.2 (2008-02-08)
x86_64-pc-linux-gnu

locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;L
C_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C

attached base packages:
[1] tools stats graphics  grDevices utils datasets  methods
[8] base

other attached packages:
[1] hu6800cdf_2.0.0  affy_1.16.0  preprocessCore_1.0.0
[4] affyio_1.6.1 Biobase_1.16.3

loaded via a namespace (and not attached):
[1] rcompgen_0.1-17



--

>Comment By: lgautier (lgautier)
Date: 2008-09-19 08:48

Message:
Seems to be working with rpy2 and R-2.7:

import rpy2.robjects as ro
ro.r.library("affy")

cel = ro.r["read.affybatch"]("GSM177882.CEL.gz")



--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=453021&aid=1956434&group_id=48422

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list


[Rpy] [ rpy-Bugs-1956434 ] rpy 1.0~rc1segfault with bioconductor packages

2008-09-18 Thread SourceForge.net
Bugs item #1956434, was opened at 2008-05-02 22:42
Message generated for change (Settings changed) made by lgautier
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=453021&aid=1956434&group_id=48422

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
>Status: Closed
Resolution: Fixed
Priority: 5
Private: No
Submitted By: Faheem Mitha (fmitha)
Assigned to: Nobody/Anonymous (nobody)
Summary: rpy 1.0~rc1segfault with bioconductor packages 

Initial Comment:
Hi,

I'm getting a segfault with rpy, 1.0~rc1-2 on Debian etch, with the CRAN 
backport of 2.6.2.
  Faheem.

**
Debian package info.
**
||/ NameVersion Description
+++-===-===-==
ii  python-rpy  1.0~rc1-2   Python 
interface to the GNU R language and environment
ii  r-base-core 2.6.2-1~etchcran.1  GNU R core 
of statistical computing language and environment


Script to reproduce

from rpy import r

r.library("affy")
r.library("hu6800cdf")
fnames = [u'AD8.CEL', u'L01.CEL', u'L02.CEL', u'L04.CEL', u'L05.CEL', 
u'L06.CEL']
celdat = r.ReadAffy(filenames = fnames, celfile_path = 'data')


*
Run output

[EMAIL PROTECTED]:/tmp$ python rpy_bug.py
RHOME= /usr/lib64/R
RVERSION= 2.6.2
RVER= 2062
RUSER= /home/faheem
Loading Rpy version 2062 .. Done.
Creating the R object 'r' ..  Done
Loading required package: Biobase
Loading required package: tools

Welcome to Bioconductor

  Vignettes contain introductory material. To view, type
  'openVignette()'. To cite Bioconductor, see
  'citation("Biobase")' and for packages 'citation(pkgname)'.

Loading required package: affyio
Loading required package: preprocessCore
Error: segfault from C stack overflow
Segmentation fault


R package info obtained from sessionInfo.

> sessionInfo()
R version 2.6.2 (2008-02-08)
x86_64-pc-linux-gnu

locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;L
C_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C

attached base packages:
[1] tools stats graphics  grDevices utils datasets  methods
[8] base

other attached packages:
[1] hu6800cdf_2.0.0  affy_1.16.0  preprocessCore_1.0.0
[4] affyio_1.6.1 Biobase_1.16.3

loaded via a namespace (and not attached):
[1] rcompgen_0.1-17



--

Comment By: lgautier (lgautier)
Date: 2008-09-19 08:48

Message:
Seems to be working with rpy2 and R-2.7:

import rpy2.robjects as ro
ro.r.library("affy")

cel = ro.r["read.affybatch"]("GSM177882.CEL.gz")



--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=453021&aid=1956434&group_id=48422

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list