Comments (5)
from future.
In principle, this might be achieved in future using the resolve function by adding a reduction function argument? That could be an elegant solution.
Segue: value()
is a generic function. The S3 methods for lists, environments, and list environments (listenv package) gather the results for the input set of futures as they get ready. The results are return in the same order as the input. Now, they're implemented to also preserve the relaying order of stdout and conditions, but as soon as they can, they re-output/re-signal them. (There's also a mechanism to drop them from memory when no longer needed).
I can imagine that the value()
function could support an optional reduction argument for doing reduction "on the fly".
The only way I can see a reduction function to work properly is that it reduces the elements in the same order as Reduce()
would do on the final result. That is, we need to reduce the "head" and the next element in order. (This is the same constraint that stdout and conditions are relayed).
Q. In the extreme, if the result of the first element comes in last, then you cannot do any reduction (same for relaying of output and conditions). Is this how you also anticipate this to work? Or do you think there should be support for relaxing this constrain, e.g. reduce as soon as possible?
from future.
Q. In the extreme, if the result of the first element comes in last, then you cannot do any reduction (same for relaying of output and conditions). Is this how you also anticipate this to work? Or do you think there should be support for relaxing this constrain, e.g. reduce as soon as possible?
Oh, I forgot that you already wrote "Because no order is guaranteed, the reduction function must be commutative and
associative". So, yes, that would make it possible to reduce ASAP. And then you wrote "(however, foreach also provides an .inorder argument that caches results locally untill order can be guaranteed)", which I think should also be supported.
So, maybe something like:
fs <- lapply(1:3, function(x) future(sqrt(x))
y <- value(fs, reduce = `+`)
and
fs <- lapply(1:3, function(x) future(sqrt(x))
y <- value(fs, reduce = structure(`-`, inorder = TRUE))
Maybe inorder = TRUE
should be the default, to minimize the risk for silent bugs.
from future.
from future.
What's an example where multicombine/maxcombine is needed? Why wouldn't pairwise reduce be sufficient?
from future.
Related Issues (20)
- CLEANUP: Remove defunct values()
- Not all packages loaded
- Lifecycle warnings are lost when using `future` anywhere after raising a warning HOT 11
- Only "sequental' plan can work HOT 5
- `plan("multisession")` stuck when using Nord VPN HOT 9
- CLEANUP: getOption() speedup only needed in R (< 4.0.0)
- `summarize_size_of_globals` can hang or be very slow with large objects HOT 2
- TESTS: Undo assertions of environment variables may fail on MS Windows HOT 3
- SSH cluster gets only one core running
- setTimeLimit(): varying results in multicore with failing job HOT 7
- Backend API: Formally define the "state" of a future HOT 1
- Set future state to "failed" on orchestration errors?
- plan(multicore) : <FutureError: Failed to retrieve the result of MulticoreFuture (<none>) from the forked worker (on localhost; PID 71). Post-mortem diagnostic: No process exists with this PID, i.e. the forked localhost worker is no longer alive.>
- Removal of 'multiprocess' HOT 1
- Remove multicore worker if process crashed HOT 1
- Unexpected value behavior in Reduce HOT 1
- deleted/invalid
- Error in unserialize(node$con) : MultisessionFuture (future_lapply-4) failed to receive results from cluster RichSOCKnode #4 (PID 436932 on localhost ‘localhost’). The reason reported was ‘error reading from connection’. Post-mortem diagnostic: No process exists with this PID, i.e. the localhost worker is no longer alive. HOT 1
- Issues with foreach and SGE HOT 3
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 future.