slurm_job {slurmR}R Documentation

Creating Slurm jobs

Description

Utilities to deal with objects of class slurm_job. The function new_slurm_job, which is mostly intended to be for internal used, creates an object of class slurm_job. The function last_submitted_job returns the last submitted job in the current R session, and the functions read/write_slurm_job are utility functions to read and write R jobs respectively.

Usage

new_slurm_job(
  call,
  rscript,
  bashfile,
  robjects,
  njobs,
  opts_job,
  opts_r,
  hooks = NULL
)

## S3 method for class 'slurm_job'
print(x, ...)

read_slurm_job(path)

write_slurm_job(x, path = NULL)

last_submitted_job()

last_job()

Arguments

call

The original call

rscript, bashfile

The R script and bash file path.

robjects

A character vector of R objects that will be imported in the job.

njobs

Integer. Number of jobs to start (array).

opts_job, opts_r

List. In the case of opts_job, a list of parameters passed to sbatch. opts_r is a list of parameters used within R. Both can be retrieved by opts_slurmR⁠$get_opts_job()⁠ and opts_slurmR⁠$get_opts_r()⁠ respectively.

hooks

List of functions. To be called on the collected results after it finalizes.

x

An object of class slurm_job.

...

Further arguments passed to the method.

path

Character scalar. Path to either a directory with a job.rds file, or directly to a job.rds file.

Details

In the case of the function new_slurm_job, besides of creating the object of class slurm_job, the function calls write_slurm_job and stores the job object in an rds class file. The name and location of the saved rds file is generated using the function snames("job").

The read_slurm_job can help the user recovering a previously saved slurm_job object. If path is a directory, then the function will assume that the file that is looking for lives within that directory and is named job.rds. Otherwise, if a file, then it will read it directly. In any case, it will check that the read object is an object of class slurm_job.

The write_slurm_job function simply takes a slurm_job object and saves it in, if path is not specified, whatever the job$options$chdir folder is under the name job.rds. If a path is specified, the it is directly passed to saveRDS().

The las_submitted_job function will return the latest slurm_job object that was submitted via sbatch in the current session. The last_job function is just an alias of the later. If no job has been submitted, then the resulting value will be NULL.

Value

An environment of class slurm_job. This has the following items:

In the case of the function write_slurm_job, it returns the full path to the file.

Examples

## Not run: 
# The last_job function can be handy when `plan = "collect"` in a called,
# for example
job <- Slurm_lapply(1:1000, function(i) runif(100), njobs = 2, plan = "collect")

# Post collection analysis
status(last_job())

## End(Not run)

[Package slurmR version 0.5-4 Index]