test_cell_magic: ERROR - failed to write data to stream

Issue #195 resolved
Laurent Gautier created an issue

I am getting the following when running the tests:

test_cell_magic (ipython.tests.test_rmagic.TestRmagic) ... ERROR - failed to write data to stream: <open file '<fdopen>', mode 'w+b' at 0x5de2420>

Comments (10)

  1. Laurent Gautier reporter

    Hi Dav, you know more than me what is happening within the ipython part. Can you look at it (or find where this is happening - there is certainly a chance that this is a bug in core rpy2)?

  2. Dav Clark

    I tracked down the issue, which has something to do with writing to standard output from standard out from the R sub-process. This led to some digging, and now I'm using unittest in a more standard way (at least, I think I am, it seems very few people actually use unittest in a serious way - most projects use nose or pytest).

    The secret is that buffer=True argument to the unittest.main() function, which you can't enable when you're using the machinery in a different way...

    We may want to move some of the tests that R is working from the main block to the load_tests() def now (though that doesn't make total sense semantically...), which would make execution the same whether we do python -m unittest rpy2.tests or python -m rpy2.tests. But, I'm leaving it as-is for now.

  3. Dav Clark

    Also - R has a fontconfig error it reports from Cairo for now. It's a known bug, already fixed in the R 3.1 branch.

  4. Laurent Gautier reporter

    This led to some digging, and now I'm using unittest in a more standard way (at least, I think I am, it seems very few people actually use unittest in a serious way - most projects use nose or pytest).

    I am hearing loud and clear the wish to move away from unittest(2) (issue #181). One can open an issue for rpy2-2.5.0.

  5. Laurent Gautier reporter

    But, I'm leaving it as-is for now.

    Good is good enough, especially if changing the testing system.

  6. Laurent Gautier reporter

    Also - R has a fontconfig error it reports from Cairo for now. It's a known bug, already fixed in the R 3.1 branch.

    Speaking of Cairo, I have noted that Cairo is only used for SVG renders (I read the code real quick- I might be wrong). If it was used also for PNG (and other formats), the consistency between rendered figures across format might be higher.

  7. Dav Clark

    That's correct that Cairo is only used for SVG, but Cairo is also not installed by default. So, the benefit is that the default PNG works without the extra install. Specifically, plotting with base (or lattice) graphics works without extra installs. This opens the question of rpy2 perhaps installing certain packages when they are absent in R...

    I don't feel strongly here on the graphics issue, but now that I feel relatively happy with the rmagic baseline, I'm thinking about better pandas interop. Specifically, we'd talked about using plyr and friends to handle things like pandas' richer indices.I think if we start using packages like plyr, we want to install them if they're absent (GGplot support currently relies on plyr, but I feel like that's less "core").

    On the unittest issue, I'm mostly beginning to feel sentiment that I've heard reflected from others: that the python standard library isn't really "standard," and so you end up with weird corners and backwaters (I'm looking particularly at string templating). The only real problem with unittest is that the documentation is very weak compared to the other packages. But things are better now - specifically, rpy2.tests will now accept all unittest command line args.

    Anyway, I'm pretty happy with things as they are for a 2.4 release, and I hope we can get there soon, so that ipython can respond with a deprecation (and I'll check in with the pandas folks also).

  8. Laurent Gautier reporter

    This opens the question of rpy2 perhaps installing certain packages when they are absent in R...

    This is a can of worms... so no for the core rpy2. However, this could be attempted for the ipython part.There are features to help with that : http://rpy.sourceforge.net/rpy2/doc-dev/html/robjects_rpackages.html?highlight=instal#installing-removing-r-packages

    (...)

    But things are better now - specifically, rpy2.tests will now accept all unittest command line args.

    Thanks for that. I learned a bunch about unittest2 (and by extension that better things than unittest could be out there) while looking at the changes you were making.

    Anyway, I'm pretty happy with things as they are for a 2.4 release, and I hope we can get there soon, so that ipython can respond with a deprecation (and I'll check in with the pandas folks also).

    I am pretty much there (only smoothing out rough edges with the display of R help as on-the-fly doctrings).

  9. Dav Clark

    I was actually messing with an error message that explains how to install Cairo via rpy2. I removed the StrVector bit, as you've rendered that unnecessary, right?

  10. Log in to comment