Skip to content

Commit

Permalink
Merge pull request #17 from A2-ai/documentation
Browse files Browse the repository at this point in the history
Documentation
  • Loading branch information
mduncans authored Nov 4, 2024
2 parents 0ee091d + 2b68b21 commit 31a8feb
Show file tree
Hide file tree
Showing 16 changed files with 146 additions and 160 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: slurmtools
Title: slurm tooling
Version: 0.0.0.9000
Version: 0.0.0.9001
Authors@R: c(person("Devin", "Pastoor", , "[email protected]", role = c("aut", "cre")),
person("Jenna", "Elwing", email = "[email protected]", role = "aut"),
person("Matthew", "Smith", email = "[email protected]", role = "aut"))
Expand Down
4 changes: 2 additions & 2 deletions R/attach.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ slurmtools_options_message <- function() {
}

#format .onAttach message
msg <- ""
msg <- "\n\n"
if (length(set_options)) {
msg <- paste0(
msg,
Expand All @@ -59,6 +59,6 @@ slurmtools_options_message <- function() {
)
}

msg
paste0(msg, "\n\n")
}

26 changes: 23 additions & 3 deletions R/get-jobs.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
utils::globalVariables(c("user_name"))

# Function to parse each job into a tibble row
#' Function to parse each job into a tibble row
#'
#' @param job output from parse_jobs_json
#'
#' @return tibble of parsed jobs
#' @keywords internal
#' @noRd
parse_job_to_row <- function(job) {
# check options for squeue version
# alter parsing based on result
Expand Down Expand Up @@ -37,6 +43,13 @@ parse_job_to_row <- function(job) {
)
}

#' Function to transform squeue --json output into named list
#'
#' @param .json output from squeue --json call
#'
#' @return list of parsed output
#' @keywords internal
#' @noRd
parse_jobs_json <- function(.json) {
if (!length(.json$jobs)) {
empty <- tibble::tibble(
Expand All @@ -57,9 +70,16 @@ parse_jobs_json <- function(.json) {
purrr::list_rbind(purrr::map(.json$jobs, parse_job_to_row))
}

#' get slurm jobs
#' @param user string of user id to filter results by
#' Gets the jobs run on slurm as a tibble
#'
#' @param user optional user name to filter jobs only submitted by user
#'
#' @return a tibble containing the jobs submitted to slurm
#' @export
#'
#' @examples \dontrun{
#' get_slurm_jobs()
#' }
get_slurm_jobs <- function(user = NULL){

cmd <- list(cmd = Sys.which("squeue"), args = "--json")
Expand Down
21 changes: 18 additions & 3 deletions R/get-partitions.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ partition_cache <- new.env(parent = emptyenv())
#' get list of each partition's number of CPUs and memory
#'
#' @return the raw partition-cpu-memory string output from `sinfo`
#' @keywords internal
#' @noRd
run_sinfo <- function() {
sinfobin <- Sys.which("sinfo")
if (!nzchar(sinfobin)) {
Expand All @@ -29,9 +31,10 @@ run_sinfo <- function() {
#' [process_slurm_partitions()]
#'
#' @param cache optional argument to forgo caching
#'
#' @return the processed table of each partition's
#' number of CPUs and memory
#' @keywords internal
#' @noRd
lookup_partitions_by_cpu <- function(cache = TRUE) {
avail_cpus <- if(cache) {
if (is.null(partition_cache[["run_sinfo"]])) {
Expand All @@ -57,6 +60,8 @@ lookup_partitions_by_cpu <- function(cache = TRUE) {
#'
#' @return the table such that the default partition will be first
#' and will have the asterisk removed
#' @keywords internal
#' @noRd
process_slurm_partitions <- function(table){
all_partitions <- table$PARTITION
is_default_partition <- grepl('\\*$', x = all_partitions, )
Expand All @@ -69,12 +74,16 @@ process_slurm_partitions <- function(table){
return(table)
}


#' get list of partition names for the given cluster
#' Gets the available slurm partitions the user can use.
#'
#' @param cache optional argument to forgo caching
#'
#' @return vector of available partitions
#' @export
#'
#' @examples \dontrun{
#' get_slurm_partitions
#' }
get_slurm_partitions <- function(cache = TRUE) {
table <- if (cache) {
if (is.null(partition_cache[["partition_by_cpu"]])) {
Expand Down Expand Up @@ -105,6 +114,9 @@ get_slurm_partitions <- function(cache = TRUE) {
#' @param cache optional argument to forgo caching
#'
#' @return string with suggestion upon [check_slurm_partitions()] error
#'
#' @keywords internal
#' @noRd
partition_advice <- function(ncpu, partition, avail_cpus_table, cache) {

sorted_table <- avail_cpus_table %>% dplyr::filter(CPUS >= ncpu) %>% dplyr::arrange(CPUS, MEMORY)
Expand All @@ -126,6 +138,9 @@ partition_advice <- function(ncpu, partition, avail_cpus_table, cache) {
#' @param partition name of partition requested by user
#' @param cache optional argument to forgo caching
#'
#' @keywords internal
#' @noRd
#'
#' @examples \dontrun{
#' check_slurm_partitions(17, "cpu2mem4gb")
#' check_slurm_partitions(3, "cpu2mem4gb")
Expand Down
26 changes: 25 additions & 1 deletion R/slurmtools-package.R → R/slurmtools.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
#' @keywords internal
#' slurmtools: An R package for easily submitting NONMEM jobs to slurm.
#'
#' This package aims to ease the submission and monitoring of NONMEM jobs running
#' on slurm.
#'
#' @section submitting jobs:
#' \itemize{
#' \item \code{\link{submit_nonmem_model}}: Submits a job to slurm
#' \item \code{\link{generate_nmm_config}}: Generates a NONMEMmonitor config
#' file
#' }
#'
#' @section monitoring jobs:
#' \itemize{
#' \item \code{\link{get_slurm_jobs}}: Gives a table of submitted jobs to slurm
#' that shows status and other information given with `squeue`
#' }
#'
#' @section slurm partitions:
#' \itemize{
#' \item \code{\link{get_slurm_partitions}}: Gives a vector of available
#' partitions a user can submit jobs to.
#' }
#'
#' @name slurmtools
"_PACKAGE"

## usethis namespace: start
Expand Down
17 changes: 8 additions & 9 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@ navbar:
left:
- intro
- reference
- articles
right:
- search
- github
- lightswitch
components:
reference:
text: Reference
href: reference/index.html
github:
icon: fa-github fa-lg
href: https://github.com/a2-ai/slurmtools
intro:
articles:
text: Get Started
menu:
- text: Running NONMEM
Expand All @@ -31,18 +30,18 @@ navbar:
href: articles/custom-alerts.html
- text: Slack Alerts
href: articles/slack-alerts.html
github:
icon: fa-github fa-lg
href: https://github.com/a2-ai/slurmtools

reference:
- title: Data Processing Functions
contents:
- submit_nonmem_model
- generate_nmm_config
- get_slurm_jobs
- get_slurm_partitions
- check_slurm_partitions
- lookup_partitions_by_cpu
- partition_advice
- process_slurm_partitions
- run_sinfo
- slurmtools

articles:
- title: Vignettes
Expand Down
28 changes: 0 additions & 28 deletions man/check_slurm_partitions.Rd

This file was deleted.

14 changes: 11 additions & 3 deletions man/get_slurm_jobs.Rd

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

12 changes: 10 additions & 2 deletions man/get_slurm_partitions.Rd

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

23 changes: 0 additions & 23 deletions man/lookup_partitions_by_cpu.Rd

This file was deleted.

30 changes: 0 additions & 30 deletions man/partition_advice.Rd

This file was deleted.

18 changes: 0 additions & 18 deletions man/process_slurm_partitions.Rd

This file was deleted.

14 changes: 0 additions & 14 deletions man/run_sinfo.Rd

This file was deleted.

Loading

0 comments on commit 31a8feb

Please sign in to comment.