-
Notifications
You must be signed in to change notification settings - Fork 3
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
use same package versions on cluster machines as source #19
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
73f1f84
copy packages instead of install
eliotmcintire e4796d4
bugfixes for e.g. terra
eliotmcintire 6bb3c22
put checks in cleanUpSpreadFirePoints
eliotmcintire 8be2d11
packageCopying -- more
eliotmcintire d37f752
try using `spread` in objFunInner instead of `spread2`
eliotmcintire 4962e53
terra-ization in objFunInner
eliotmcintire File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,6 +97,7 @@ | |
.verbose, | ||
visualizeDEoptim, | ||
.plotSize = list(height = 1600, width = 2000)) { | ||
if (isTRUE(is.na(cores))) cores <- NULL | ||
origBlas <- blas_get_num_procs() | ||
if (origBlas > 1) { | ||
blas_set_num_threads(1) | ||
|
@@ -150,61 +151,79 @@ | |
## Make cluster with just one worker per machine --> don't need to do these steps | ||
# multiple times per machine, if not all 'localhost' | ||
revtunnel <- FALSE | ||
neededPkgs <- c("kSamples", "magrittr", "raster", "data.table", | ||
"SpaDES.tools", "fireSenseUtils") | ||
|
||
# browser() | ||
if (!identical("localhost", unique(cores))) { | ||
revtunnel <- ifelse(all(cores == "localhost"), FALSE, TRUE) | ||
repos <- c("https://predictiveecology.r-universe.dev", getOption("repos")) | ||
|
||
coresUnique <- setdiff(unique(cores), "localhost") | ||
message( | ||
"Making sure packages with sufficient versions installed and loaded on: ", | ||
paste(coresUnique, collapse = ", ") | ||
) | ||
st <- system.time({ | ||
cl <- parallelly::makeClusterPSOCK(coresUnique, revtunnel = revtunnel, rscript_libs = libPath) | ||
}) | ||
packageVersionFSU <- packageVersion("fireSenseUtils") | ||
packageVersionST <- packageVersion("SpaDES.tools") | ||
clusterExport(cl, list("libPath", "logPath", "packageVersionFSU", "packageVersionST"), envir = environment()) | ||
|
||
parallel::clusterEvalQ( | ||
cl, | ||
{ | ||
# If this is first time that packages need to be installed for this user on this machine | ||
# there won't be a folder present that is writable | ||
if (!dir.exists(libPath)) { | ||
dir.create(libPath, recursive = TRUE) | ||
aa <- Require::pkgDep(unique(c("dqrng", "PredictiveEcology/SpaDES.tools@development", | ||
"PredictiveEcology/fireSenseUtils@development", "qs", "RCurl", neededPkgs)), recursive = TRUE) | ||
revtunnel <- ifelse(all(cores == "localhost"), FALSE, TRUE) | ||
|
||
coresUnique <- setdiff(unique(cores), "localhost") | ||
message( | ||
"Making sure packages with sufficient versions installed and loaded on: ", | ||
paste(coresUnique, collapse = ", ") | ||
) | ||
st <- system.time({ | ||
cl <- parallelly::makeClusterPSOCK(coresUnique, revtunnel = revtunnel, rscript_libs = libPath) | ||
}) | ||
packageVersionFSU <- packageVersion("fireSenseUtils") | ||
packageVersionST <- packageVersion("SpaDES.tools") | ||
clusterExport(cl, list("libPath", "logPath", "packageVersionFSU", "packageVersionST", "repos"), | ||
envir = environment()) | ||
|
||
parallel::clusterEvalQ( | ||
cl, | ||
{ | ||
# If this is first time that packages need to be installed for this user on this machine | ||
# there won't be a folder present that is writable | ||
if (!dir.exists(libPath)) { | ||
stop("libPath directory creation failed.\n", | ||
"Try creating on each machine manually, using e.g.,\n", | ||
" mkdir -p ", libPath) | ||
dir.create(libPath, recursive = TRUE) | ||
|
||
if (!dir.exists(libPath)) { | ||
stop("libPath directory creation failed.\n", | ||
"Try creating on each machine manually, using e.g.,\n", | ||
" mkdir -p ", libPath) | ||
} | ||
} | ||
} | ||
|
||
if (!"Require" %in% rownames(utils::installed.packages())) { | ||
remotes::install_github("PredictiveEcology/Require@development") | ||
} else if (packageVersion("Require") < "0.1.0.9000") { | ||
remotes::install_github("PredictiveEcology/Require@development") | ||
} | ||
# logPath <- Require::checkPath(dirname(logPath), create = TRUE) | ||
logPath <- dir.create(dirname(logPath), showWarnings = FALSE, recursive = TRUE) | ||
|
||
message(Sys.info()[["nodename"]]) | ||
|
||
## Use the binary packages for install if Ubuntu & Linux | ||
Require::setLinuxBinaryRepo() | ||
#scp -r /home/emcintir/.local/share/R/Edehzhie/packages/x86_64-pc-linux-gnu/4.3/fireSenseUtils emcintir@10.│^C | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oops |
||
#20.0.97:/home/emcintir/.local/share/R/Edehzhie/packages/x86_64-pc-linux-gnu/4.3 | ||
|
||
logPath <- Require::checkPath(dirname(logPath), create = TRUE) | ||
needRequire <- FALSE | ||
if (!"Require" %in% rownames(utils::installed.packages())) { | ||
needRequire <- TRUE | ||
} else if (packageVersion("Require") < "0.1.0.9000") { | ||
needRequire <- TRUE | ||
} | ||
if (isTRUE(needRequire)) | ||
install.packages("Require", repos = repos, lib = libPath) | ||
|
||
message(Sys.info()[["nodename"]]) | ||
## Use the binary packages for install if Ubuntu & Linux | ||
# Require::setLinuxBinaryRepo() | ||
|
||
## This will install the versions of SpaDES.tools and fireSenseUtils that are on the main machine | ||
Require::Require( | ||
c( | ||
"dqrng", | ||
paste0("PredictiveEcology/SpaDES.tools@development (>=", packageVersionST, ")"), | ||
paste0("PredictiveEcology/fireSenseUtils@development (>=", packageVersionFSU, ")") | ||
), | ||
upgrade = FALSE | ||
) | ||
} | ||
) | ||
parallel::stopCluster(cl) | ||
if (FALSE) { | ||
## This will install the versions of SpaDES.tools and fireSenseUtils that are on the main machine | ||
Require::Require(c("dqrng", "SpaDES.tools", "fireSenseUtils"), repos = repos) | ||
} | ||
|
||
} | ||
) | ||
pkgsNeeded <- unique(Require::extractPkgName(unname(unlist(aa)))) | ||
out <- lapply(setdiff(unique(cores), "localhost"), function(ip) { | ||
system(paste0("rsync -aruv --update ", paste(file.path(libPath, pkgsNeeded), collapse = " "), | ||
" ", ip, ":", libPath)) | ||
}) | ||
|
||
parallel::stopCluster(cl) | ||
} | ||
|
||
## Now make full cluster with one worker per core listed in "cores" | ||
|
@@ -237,14 +256,14 @@ | |
} | ||
x | ||
}) | ||
filenameForTransfer <- Require::normPath(tempfile(fileext = ".qs")) | ||
Require::checkPath(dirname(filenameForTransfer), create = TRUE) # during development, this was deleted accidentally | ||
filenameForTransfer <- normalizePath(tempfile(fileext = ".qs"), mustWork = FALSE, winslash = "/") | ||
dir.create(dirname(filenameForTransfer), recursive = TRUE, showWarnings = FALSE) # during development, this was deleted accidentally | ||
qs::qsave(objsToCopy, file = filenameForTransfer) | ||
stExport <- system.time({ | ||
outExp <- clusterExport(cl, varlist = "filenameForTransfer", envir = environment()) | ||
}) | ||
out11 <- clusterEvalQ(cl, { | ||
Require::checkPath(dirname(filenameForTransfer), create = TRUE) | ||
dir.create(dirname(filenameForTransfer), recursive = TRUE, showWarnings = FALSE) | ||
}) | ||
out <- lapply(setdiff(unique(cores), "localhost"), function(ip) { | ||
st1 <- system.time(system(paste0("rsync -a ", filenameForTransfer, " ", ip, ":", filenameForTransfer))) | ||
|
@@ -277,13 +296,12 @@ | |
} | ||
message("it took ", round(stMoveObjects[3], 2), "s to move objects to nodes") | ||
message("loading packages in cluster nodes") | ||
|
||
clusterExport(cl, "neededPkgs", envir = environment()) | ||
stPackages <- system.time(parallel::clusterEvalQ( | ||
cl, | ||
{ | ||
for (i in c( | ||
"kSamples", "magrittr", "raster", "data.table", | ||
"SpaDES.tools", "fireSenseUtils" | ||
)) { | ||
for (i in neededPkgs) { | ||
library(i, character.only = TRUE) | ||
} | ||
message("loading ", i, " at ", Sys.time()) | ||
|
@@ -417,6 +435,7 @@ | |
mutuallyExclusive = mutuallyExclusive, | ||
doAssertions = doObjFunAssertions, | ||
Nreps = Nreps, | ||
plot.it = FALSE, | ||
controlForCache = controlForCache, | ||
objFunCoresInternal = objFunCoresInternal, | ||
thresh = thresh, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to be careful allowing Require to install update anything without specifying exact versions (i.e., those installed on the main node); otherwise we get mismatched packages on each node.
Can you confirm that the versions installed are exactly the same, and that it's not just grabbing the latest versions of everything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't installing them ... this is just determining which to use. It copies them from the source folder. Previously this was not checking versions. Now it is using the exact version because they are being copied.