Skip to content

Commit 55f66fe

Browse files
author
Jasen Finch
authored
Merge pull request #24 from jasenfinch/devel
v1.1.0
2 parents 7db4776 + 3f26a53 commit 55f66fe

File tree

14 files changed

+136
-114
lines changed

14 files changed

+136
-114
lines changed

.github/workflows/pkgdown.yaml

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
22
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
33
on:
44
push:
55
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
68
release:
79
types: [published]
810
workflow_dispatch:
@@ -12,36 +14,42 @@ name: pkgdown
1214
jobs:
1315
pkgdown:
1416
runs-on: ubuntu-latest
17+
# Only restrict concurrency for non-PR jobs
18+
concurrency:
19+
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
1520
env:
1621
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
1722
steps:
18-
- uses: actions/checkout@v2
23+
- uses: actions/checkout@v3
1924

20-
- uses: r-lib/actions/setup-pandoc@v1
25+
- uses: r-lib/actions/setup-pandoc@v2
2126

22-
- uses: r-lib/actions/setup-r@v1
27+
- uses: r-lib/actions/setup-r@v2
2328
with:
2429
use-public-rspm: true
25-
26-
- uses: r-lib/actions/setup-r-dependencies@v1
27-
with:
28-
extra-packages: pkgdown
29-
needs: website
3030

3131
- name: Install system dependencies
3232
if: runner.os == 'Linux'
3333
run: |
3434
sudo apt install mono-xbuild
3535
36-
- name: Setup R dependencies
36+
- uses: r-lib/actions/setup-r-dependencies@v2
37+
with:
38+
extra-packages: any::pkgdown, local::.
39+
needs: website
40+
41+
- name: Build site
3742
run: |
3843
rawrr::installRawFileReaderDLLs()
3944
rawrr::buildRawrrExe()
4045
msconverteR::get_pwiz_container()
46+
pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
4147
shell: Rscript {0}
4248

43-
- name: Deploy package
44-
run: |
45-
git config --local user.name "$GITHUB_ACTOR"
46-
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
47-
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)'
49+
- name: Deploy to GitHub pages 🚀
50+
if: github.event_name != 'pull_request'
51+
uses: JamesIves/github-pages-deploy-action@v4.4.1
52+
with:
53+
clean: false
54+
branch: gh-pages
55+
folder: docs

.github/workflows/test-coverage.yaml

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
22
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
33
on:
44
push:
@@ -15,28 +15,44 @@ jobs:
1515
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
1616

1717
steps:
18-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v3
1919

20-
- uses: r-lib/actions/setup-r@v1
20+
- uses: r-lib/actions/setup-r@v2
2121
with:
2222
use-public-rspm: true
23-
24-
- uses: r-lib/actions/setup-r-dependencies@v1
25-
with:
26-
extra-packages: covr
2723

2824
- name: Install system dependencies
2925
if: runner.os == 'Linux'
3026
run: |
3127
sudo apt install mono-xbuild
32-
33-
- name: Setup R dependencies
28+
29+
- uses: r-lib/actions/setup-r-dependencies@v2
30+
with:
31+
extra-packages: any::covr
32+
needs: coverage
33+
34+
- name: Test coverage
3435
run: |
3536
rawrr::installRawFileReaderDLLs()
3637
rawrr::buildRawrrExe()
3738
msconverteR::get_pwiz_container()
39+
covr::codecov(
40+
quiet = FALSE,
41+
clean = FALSE,
42+
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
43+
)
3844
shell: Rscript {0}
3945

40-
- name: Test coverage
41-
run: covr::codecov()
42-
shell: Rscript {0}
46+
- name: Show testthat output
47+
if: always()
48+
run: |
49+
## --------------------------------------------------------------------
50+
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
51+
shell: bash
52+
53+
- name: Upload test results
54+
if: failure()
55+
uses: actions/upload-artifact@v3
56+
with:
57+
name: coverage-test-failures
58+
path: ${{ runner.temp }}/package

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ grover.txt
66
doc
77
Meta
88
docs
9+
/doc/
10+
/Meta/

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: grover
22
Title: Web API Framework for Mass Spectrometry Data Transfer
3-
Version: 1.0.9
3+
Version: 1.1.0
44
Authors@R:
55
person(given = "Jasen",
66
family = "Finch",
@@ -43,4 +43,4 @@ Suggests:
4343
Remotes: wilsontom/msconverteR,
4444
bioc::rawrr
4545
VignetteBuilder: knitr
46-
RoxygenNote: 7.2.2
46+
RoxygenNote: 7.2.3

NAMESPACE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,15 @@ importFrom(plumber,serializer_content_type)
8282
importFrom(progress,progress_bar)
8383
importFrom(purrr,map)
8484
importFrom(purrr,map_chr)
85+
importFrom(purrr,map_lgl)
8586
importFrom(purrr,walk)
8687
importFrom(rawrr,readFileHeader)
8788
importFrom(rawrr,readIndex)
8889
importFrom(readr,read_file)
8990
importFrom(rjson,fromJSON)
9091
importFrom(rjson,toJSON)
92+
importFrom(stats,na.omit)
93+
importFrom(stats,setNames)
9194
importFrom(stringr,regex)
9295
importFrom(stringr,str_c)
9396
importFrom(stringr,str_detect)

NEWS.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# grover 1.1.0
2+
3+
* 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.
4+
5+
* [`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.
6+
7+
* 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.
8+
9+
* Improved the naming of the [`grover::groverAPI`](https://jasenfinch.github.io/grover/reference/groverAPI.html) log files to include the current system date.
10+
111
# grover 1.0.9
212

313
* 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.

R/allGenerics.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ setGeneric('convertDirectory',function(grover_client,
101101
args = '',
102102
outDir = '.',
103103
zip = TRUE,
104-
overwrite = FALSE){
104+
overwrite = FALSE,
105+
exclude = character()){
105106
standardGeneric('convertDirectory')
106107
})
107108

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

144145
#' @rdname info
145146

146-
setGeneric('runInfo',function(grover_client,instrument,directory,time_out = 100){
147+
setGeneric('runInfo',function(grover_client,instrument,directory,exclude = character()){
147148
standardGeneric('runInfo')
148149
})
149150

R/api.R

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ groverAPI <- function(grover_host,
2828
temp_dir <- path.expand(temp_dir)
2929

3030
if (!dir.exists(log_dir)){
31-
dir.create(log_dir)
31+
dir.create(log_dir,recursive = TRUE)
3232
}
3333

3434
if (!dir.exists(temp_dir)){
35-
dir.create(temp_dir)
35+
dir.create(temp_dir,recursive = TRUE)
3636
}
3737

3838
if (isFALSE(background)) {
@@ -70,7 +70,6 @@ groverAPI <- function(grover_host,
7070
env$hostListDirectories <- hostListDirectories
7171
env$hostListInstruments <- hostListInstruments
7272
env$hostSampleInfo <- hostSampleInfo
73-
env$hostRunInfo <- hostRunInfo
7473
env$hostTidy <- hostTidy
7574
env$hostFileInfo <- hostFileInfo
7675
env$hostDirectoryFileInfo <- hostDirectoryFileInfo
@@ -132,7 +131,10 @@ API <- function(host,
132131

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

135-
logger::log_appender(logger::appender_tee(tempfile("plumber_", log_dir, ".log")))
134+
logger::log_appender(logger::appender_tee(paste0(log_dir,
135+
'/grover_',
136+
Sys.Date(),
137+
'.log')))
136138

137139
api <- plumber::pr()
138140

@@ -155,7 +157,6 @@ API <- function(host,
155157
api <- plumber::pr_get(api,'/listDirectories',hostListDirectories)
156158
api <- plumber::pr_get(api,'/listInstruments',hostListInstruments)
157159
api <- plumber::pr_get(api,'/sampleInfo',hostSampleInfo)
158-
api <- plumber::pr_get(api,'/runInfo',hostRunInfo)
159160
api <- plumber::pr_put(api,'/tidy',hostTidy)
160161

161162
api <- plumber::pr_get(api,'/fileInfo',hostFileInfo)

R/client-conversion.R

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#' @param outDir output directory path for converted files
1010
#' @param zip zip converted file
1111
#' @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
12+
#' @param exclude A character vector of regular expression patterns for which raw files with matching patterns will not be converted.
1213
#' @return A vector of file paths to converted data files.
1314
#' @importFrom tools file_path_sans_ext
1415
#' @importFrom stringr str_split
@@ -18,6 +19,8 @@
1819
#' @importFrom progress progress_bar
1920
#' @importFrom crayon yellow bold
2021
#' @importFrom R.utils gzip
22+
#' @importFrom purrr map_lgl
23+
#' @importFrom stats setNames na.omit
2124
#' @export
2225

2326
setMethod('convertFile',signature = 'GroverClient',
@@ -126,7 +129,8 @@ setMethod('convertDirectory',signature = 'GroverClient',
126129
args = '',
127130
outDir = '.',
128131
zip = TRUE,
129-
overwrite = FALSE){
132+
overwrite = FALSE,
133+
exclude = character()){
130134

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

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

142146
raw_files <- listRawFiles(grover_client,instrument,directory)
143147

148+
raw_files <- raw_files[exclude %>%
149+
map(
150+
~!grepl(.x,raw_files)) %>%
151+
setNames(seq_along(.)) %>%
152+
as_tibble() %>%
153+
split(1:nrow(.)) %>%
154+
map_lgl(all)] %>%
155+
na.omit()
156+
144157
if (isFALSE(overwrite)){
145158
files <- raw_files[!(file_path_sans_ext(raw_files) %in%
146-
file_path_sans_ext(local_files,compression = zip))]
159+
file_path_sans_ext(local_files,compression = zip))]
147160
} else {
148161
files <- raw_files
149162
}

R/client-info.R

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#' @param instrument instrument name
77
#' @param directory directory name
88
#' @param file file name
9-
#' @param time_out maximum request time in seconds. This may need to be increased for larger directories.
9+
#' @param exclude A character vector of regular expression patterns for which the information matching files will not be retrieved.
1010
#' @importFrom rjson fromJSON
1111
#' @export
1212

@@ -63,32 +63,49 @@ setMethod('sampleInfo',signature = 'GroverClient',
6363
#' @export
6464

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

69+
files <- files[exclude %>%
70+
map(
71+
~!grepl(.x,files)) %>%
72+
setNames(seq_along(.)) %>%
73+
as_tibble() %>%
74+
split(1:nrow(.)) %>%
75+
map_lgl(all)] %>%
76+
na.omit()
77+
6978
message('\nGenrating run info table for ',
7079
bold(blue(directory)),
7180
' containing ',
7281
bold(yellow(length(files))),
7382
' .raw files\n')
7483

75-
cmd <- str_c(hostURL(grover_client),
76-
"/runInfo?",
77-
"auth=",auth(grover_client),
78-
"&instrument=",instrument,
79-
"&directory=",directory)
84+
pb <- progress_bar$new(
85+
format = "[:bar] :percent eta: :eta",
86+
total = length(files), clear = FALSE)
87+
pb$tick(0)
8088

81-
run_info <- GET(cmd,timeout(time_out))
89+
run_info <- files %>%
90+
purrr::map_dfr(~{
91+
suppressMessages({
92+
sample_info <- sampleInfo(
93+
grover_client = grover_client,
94+
instrument = instrument,
95+
directory = directory,
96+
file = .x)
97+
})
98+
99+
pb$tick()
100+
101+
return(sample_info)
102+
})
82103

83-
if (run_info$status_code == 200) {
84-
run_info <- run_info %>%
85-
content() %>%
86-
unlist() %>%
87-
fromJSON() %>%
88-
as_tibble()
89-
} else {
90-
stop(str_c('Failed to retrieve with status code ',
91-
run_info$status_code),call. = FALSE)
104+
failed <- files[!(files %in% run_info$`RAW file`)]
105+
106+
if (length(failed) > 0) {
107+
warning(str_c('Unable to retrieve information for files: ',
108+
str_c(failed,collapse = ', ')),call. = FALSE)
92109
}
93110

94111
return(run_info)

0 commit comments

Comments
 (0)