Comments (22)
I agree with the problem. I think BiocParallelParam (and derived) should be reference classes, so a little bit more extensive change.
from biocparallel.
Here's a trivial start of implementing a param class hierarchy as reference classes. I mostly did this to figure out how to write reference classes. Seems pretty straightforward once you know the conventions for initializers and callSuper and such.
BiocParallelParamRef <- setRefClass("BiocParallelParamRef",
contains="VIRTUAL",
fields=list(.controlled="logical", workers="integer"),
methods=list(initialize=function(.controlled=TRUE, workers=0, ...) callSuper(.controlled=.controlled, workers=as.integer(workers), ...)))
SerialParamRef <- setRefClass("SerialParamRef",
contains="BiocParallelParamRef")
# Only difference is it reports 2 workers
DummyParallelParamRef <- setRefClass("DummyParallelParamRef",
contains="BiocParallelParamRef",
methods=list(initialize=function(...) callSuper(.controlled=TRUE, workers=2, ...)))
x <- DummyParallelParamRef$new()
print (x$workers)
from biocparallel.
I'm now experimenting with reference classes here: https://github.com/DarwinAwardWinner/BiocParallel/blob/refclass/R/BiocParallelParam-refclass.R
Anyone with knowledge of how reference classes are actually supposed to be written should feel free to critique me.
from biocparallel.
I've just done some more work toward implementing ref classes here: https://github.com/DarwinAwardWinner/BiocParallel/tree/refclass
However, I'm having trouble getting the package to load with my modifications, so I can't test it. The problem is that in the .onLoad function the calls to both SnowParam()
and MulticoreParam()
fail with:
error: attempt to apply non-function
However, I put in print statements like print(SnowParam); print(class(SnowParam))
and everything seems to indicate that they are functions. If I can get past this issue then I can start testing my reference-class based implementation.
from biocparallel.
Well, I just replaced the onLoad body with register(SerialParam())
which gets me past that hump, and I'm happy to report that I appear to have a working implementation of reference-based parallel param classes!
If someone could help me debug the onLoad problem, we can incorporate this soon.
from biocparallel.
You can debug by adding browser()
to .onLoad
and installing with
R CMD INSTALL --no-test-load BiocParallel
Then when you say library(BiocParallel)
you end up in browser, ready to fail! I find that if I create a simple class setRefClass("A")
somewhere in the code, and then try in the browser in .onLoad to, e.g., getRefClass("A")
I see the error message you mention, so it seems like a bug in the methods package.
from biocparallel.
So, I've done some testing, and the onLoad error only occurs for me when R is run with --vanilla
. (R CMD check
runs with --vanilla
, which is why it triggers the error as well.)
from biocparallel.
After further testing, I have determined that the package can only be loaded after loading the "scales" package. I have no idea why.
from biocparallel.
On 05/14/2013 05:11 PM, Ryan Thompson wrote:
After further testing, I have determined that the package can only be loaded
after loading the "scales" package. I have no idea why.
Something is not being initialized correctly in the methods package; I think
I've had intermittent success with a simple package with only
A <- setRefClass("A")
.onLoad <- function(...) A()
Try experimenting with a simpler rather than more complicated (by adding scales)
package...? Also it is possible to use options(error=recover) to figure out
what is going wrong, though the code is quite complicated...
—
Reply to this email directly or view it on GitHub
#5 (comment).
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109
Location: Arnold Building M1 B861
Phone: (206) 667-2793
from biocparallel.
Well, I got things to work in R 3.0.0: 6087e62
from biocparallel.
My fix also works in R 2.15.3.
from biocparallel.
this
is a work-around that should be addressed by narrowing to a simple reproducible example that can be reported to the R-devel mailing list.
from biocparallel.
Yes indeed, I will do that when I have the chance. Since the bug only seems to occur in the onLoad function of a package, should I just create a minimal package that triggers the bug and send a download link to the R-devel list?
from biocparallel.
Hmm. It seems that I am not constructing reference objects correctly. I thought you had to do ClassName$new()
, when in fact you apparently just have to do ClassName()
. As far as I can tell, both forms are equivalent except that the former triggers this bug and the latter doesn't.
So basically I am only seeing the bug because I was doing it wrong. Is it still worth reporting?
from biocparallel.
Actually never mind. I'm getting inconsistent results, so now I don't know what's going on. I will investigate further, but for now, disregard my previous comment.
from biocparallel.
https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15322
from biocparallel.
Looks like the solution is to use setLoadAction
instead of defining a .onLoad function: https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15322#c1
I'll try this out and see if it fixes things.
from biocparallel.
Ok, I switched it over: c9a5c03
Everything seems to work now.
from biocparallel.
On 05/27/2013 05:36 PM, Ryan Thompson wrote:
Ok, I switched it over: c9a5c03
c9a5c03Everything seems to work now.
OK great, thanks for pursuing this; I'll merge this in the next two days. Martin
—
Reply to this email directly or view it on GitHub
#5 (comment).
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109
Location: Arnold Building M1 B861
Phone: (206) 667-2793
from biocparallel.
Ok, in the mean time, I will work on eliminating any warnings related to missing documentation and other cleanup. I'll post here when I think it's ready to merge.
from biocparallel.
Ok, I'd say it's ready to merge. With this and my other pull request, there are no more warnings from R CMD check.
from biocparallel.
Should have closed this with the pull request; thanks.
from biocparallel.
Related Issues (20)
- Error in serialize(data, node$con, xdr = FALSE) : ignoring SIGPIPE signal HOT 5
- Performance (speed) degradation in MulticoreParam with default force.G = TRUE HOT 3
- Nested parallellization question HOT 6
- stop.on.error = FALSE for DoParam doesn't work as expected HOT 2
- Troubles with bplapply within function (using SnowParam on Windows) HOT 6
- MulticoreParam bplapply unable to restart upon interrupt HOT 1
- Increase depth of traceback beyond `tryCatch()` for bp* functions - possible enhancement HOT 1
- The running time isn't reduced when using bplapply()? HOT 3
- BiocParallel errors HOT 4
- Handle worker abort better HOT 1
- move Rmpi to Enhances: HOT 1
- "foreach" %in% loadedNamespaces() instead of "package:foreach" %in% search()? HOT 1
- BiocParallel errors:could not find function ".OLD_read_block" HOT 11
- I meet a error when I use BiocParallel HOT 6
- BiocParallel : long vectors are not supported in .C() HOT 5
- BiocParallel for parallelization in BEER: Error and GPU Compatibility HOT 8
- BatchtoolsParam fails to propagate errors in bpiterate HOT 2
- Extremely minor: typo in docs? man/MulticoreParam-class.Rd HOT 1
- BiocParallel socketConnection error HOT 5
- strategy of tasks in MulticoreParam HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from biocparallel.