Giter Club home page Giter Club logo

Comments (2)

DavisVaughan avatar DavisVaughan commented on July 28, 2024

Definitely. I'm planning on cleaning that up in the next few days. It was getting to be a hassle. This is a nice way to do so. Thanks!

from furrr.

DavisVaughan avatar DavisVaughan commented on July 28, 2024

@hadley, I've updated furrr to include future_options() to build a set of options. This greatly streamlined the interface (and the docs) as we now have:

future_map(.x, .f, ..., .progress = FALSE, .options = future_options())

Thanks for the advice!

Here are a few examples of the interface in practice:

library(furrr)
#> Loading required package: future

# If you use multicore (on Mac) you can actually still access variables even though you 
# don't explicitly pass them with `globals`. This has something to do with it being a forked process.
plan(multisession)
#### Selective exporting of variables

# Export only x
x <- 1
y <- 1

future_map(1, ~x) # black magic
#> [[1]]
#> [1] 1

future_map(1, ~x, .options = future_options(globals = "y")) # no magic
#> Error in ...future.f(...future.x_jj, ...): object 'x' not found

future_map(1, ~x, .options = future_options(globals = "x")) # no magic
#> [[1]]
#> [1] 1
#### Selective exporting of packages

future_map(1, ~tibble(x = 1), .options = future_options(packages = "tibble")) # no magic
#> [[1]]
#> # A tibble: 1 x 1
#>       x
#>   <dbl>
#> 1     1

library(tibble)
future_map(1, ~tibble(x = 1)) # magic
#> [[1]]
#> # A tibble: 1 x 1
#>       x
#>   <dbl>
#> 1     1

Created on 2018-05-09 by the reprex package (v0.2.0).

from furrr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.