Skip to content

Commit

Permalink
Merge pull request #24 from jasenfinch/devel
Browse files Browse the repository at this point in the history
v1.1.0
  • Loading branch information
jasenfinch committed Jan 17, 2023
2 parents 7db4776 + 3f26a53 commit 55f66fe
Show file tree
Hide file tree
Showing 14 changed files with 136 additions and 114 deletions.
38 changes: 23 additions & 15 deletions .github/workflows/pkgdown.yaml
@@ -1,8 +1,10 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
release:
types: [published]
workflow_dispatch:
Expand All @@ -12,36 +14,42 @@ name: pkgdown
jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v1
- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v1
with:
extra-packages: pkgdown
needs: website

- name: Install system dependencies
if: runner.os == 'Linux'
run: |
sudo apt install mono-xbuild
- name: Setup R dependencies
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website

- name: Build site
run: |
rawrr::installRawFileReaderDLLs()
rawrr::buildRawrrExe()
msconverteR::get_pwiz_container()
pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy package
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)'
- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4.4.1
with:
clean: false
branch: gh-pages
folder: docs
40 changes: 28 additions & 12 deletions .github/workflows/test-coverage.yaml
@@ -1,4 +1,4 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
Expand All @@ -15,28 +15,44 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v1
with:
extra-packages: covr

- name: Install system dependencies
if: runner.os == 'Linux'
run: |
sudo apt install mono-xbuild
- name: Setup R dependencies
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr
needs: coverage

- name: Test coverage
run: |
rawrr::installRawFileReaderDLLs()
rawrr::buildRawrrExe()
msconverteR::get_pwiz_container()
covr::codecov(
quiet = FALSE,
clean = FALSE,
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
)
shell: Rscript {0}

- name: Test coverage
run: covr::codecov()
shell: Rscript {0}
- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -6,3 +6,5 @@ grover.txt
doc
Meta
docs
/doc/
/Meta/
4 changes: 2 additions & 2 deletions DESCRIPTION
@@ -1,6 +1,6 @@
Package: grover
Title: Web API Framework for Mass Spectrometry Data Transfer
Version: 1.0.9
Version: 1.1.0
Authors@R:
person(given = "Jasen",
family = "Finch",
Expand Down Expand Up @@ -43,4 +43,4 @@ Suggests:
Remotes: wilsontom/msconverteR,
bioc::rawrr
VignetteBuilder: knitr
RoxygenNote: 7.2.2
RoxygenNote: 7.2.3
3 changes: 3 additions & 0 deletions NAMESPACE
Expand Up @@ -82,12 +82,15 @@ importFrom(plumber,serializer_content_type)
importFrom(progress,progress_bar)
importFrom(purrr,map)
importFrom(purrr,map_chr)
importFrom(purrr,map_lgl)
importFrom(purrr,walk)
importFrom(rawrr,readFileHeader)
importFrom(rawrr,readIndex)
importFrom(readr,read_file)
importFrom(rjson,fromJSON)
importFrom(rjson,toJSON)
importFrom(stats,na.omit)
importFrom(stats,setNames)
importFrom(stringr,regex)
importFrom(stringr,str_c)
importFrom(stringr,str_detect)
Expand Down
10 changes: 10 additions & 0 deletions NEWS.md
@@ -1,3 +1,13 @@
# grover 1.1.0

* Added the `exclude` argument to [`convertDirectory`](https://jasenfinch.github.io/grover/reference/convert.html) and [`runInfo`](https://jasenfinch.github.io/grover/reference/info.html) to exclude raw files matching the specified patterns.

* [`runInfo`](https://jasenfinch.github.io/grover/reference/info.html) now collates the sample information client-side and so the `time_out` argument has been removed.

* The [`grover::groverAPI`](https://jasenfinch.github.io/grover/reference/groverAPI.html) `log_dir` and `temp_dir` argument directories are now created recursively if they do not already exist.

* Improved the naming of the [`grover::groverAPI`](https://jasenfinch.github.io/grover/reference/groverAPI.html) log files to include the current system date.

# grover 1.0.9

* The [`grover::groverAPI`](https://jasenfinch.github.io/grover/reference/groverAPI.html) `log_dir` and `temp_dir` argument directories are now created if they do not already exist.
Expand Down
5 changes: 3 additions & 2 deletions R/allGenerics.R
Expand Up @@ -101,7 +101,8 @@ setGeneric('convertDirectory',function(grover_client,
args = '',
outDir = '.',
zip = TRUE,
overwrite = FALSE){
overwrite = FALSE,
exclude = character()){
standardGeneric('convertDirectory')
})

Expand Down Expand Up @@ -143,7 +144,7 @@ setGeneric('sampleInfo',function(grover_client,instrument,directory,file){

#' @rdname info

setGeneric('runInfo',function(grover_client,instrument,directory,time_out = 100){
setGeneric('runInfo',function(grover_client,instrument,directory,exclude = character()){
standardGeneric('runInfo')
})

Expand Down
11 changes: 6 additions & 5 deletions R/api.R
Expand Up @@ -28,11 +28,11 @@ groverAPI <- function(grover_host,
temp_dir <- path.expand(temp_dir)

if (!dir.exists(log_dir)){
dir.create(log_dir)
dir.create(log_dir,recursive = TRUE)
}

if (!dir.exists(temp_dir)){
dir.create(temp_dir)
dir.create(temp_dir,recursive = TRUE)
}

if (isFALSE(background)) {
Expand Down Expand Up @@ -70,7 +70,6 @@ groverAPI <- function(grover_host,
env$hostListDirectories <- hostListDirectories
env$hostListInstruments <- hostListInstruments
env$hostSampleInfo <- hostSampleInfo
env$hostRunInfo <- hostRunInfo
env$hostTidy <- hostTidy
env$hostFileInfo <- hostFileInfo
env$hostDirectoryFileInfo <- hostDirectoryFileInfo
Expand Down Expand Up @@ -132,7 +131,10 @@ API <- function(host,

message(stringr::str_c('API logs can be found at ',log_dir))

logger::log_appender(logger::appender_tee(tempfile("plumber_", log_dir, ".log")))
logger::log_appender(logger::appender_tee(paste0(log_dir,
'/grover_',
Sys.Date(),
'.log')))

api <- plumber::pr()

Expand All @@ -155,7 +157,6 @@ API <- function(host,
api <- plumber::pr_get(api,'/listDirectories',hostListDirectories)
api <- plumber::pr_get(api,'/listInstruments',hostListInstruments)
api <- plumber::pr_get(api,'/sampleInfo',hostSampleInfo)
api <- plumber::pr_get(api,'/runInfo',hostRunInfo)
api <- plumber::pr_put(api,'/tidy',hostTidy)

api <- plumber::pr_get(api,'/fileInfo',hostFileInfo)
Expand Down
17 changes: 15 additions & 2 deletions R/client-conversion.R
Expand Up @@ -9,6 +9,7 @@
#' @param outDir output directory path for converted files
#' @param zip zip converted file
#' @param overwrite overwrite local mzML files that already exist at the `outDir` path that have the same file name as the raw files to be converted
#' @param exclude A character vector of regular expression patterns for which raw files with matching patterns will not be converted.
#' @return A vector of file paths to converted data files.
#' @importFrom tools file_path_sans_ext
#' @importFrom stringr str_split
Expand All @@ -18,6 +19,8 @@
#' @importFrom progress progress_bar
#' @importFrom crayon yellow bold
#' @importFrom R.utils gzip
#' @importFrom purrr map_lgl
#' @importFrom stats setNames na.omit
#' @export

setMethod('convertFile',signature = 'GroverClient',
Expand Down Expand Up @@ -126,7 +129,8 @@ setMethod('convertDirectory',signature = 'GroverClient',
args = '',
outDir = '.',
zip = TRUE,
overwrite = FALSE){
overwrite = FALSE,
exclude = character()){

outDir <- str_c(outDir,directory,sep = '/')

Expand All @@ -141,9 +145,18 @@ setMethod('convertDirectory',signature = 'GroverClient',

raw_files <- listRawFiles(grover_client,instrument,directory)

raw_files <- raw_files[exclude %>%
map(
~!grepl(.x,raw_files)) %>%
setNames(seq_along(.)) %>%
as_tibble() %>%
split(1:nrow(.)) %>%
map_lgl(all)] %>%
na.omit()

if (isFALSE(overwrite)){
files <- raw_files[!(file_path_sans_ext(raw_files) %in%
file_path_sans_ext(local_files,compression = zip))]
file_path_sans_ext(local_files,compression = zip))]
} else {
files <- raw_files
}
Expand Down
51 changes: 34 additions & 17 deletions R/client-info.R
Expand Up @@ -6,7 +6,7 @@
#' @param instrument instrument name
#' @param directory directory name
#' @param file file name
#' @param time_out maximum request time in seconds. This may need to be increased for larger directories.
#' @param exclude A character vector of regular expression patterns for which the information matching files will not be retrieved.
#' @importFrom rjson fromJSON
#' @export

Expand Down Expand Up @@ -63,32 +63,49 @@ setMethod('sampleInfo',signature = 'GroverClient',
#' @export

setMethod('runInfo',signature = 'GroverClient',
function(grover_client, instrument, directory,time_out = 100) {
function(grover_client, instrument, directory,exclude = character()) {
files <- listRawFiles(grover_client, instrument, directory)

files <- files[exclude %>%
map(
~!grepl(.x,files)) %>%
setNames(seq_along(.)) %>%
as_tibble() %>%
split(1:nrow(.)) %>%
map_lgl(all)] %>%
na.omit()

message('\nGenrating run info table for ',
bold(blue(directory)),
' containing ',
bold(yellow(length(files))),
' .raw files\n')

cmd <- str_c(hostURL(grover_client),
"/runInfo?",
"auth=",auth(grover_client),
"&instrument=",instrument,
"&directory=",directory)
pb <- progress_bar$new(
format = "[:bar] :percent eta: :eta",
total = length(files), clear = FALSE)
pb$tick(0)

run_info <- GET(cmd,timeout(time_out))
run_info <- files %>%
purrr::map_dfr(~{
suppressMessages({
sample_info <- sampleInfo(
grover_client = grover_client,
instrument = instrument,
directory = directory,
file = .x)
})

pb$tick()

return(sample_info)
})

if (run_info$status_code == 200) {
run_info <- run_info %>%
content() %>%
unlist() %>%
fromJSON() %>%
as_tibble()
} else {
stop(str_c('Failed to retrieve with status code ',
run_info$status_code),call. = FALSE)
failed <- files[!(files %in% run_info$`RAW file`)]

if (length(failed) > 0) {
warning(str_c('Unable to retrieve information for files: ',
str_c(failed,collapse = ', ')),call. = FALSE)
}

return(run_info)
Expand Down

0 comments on commit 55f66fe

Please sign in to comment.