knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-", eval = FALSE )
The goal of condor is to run R batch commands in HTCondor
on a remote cluster directly from a local terminal or RStudio
work environment.
You can install condor from github with:
# install.packages("devtools") devtools::install_github("yuliasidi/condor")
~
) create the subdirectory ~/.ssh
if it is not already theremkdir ~/.ssh
~/.ssh
called authorized_keys
touch ~/.ssh/authorized_keys
cat ~/.ssh/id_rsa.pub | pbcopy
(mac)~/.ssh/authorized_keys
echo '[PASTE CONTENTS OF CLIPBOARD]' > ~/.ssh/authorized_keys
library(condor) library(ssh)
Populate package template and create Rcalcpi.condor
in example
subdir.
condor::build_template( file = 'calcpi.R', args = c('$(Process)'), tag = 'pi', jobs = 5, init_dir = 'jobs/run', template_file = 'example/Rcalcpi.condor', job_type = 'test')
Lines in file that will be run on the cluster
readLines(system.file('example/calcpi.R',package='condor'))
Lines in the populated condor file
readLines(system.file('example/Rcalcpi.condor',package='condor'))
Connect to ssh
session <- ssh::ssh_connect(Sys.getenv('UCONN_USER'))
Upload files needed for the job to the cluster
ssh::scp_upload(session, files = c('example/calcpi.R', 'example/Rcalcpi.condor', 'example/emailMyself.txt'), to = '~' )
Create directories needed for job outputs
condor::create_dirs(session, file = 'example/Rcalcpi.condor')
Submit the jobs
condor::condor_submit(session,'Rcalcpi.condor')
condor::condor_q(session)
condor::condor_rm(session,'5000.1')
Retrieve the files
condor::pull(session, from = c('jobs/run/log', 'jobs/run/out', 'jobs/run/err', 'jobs/run/*.rds'), to = c('output', 'output', 'output', 'output/data'))
Remove files from the cluster
condor::cleanup_remote(session)
Collect output from the local into a single object
RETURN <- purrr::map( list.files(path = "example/output/data",full.names = TRUE), readRDS )
Remove files from the local machine
condor::cleanup_local(dir = 'example/output',tag = 'pi')
Close ssh connection
ssh::ssh_disconnect(session)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.