Skip to content

Commit

Permalink
Merge pull request #1925 from LaviniaBaumstark/REMIND_release3p4p0
Browse files Browse the repository at this point in the history
remind release 3.4.0
  • Loading branch information
LaviniaBaumstark authored Dec 11, 2024
2 parents 337d130 + 66d8468 commit 2a872bf
Show file tree
Hide file tree
Showing 860 changed files with 8,255 additions and 21,682 deletions.
87 changes: 15 additions & 72 deletions .Rprofile
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,28 @@ local({
# for some reason this also has implications for symlinking into the global cache
Sys.setenv(RENV_PATHS_LIBRARY = "renv/library")

# remind's renv integration previously relied on renv.lock, but now it should generally not be used anymore
# this can safely be removed in January 2024
if (file.exists("renv.lock") && file.exists("README.md") && !file.exists("renv/old_renv.lock")) {
file.rename("renv.lock", "renv/old_renv.lock")
message("moved legacy renv.lock to renv/old_renv.lock")
}

# do not check if library and renv.lock are in sync, because normally renv.lock does not exist
options(renv.config.synchronized.check = FALSE)

source("renv/activate.R")
# always set the renv project to the current directory
Sys.setenv("RENV_PROJECT" = getwd())

# when increasing renvVersion first commit new version's activate script and
# put that commit's hash into the download.file call below
# put that commit's hash into the git checkout call below
renvVersion <- "1.0.7"

# reset renv/activate.R to match renv 1.0.7
gitRoot <- system2("git", c("rev-parse", "--show-toplevel"), stdout = TRUE)
if (Sys.getenv("RESET_RENV_ACTIVATE_SCRIPT", unset = "TRUE") == "TRUE" &&
normalizePath(gitRoot) == normalizePath(".")) {
system2("git", c("checkout", "b83bb1811ff08d8ee5ba8e834af5dd0080d10e66", "--", "renv/activate.R"))
}

source("renv/activate.R")

if (packageVersion("renv") != renvVersion) {
renvLockExisted <- file.exists(renv::paths$lockfile())
renv::install(paste0("renv@", renvVersion))
message("Downloading 'renv/activate.R' of renv version 1.0.7")
download.file("https://raw.githubusercontent.com/remindmodel/remind/b83bb1811ff08d8ee5ba8e834af5dd0080d10e66/renv/activate.R", "renv/activate.R")
if (!renvLockExisted) {
unlink(renv::paths$lockfile())
}
Expand All @@ -36,30 +38,10 @@ if (!"https://rse.pik-potsdam.de/r/packages" %in% getOption("repos")) {
if (isTRUE(rownames(installed.packages(priority = "NA")) == "renv")) {
message("R package dependencies are not installed in this renv, installing now...")
renv::install("rmarkdown", prompt = FALSE) # rmarkdown is required to find dependencies in Rmd files
renv::hydrate() # auto-detect and install all dependencies
renv::hydrate(prompt = FALSE, report = FALSE) # auto-detect and install all dependencies
message("Finished installing R package dependencies.")
}

# bootstrapping python venv, will only run once after remind is freshly cloned
if (!dir.exists(".venv/")
&& (Sys.which("python3") != ""
|| (Sys.which("python.exe") != ""
&& suppressWarnings(isTRUE(startsWith(system2("python.exe", "--version", stdout = TRUE), "Python 3")))
))) {
message("Python venv is not available, setting up now...")
# use system python to set up venv
if (.Platform$OS.type == "windows") {
system2("python.exe", c("-mvenv", ".venv"))
pythonInVenv <- normalizePath(file.path(".venv", "Scripts", "python.exe"), mustWork = TRUE)
} else {
system2("python3", c("-mvenv", ".venv"))
pythonInVenv <- normalizePath(file.path(".venv", "bin", "python"), mustWork = TRUE)
}
# use venv python to install dependencies in venv
system2(pythonInVenv, c("-mpip", "install", "--upgrade", "pip", "wheel"))
system2(pythonInVenv, c("-mpip", "install", "-r", "requirements.txt"))
}

# Configure locations of REMIND input data
# These can be located in directories on the local machine, remote directories,
# or default directories on the cluster.
Expand All @@ -74,51 +56,12 @@ if (!dir.exists(".venv/")
# REMIND_repos_dirs="C:\my\first\path;D:\my\second\path"
remindReposDirs <- Sys.getenv("REMIND_repos_dirs")

# for scp targets, you need to set three environment variables
# on linux e.g. (separate multiple paths by semicolons)
# REMIND_repos_scp="scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output;scp://cluster.pik-potsdam.de/p/projects/remind/inputdata/CESparametersAndGDX"
# REMIND_repos_scp_user="myusername" # use your user name on the scp target, e.g. the cluster
# REMIND_repos_scp_key="/home/myusername/.ssh/id_ed25519" # path to your your ssh private key on your laptop
# on windows e.g.
# REMIND_repos_scp="scp://cluster.pik-potsdam.de/p/projects/rd3mod/inputdata/output;scp://cluster.pik-potsdam.de/p/projects/remind/inputdata/CESparametersAndGDX"
# REMIND_repos_scp_user="myusername" # use your user name on the scp target, e.g. the cluster
# REMIND_repos_scp_key="C:\Users\myusername\.ssh\id_ed25519" # path to your your ssh private key on your laptop
remindReposSCP <- Sys.getenv("REMIND_repos_scp") # scp URL
remindReposSCPUser <- Sys.getenv("REMIND_repos_scp_user") # ssh user name
remindReposSCPKey <- Sys.getenv("REMIND_repos_scp_key") # ssh key path

# unless specified otherwise, use cluster defaults
use_cluster_defaults <- TRUE

# add local directories, if any
if ("" != remindReposDirs) {
directories <- unlist(strsplit(remindReposDirs, .Platform$path.sep,
fixed = TRUE))
directories <- unlist(strsplit(remindReposDirs, .Platform$path.sep, fixed = TRUE))
directoriesList <- rep(list(NULL), length(directories))
names(directoriesList) <- directories

options(remind_repos = c(options("remind_repos")[[1]], directoriesList))
use_cluster_defaults <- FALSE
}

# add remote directories, if any remote directory and username and SSH key are set
if ("" != remindReposSCP && "" != remindReposSCPUser && "" != remindReposSCPKey) {
SCPUrls <- unlist(strsplit(remindReposSCP, ";", fixed = TRUE))
config <- list(list(username = remindReposSCPUser, ssh_private_keyfile = remindReposSCPKey))
for (SCPUrl in SCPUrls) {
names(config) <- SCPUrl
options(remind_repos = c(options("remind_repos")[[1]], config))
}
use_cluster_defaults <- FALSE
}

# default to cluster directories
if (use_cluster_defaults &&
all(file.exists(c("/p/projects/rd3mod/inputdata/output",
"/p/projects/remind/inputdata/CESparametersAndGDX")))) {
options(remind_repos = list(
"/p/projects/rd3mod/inputdata/output" = NULL,
"/p/projects/remind/inputdata/CESparametersAndGDX" = NULL))
}

# Include local calibration results, if they exist, from either the main
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-case-conflict
- id: check-json
Expand Down
253 changes: 0 additions & 253 deletions .zenodo.json

This file was deleted.

Loading

0 comments on commit 2a872bf

Please sign in to comment.