Re: [Bioc-devel] BiocParallel: Best standards for passing locally assigned variables/functions, e.g. a bpExport()?

2013-11-06 Thread Martin Morgan
On 11/04/2013 11:34 AM, Michael Lawrence wrote: The dynamic nature of R limits the extent of these checks. But as Ryan has noted, a simple sanity check goes a long way. If what he has done could be extended to the rest of the search path (people always forget to attach packages), I think we've

Re: [Bioc-devel] BiocParallel: Best standards for passing locally assigned variables/functions, e.g. a bpExport()?

2013-11-05 Thread luke-tierney
The 'foreach' framework does this sort of analysis using codetools at least in part. You may be able to build on what they have. luke On Mon, 4 Nov 2013, Ryan wrote: On 11/4/13, 11:05 AM, Gabriel Becker wrote: As a side note, I'm not sure that existence of a symbol is sufficient (it

Re: [Bioc-devel] BiocParallel: Best standards for passing locally assigned variables/functions, e.g. a bpExport()?

2013-11-04 Thread Ryan
Actually, the check that I proposed is only supposed to check for usage of user-defined variables, not variables from packages. Truthfully, though, I guess I'm not the right person to work on this, since in practice I use forked processes for the vast majority of my inside-R parallelization,

Re: [Bioc-devel] BiocParallel: Best standards for passing locally assigned variables/functions, e.g. a bpExport()?

2013-11-04 Thread Gabriel Becker
Weird, I guess it needs to be logged in or something. I don't know if the issue is that its in a non-master branch or waht. The repo is fully public and the forCRAN_0.3.5 in branch definitely exists on github. I started chrome (where I'm not logged into github) and got the same 404 error but

Re: [Bioc-devel] BiocParallel: Best standards for passing locally assigned variables/functions, e.g. a bpExport()?

2013-11-04 Thread Ryan Thompson
The code that I wrote intentionally avoids checking for package variables, since I consider that a separate problem. Package variables can be provided to the child by leading the package, whereas user-defined variables must be serialized in the parent and sent to the child. I think I could fairly

Re: [Bioc-devel] BiocParallel: Best standards for passing locally assigned variables/functions, e.g. a bpExport()?

2013-11-04 Thread Gabriel Becker
Ryan, I agree that in some sense it is a different problem, but my point is with a different approach we can easily answer both. The code I posted returns a named character vector of symbol names with package name being the name. This makes it a trivial lookup to determine both a) what symbols

Re: [Bioc-devel] BiocParallel: Best standards for passing locally assigned variables/functions, e.g. a bpExport()?

2013-11-04 Thread Ryan
On 11/4/13, 11:05 AM, Gabriel Becker wrote: As a side note, I'm not sure that existence of a symbol is sufficient (it certainly is necessary). What about situations where the symbol exists but is stale compared to the value in the parent? Are we sure that can never happen? I think this is a

Re: [Bioc-devel] BiocParallel: Best standards for passing locally assigned variables/functions, e.g. a bpExport()?

2013-11-03 Thread Michael Lawrence
An analog to clusterExport is a good idea. To make it even easier, we could have a dynamic environment based on object tables that would catch missing symbols and download them from the parent thread. But maybe there's some benefit to being explicit? Michael On Sun, Nov 3, 2013 at 12:39 PM,

Re: [Bioc-devel] BiocParallel: Best standards for passing locally assigned variables/functions, e.g. a bpExport()?

2013-11-03 Thread Henrik Bengtsson
On Sun, Nov 3, 2013 at 1:29 PM, Michael Lawrence lawrence.mich...@gene.com wrote: An analog to clusterExport is a good idea. To make it even easier, we could have a dynamic environment based on object tables that would catch missing symbols and download them from the parent thread. But maybe

Re: [Bioc-devel] BiocParallel: Best standards for passing locally assigned variables/functions, e.g. a bpExport()?

2013-11-03 Thread Ryan
Here's an easy thing we can add to BiocParallel in the short term. The following code defines a wrapper function withBPExtraErrorText that simply appends an additional message to the end of any error that looks like it is about a missing variable. We could wrap every evaluation in a similar

Re: [Bioc-devel] BiocParallel: Best standards for passing locally assigned variables/functions, e.g. a bpExport()?

2013-11-03 Thread Ryan
Another potential easy step we can do is that if FUN function in the user's workspace, we automatically export that function under the same name in the children. This would make recursive functions just work, but it might be a bit too magical. On 11/3/13, 2:38 PM, Ryan wrote: Here's an easy

Re: [Bioc-devel] BiocParallel: Best standards for passing locally assigned variables/functions, e.g. a bpExport()?

2013-11-03 Thread Gabriel Becker
Henrik, See https://github.com/duncantl/CodeDepends (as used by used by https://github.com/gmbecker/RCacheSuite). It will identify necessarily defined symbols (input variables) for code that is not doing certain tricks (eg get(), mixing data.frame columns and gobal variables in formulas, etc ).

Re: [Bioc-devel] BiocParallel: Best standards for passing locally assigned variables/functions, e.g. a bpExport()?

2013-11-03 Thread Ryan
I guess all we need to do is to detect whether a function would try to access a free variable in the user's workspace, and warn/error if so. It looks like CodeDepends could do that. I could try to come up with an implementation. I guess we would add CodeDepends as an optional dependency for

Re: [Bioc-devel] BiocParallel: Best standards for passing locally assigned variables/functions, e.g. a bpExport()?

2013-11-03 Thread Gabriel Becker
Ryan (et al), FYI: f function() { x = rnorm(x) x } findGlobals(f) [1] = { rnorm x should be in the list of globals but it isn't. ~G sessionInfo() R version 3.0.2 (2013-09-25) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3]

Re: [Bioc-devel] BiocParallel: Best standards for passing locally assigned variables/functions, e.g. a bpExport()?

2013-11-03 Thread Ryan
Ok, here is my attempt at a function to get the list of user-defined free variables that a function refers to: https://gist.github.com/DarwinAwardWinner/7298557 Is uses codetools, so it is subject to the limitations of that package, but for simple examples, it successfully detects when a