-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.length() misses methods in packages #164
Comments
Thanks for the kind words - I'm happy you find it useful and your use case seem really cool - and thanks for this details report and troubleshooting/patching. I can reproduce this and without diving into the details I'd say it's a bug in the future package. I'll look into this and your proposal in more details when I have time - need to create some solid package unit tests etc. Just a quick comment, I think your library("future")
library("greta")
x <- as_data(1:3)
f <- function (i) max(i)
environment(f) <- new.env() ## disconnect from the global environment
future_lapply(1:3, f) so it is not that all objects are scanned / measured - only those somehow connected to the globals identified, which are As a quick workaround, you can disable the check for "too large globals" by using library("future")
library("greta")
x <- as_data(1:3)
f <- function (i) max(i)
future_lapply(1:3, f)
## Error in .subset2(x, kk) : subscript out of bounds
options(future.globals.maxSize = +Inf)
future_lapply(1:3, f)
## [[1]]
## [1] 1
##
## [[2]]
## [1] 2
##
## [[3]]
## [1] 3 |
Ah nice, thanks! Yeah, I found this whilst troubleshooting another bug*, and you're right - it's not an issue for my package code. *my real bug is something cryptic in the intersection of R6, non-standard evaluation, and reticulate that I can only identify by a forked process hanging :/ It doesn't appear to be a future issue though |
Yeah, there are probably quite few things that are really hard to parallelize in R because they're designed / implement to rely on process-specific unique objects such as external pointers, mutable states, connections to other background processes, etc. For instance, connections cannot be serialized and exported to another process (#79). If you find other examples (e.g. reticulate), I'd like to know so at least it can be documented. The basic test is whether it's possible to save an object to file ( |
Somewhat surprisingly, forked process seem to call python just fine, and can use a tensorflow graph defined in the parent process (gist). That's the core of the problem, so it should be feasible with greta! |
Forked processes are probably the most "forgiving" parallel setup. If you can get it to work also with external (PSOCK) processes / background R sessions (e.g. |
Cool thanks, I'll give it a try! |
…t, for certain types of classes then inferred lengths of these objects were incorrect causing internal subset out-of-range issues [#164]
This has now been fixed in the develop branch (with appropriate redundancy tests) and will be part of the next release. Thxs again for troubleshooting this so carefully. |
FYI, future 1.6.2, where this bug is fixed, is now on CRAN. |
future_lapply()
errors when called on a user-defined function, and when an object is in the calling environment that has alength()
method defined in another package.This gives the expected result:
But this errors (x is a
greta_array
object, and greta exports alength.greta_array()
method):The reason is that the sizes of all objects in the environment are checked, and when
.length()
checks for the length ofx
it checks whether another S3 method is available with the call:but that doesn't search the namespaces of attached packages, so the incorrect length is returned, which leads to the
.subset2
error.I've pasted a fix below. I'd be happy to submit it as a PR instead, just let me know.
P.S. future is really really nice! I'm working on integrating it into greta to handle parallelism across MCMC chains, and for running models on remote (GPU-enabled) machines.
A fix:
This now works:
The text was updated successfully, but these errors were encountered: