Skip to content
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

Resources: syntax #1

Open
HenrikBengtsson opened this issue Nov 1, 2021 · 6 comments
Open

Resources: syntax #1

HenrikBengtsson opened this issue Nov 1, 2021 · 6 comments

Comments

@HenrikBengtsson
Copy link
Collaborator

How to support the different cases of globals:

resources = globals:FALSE
resources = globals:all() - x - y
resources = globals:all() - x + y
resources = globals:all() + {{ vars }}
resources = globals:(all() + {{ vars }} - x)
@HenrikBengtsson
Copy link
Collaborator Author

HenrikBengtsson commented Nov 5, 2021

future(..., resources = . ~ gpu & !fork & ram:32*GiB & file:/path/to/data.csv & time:00:30:25)

Flags:

  • localhost
  • fork
  • gpu

Filesystem:

  • file
  • folder
  • file permissions
  • file identifiers, e.g. size, md5
  • TMPDIR size

Networking:

  • internet
  • URL

Needs:

  • packages
  • package version
  • R version (sorry for 'base' package version)
  • R capabilities()
  • RNG

Consumables:

  • ram
  • runtime

Genetic consumables (GREs):

  • scratch
  • licenses

Preferables:

  • globals cache
  • file cache
  • localhost

@HenrikBengtsson
Copy link
Collaborator Author

HenrikBengtsson commented Nov 7, 2021

> foo <- function(resources) resources
> res <- foo(resources= ~ gpu && !fork && r >= 3.2 && file("foo.txt") && ram <= 32*GiB && time <= 00:30:25 && scratch <= 256*GiB && matlab && capabilities == (jpeg || png) && profmem)
> res
~gpu && !fork && r >= 3.2 && file("foo.txt") && ram <= 32 * GiB && 
    time <= 0:30:25 && scratch <= 256 * GiB && matlab && capabilities == 
    (jpeg || png) && profmem

Or maybe:

> res <- foo(resources= ~ isTRUE({ getRversion() >= "3.2" && file_test("-f", "Makefile") && any(capabilities(c("jpeg", "png"))) && capabilities("profmem") }))
> res
~isTRUE({
    getRversion() >= "3.2" && file_test("-f", "Makefile") && 
        any(capabilities(c("jpeg", "png"))) && capabilities("profmem")
})

OTH, that requires R to evaluate, which means we need to launch R in order know if the resources are met, but can't always do that before the future is assigned to a worker, e.g. a HPC scheduler or a remote machine.

@HenrikBengtsson
Copy link
Collaborator Author

HenrikBengtsson commented Nov 8, 2021

There are different types of "resources":

  1. required - the R worker needs to support these resource specifications in order for the future to be successfully resolved
  2. preferred - the future can be resolved also without these resources, but it will be more efficient if the R worker supported them

Syntax ideas:

  • resources ~ R >= 4.0 & ?gpu - requires R (>= 4.0) and prefer a host with a GPU

@HenrikBengtsson
Copy link
Collaborator Author

HenrikBengtsson commented Nov 22, 2021

resources= ~ gpu && !fork && r >= 3.2 && file("foo.txt") && ram <= 32*GiB && time <= 00:30:25 && scratch <= 256*GiB && matlab && capabilities == (jpeg || png) && profmem

resources= ~ gpu() && !fork() && r >= 3.2 && file("foo.txt") && ram(32*GiB) && time(00:30:25) && scratch(256*GiB) && matlab && capabilities(jpeg || png) && profmem()
gpu(nvidia, ram(64*GiB))
os(windows, version(10))
packages(MASS >= 3.2, future)

One problem with NSE is that it'll produce lots of false notes. R CMD check --as-cran will not complain about variables in formulas, e.g.

hello <- function() {
  model <- y ~ x + 1
  message("Hello world!")
  invisible(model)
}

passes with all OK, cf. https://github.com/HenrikBengtsson/teeny/blob/R_CMD_check/formula/R/hello.R.

@HenrikBengtsson
Copy link
Collaborator Author

Are all resources static? Or can a machine have a resource that comes and goes? I guess it could, e.g. a GPU might come and go based on other processes using it

@HenrikBengtsson
Copy link
Collaborator Author

HenrikBengtsson commented Apr 8, 2022

RNG:

~rng
~rng(kind="random.org")

@HenrikBengtsson HenrikBengtsson transferred this issue from another repository May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant