R/cat_sim_hpc.R

Defines functions cat_sim_csv_hpc cat_sim_log_hpc

Documented in cat_sim_csv_hpc cat_sim_log_hpc

#' Fetch and print simulation log from Peregrine
#'
#' Given a job ID, prints the corresponding `.log` file from Peregrine.
#'
#' @param job_id eight-digit job ID given by Peregrine upon
#' submission.
#'
#' @author Théo Pannetier
#'
#' @name cat_sim_hpc
NULL

#' @export
#' @rdname cat_sim_hpc
cat_sim_log_hpc <- function(
  job_id, pkg = "comrad"
) {
  # Connect to hpc
  session <- ssh::ssh_connect(
    "p282688@peregrine.hpc.rug.nl"
  )

  command <- glue::glue(
    "cat ", path_to_fabrika_hpc(), "{pkg}_data/logs/{pkg}_sim_{job_id}.log; echo \n" # space between multiple jobs
  )

  ssh::ssh_exec_wait(
    session = session,
    command = command
  )

  # Disconnect
  ssh::ssh_disconnect(
    session = session
  )
}

#' @export
#' @rdname cat_sim_hpc
cat_sim_csv_hpc <- function(
  job_id, pkg = "comrad"
) {
  # Connect to hpc
  session <- ssh::ssh_connect(
    "p282688@peregrine.hpc.rug.nl"
  )

  command <- glue::glue(
    "cat ", path_to_fabrika_hpc(), "{pkg}_data/sims/{pkg}_sim_{job_id}.csv; echo \n" # space between multiple jobs"
  )

  ssh::ssh_exec_wait(
    session = session,
    command = command
  )

  # Disconnect
  ssh::ssh_disconnect(
    session = session
  )
}
TheoPannetier/hamr documentation built on Nov. 19, 2022, 3:48 a.m.