Skip to content

Commit

Permalink
Small ui tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
richfitz committed Dec 8, 2023
1 parent be4a252 commit 8d265cc
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 5 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export(hermod_task_eval)
export(hermod_task_result)
export(hermod_task_status)
export(hermod_task_submit)
export(windows_credentials)
20 changes: 20 additions & 0 deletions R/windows.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
##' Register DIDE windows credentials.
##'
##' In order to be able to communicate with the Windows DIDE HPC
##' system, we need to be able to communicate with the HPC portal
##' (<https::mrcdata.dide.ic.ac.uk/hpc>), and for this we need your
##' **DIDE** password and username. This is typically, but not always,
##' the same as your Imperial credentials. We store this information
##' securely using the [keyring](https://keyring.r-lib.org/) package,
##' so when unlocking your credentials you will be prompted for your
##' **computer** password, which might differ from either your DIDE or
##' Imperial password if you are not on a windows machine.
##'
##' @title DIDE windows credentials
##'
##' @return Nothing, these functions are called for their side effects.
##'
##' @export
windows_credentials <- function() {
ensure_package("hermod.windows")$dide_credentials()

Check warning on line 19 in R/windows.R

View check run for this annotation

Codecov / codecov/patch

R/windows.R#L19

Added line #L19 was not covered by tests
}
7 changes: 7 additions & 0 deletions drivers/windows/R/batch.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ template_data <- function(config, path_root) {
"ECHO Removing mapping {{drive}}\nnet use {{drive}} /delete /y",
network_shares_data)

## Semicolon delimited list on windows; see "Managing libraries" in
## https://cran.r-project.org/doc/manuals/r-release/R-admin.html
hermod_library <- paste(unix_path(config$path_lib),
unix_path(config$path_bootstrap),
sep = ";")

list(hostname = hostname(),
date = as.character(Sys.time()),
hermod_version = hermod_version(),
Expand All @@ -46,5 +52,6 @@ template_data <- function(config, path_root) {
network_shares_delete = paste(network_shares_delete, collapse = "\n"),
hermod_root_drive = hermod_root$drive_remote,
hermod_root_path = paste0("\\", windows_path(hermod_root$rel)),
hermod_library = hermod_library,
cluster_name = config$cluster)
}
6 changes: 6 additions & 0 deletions drivers/windows/R/dide_auth.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
##' @export
dide_authenticate <- function() {
if (keyring::keyring_is_locked()) {
cli::cli_text(paste(
"I need to unlock the system keychain in order to load and save your",
"credentials. This might differ from your DIDE password, and will be",
"the password you use to log in to this particular machine"))
keyring::keyring_unlock()
}

Expand Down Expand Up @@ -42,6 +46,8 @@ dide_authenticate <- function() {
i = "Please try again with 'dide_authenticate()'"))
}
keyring::key_set_with_value("hermod/dide/username", password = username)

cli::cli_text("Excellent news! Everything seems to work!")
invisible(credentials(username, password))
}

Expand Down
5 changes: 5 additions & 0 deletions drivers/windows/R/util.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ windows_path <- function(x) {
}


unix_path <- function(x) {
gsub("\\", "/", x, fixed = TRUE)
}


get_system_username <- function() {
Sys.getenv(if (is_windows()) "USERNAME" else "USER", NA_character_)
}
Expand Down
6 changes: 1 addition & 5 deletions drivers/windows/inst/templates/task_run.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ ECHO generated on date: {{date}}
ECHO hermod version: {{hermod_version}}
ECHO running on: %COMPUTERNAME%

REM variables that get pulled in here
REM * hermod_root_drive - the drive alone (e.g., Q:)
REM * hermod_root_path - the relative path incl. drive to folder with hermod/

call setr64_{{r_version}}.bat

{{network_shares_create}}
Expand All @@ -17,7 +13,7 @@ call setr64_{{r_version}}.bat
cd {{hermod_root_path}}
ECHO working directory: %CD%

set R_LIBS_USER=\\fi--didef3.dide.ic.ac.uk\tmp\hermod-testing
set R_LIBS_USER={{hermod_library}}

ECHO this is a single task

Expand Down
5 changes: 5 additions & 0 deletions drivers/windows/tests/testthat/test-batch.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ test_that("batch data creates entries for share drives", {
"network_shares_delete",
"hermod_root_drive",
"hermod_root_path",
"hermod_library",
"cluster_name")
expect_setequal(names(dat), nms)
expect_true(all(vlapply(dat, function(x) is.character(x) && length(x) == 1)))
Expand All @@ -22,6 +23,10 @@ test_that("batch data creates entries for share drives", {

expect_equal(dat$hermod_root_drive, "X:")
expect_equal(dat$hermod_root_path, "\\b\\c")

expect_equal(
dat$hermod_library,
"hermod/lib/windows/4.3.0;//fi--didef3.dide.ic.ac.uk/tmp/hermod-testing")
})


Expand Down
25 changes: 25 additions & 0 deletions man/windows_credentials.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8d265cc

Please sign in to comment.