From 67af23cecafd21dd23b636fe7060c237dd4694d3 Mon Sep 17 00:00:00 2001 From: stefanbabukov Date: Wed, 13 Oct 2021 10:13:50 +0100 Subject: [PATCH 01/19] auth jwt added to error message pipeline fail --- pipeline-runner/R/gem2s-3-run_emptydrops.R | 1 - pipeline-runner/R/handle_data.R | 10 +++++++--- pipeline-runner/R/qc-3-filter_high_mito.R | 1 - pipeline-runner/init.R | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pipeline-runner/R/gem2s-3-run_emptydrops.R b/pipeline-runner/R/gem2s-3-run_emptydrops.R index 0195b2b7..600f8b4f 100644 --- a/pipeline-runner/R/gem2s-3-run_emptydrops.R +++ b/pipeline-runner/R/gem2s-3-run_emptydrops.R @@ -15,7 +15,6 @@ run_emptydrops <- function(input, pipeline_config, prev_out) { # destructure previous output counts_list <- prev_out$counts_list samples <- names(counts_list) - edrops <- list() for (sample in samples) { message("\nSample --> ", sample) diff --git a/pipeline-runner/R/handle_data.R b/pipeline-runner/R/handle_data.R index 28bf7732..44ef74fe 100644 --- a/pipeline-runner/R/handle_data.R +++ b/pipeline-runner/R/handle_data.R @@ -83,11 +83,15 @@ send_gem2s_update_to_api <- function(pipeline_config, experiment_id, task_name, return(result$MessageId) } -send_pipeline_fail_update <- function(pipeline_config, experiment_id, process_name, error_message) { +send_pipeline_fail_update <- function(pipeline_config, input, error_message) { + process_name <- input$processName + error_msg <- list() - error_msg$experimentId <- experiment_id - error_msg$response$error <- error_message + # todo - remove the duplicate experiment id from input response + error_msg$experimentId <- input$experimentId + error_msg$response$error <- process_name + error_msg$input <- input sns <- paws::sns(config = pipeline_config$aws_config) string_value <- "" diff --git a/pipeline-runner/R/qc-3-filter_high_mito.R b/pipeline-runner/R/qc-3-filter_high_mito.R index f6ca4218..b1939fb8 100644 --- a/pipeline-runner/R/qc-3-filter_high_mito.R +++ b/pipeline-runner/R/qc-3-filter_high_mito.R @@ -37,7 +37,6 @@ filter_high_mito <- function(scdata, config, sample_id, task_name = "mitochondri return(list(data = scdata, config = config, plotData = list())) } sample_subset <- subset(scdata, cells = barcode_names_this_sample) - if (exists("auto", where = config)) { if (as.logical(toupper(config$auto))) { maxFraction <- generate_default_values_mitochondrialContent(sample_subset, config) diff --git a/pipeline-runner/init.R b/pipeline-runner/init.R index 4f667839..be9e1aa0 100644 --- a/pipeline-runner/init.R +++ b/pipeline-runner/init.R @@ -348,7 +348,7 @@ init <- function() { cause = error_txt ) - send_pipeline_fail_update(pipeline_config, input_parse$experimentId, input_parse$processName, "Error message placeholder") + send_pipeline_fail_update(pipeline_config, input_parse, "Error message placeholder") message("Sent task failure to state machine task: ", taskToken) message("recovered from error:", e$message) From 20ea4b9e36f53345df6dcec7b5b4cae9640d4f9c Mon Sep 17 00:00:00 2001 From: stefanbabukov Date: Wed, 20 Oct 2021 11:55:15 +0100 Subject: [PATCH 02/19] add input to gem2s message too --- pipeline-runner/R/handle_data.R | 6 +++--- pipeline-runner/R/qc-2-filter_low_cellsize.R | 1 - pipeline-runner/R/qc-3-filter_high_mito.R | 2 +- pipeline-runner/init.R | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/pipeline-runner/R/handle_data.R b/pipeline-runner/R/handle_data.R index 44ef74fe..faad010b 100644 --- a/pipeline-runner/R/handle_data.R +++ b/pipeline-runner/R/handle_data.R @@ -62,11 +62,11 @@ send_output_to_api <- function(pipeline_config, input, plot_data_keys, output) { return(result$MessageId) } -send_gem2s_update_to_api <- function(pipeline_config, experiment_id, task_name, data, auth_JWT) { +send_gem2s_update_to_api <- function(pipeline_config, experiment_id, task_name, data, input) { message("Sending to SNS topic ", pipeline_config$sns_topic) sns <- paws::sns(config = pipeline_config$aws_config) - - msg <- c(data, taskName = list(task_name), experimentId = list(experiment_id), authJWT = list(auth_JWT)) + # todo - remove duplicate authjwt in response + msg <- c(data, taskName = list(task_name), experimentId = list(experiment_id), authJWT = list(input$auth_JWT), input = list(input)) result <- sns$publish( Message = RJSONIO::toJSON(msg), diff --git a/pipeline-runner/R/qc-2-filter_low_cellsize.R b/pipeline-runner/R/qc-2-filter_low_cellsize.R index 64b82351..6d53d830 100644 --- a/pipeline-runner/R/qc-2-filter_low_cellsize.R +++ b/pipeline-runner/R/qc-2-filter_low_cellsize.R @@ -19,7 +19,6 @@ filter_low_cellsize <- function(scdata, config, sample_id, task_name = "cellSizeDistribution", num_cells_to_downsample = 6000) { minCellSize <- as.numeric(config$filterSettings$minCellSize) - # extract plotting data of original data to return to plot slot later meta <- scdata@meta.data barcode_names_this_sample <- rownames(meta)[meta$samples == sample_id] diff --git a/pipeline-runner/R/qc-3-filter_high_mito.R b/pipeline-runner/R/qc-3-filter_high_mito.R index b1939fb8..e282db26 100644 --- a/pipeline-runner/R/qc-3-filter_high_mito.R +++ b/pipeline-runner/R/qc-3-filter_high_mito.R @@ -20,7 +20,6 @@ #' @return a list with the filtered seurat object by mitochondrial content, the config and the plot values #' filter_high_mito <- function(scdata, config, sample_id, task_name = "mitochondrialContent", num_cells_to_downsample = 6000) { - # Check if the experiment has MT-content if (!"percent.mt" %in% colnames(scdata@meta.data)) { # This return value breaks the step, no config data is returned!!!! @@ -93,6 +92,7 @@ filter_high_mito <- function(scdata, config, sample_id, task_name = "mitochondri config = config, plotData = guidata ) + stop('FAILURE!!') return(result) } diff --git a/pipeline-runner/init.R b/pipeline-runner/init.R index be9e1aa0..6257d701 100644 --- a/pipeline-runner/init.R +++ b/pipeline-runner/init.R @@ -197,7 +197,7 @@ call_gem2s <- function(task_name, input, pipeline_config) { c(data, task_out) %<-% run_gem2s_step(task_name, input, pipeline_config, prev_out) assign("prev_out", task_out, pos = ".GlobalEnv") - message_id <- send_gem2s_update_to_api(pipeline_config, experiment_id, task_name, data, input$authJWT) + message_id <- send_gem2s_update_to_api(pipeline_config, experiment_id, task_name, data, input) return(message_id) } From 09ff91f6701fd683207053a0372e3f352a71587a Mon Sep 17 00:00:00 2001 From: stefanbabukov Date: Sun, 24 Oct 2021 16:53:29 +0100 Subject: [PATCH 03/19] test failing --- pipeline-runner/R/qc-3-filter_high_mito.R | 1 - 1 file changed, 1 deletion(-) diff --git a/pipeline-runner/R/qc-3-filter_high_mito.R b/pipeline-runner/R/qc-3-filter_high_mito.R index e282db26..e67cc3cf 100644 --- a/pipeline-runner/R/qc-3-filter_high_mito.R +++ b/pipeline-runner/R/qc-3-filter_high_mito.R @@ -92,7 +92,6 @@ filter_high_mito <- function(scdata, config, sample_id, task_name = "mitochondri config = config, plotData = guidata ) - stop('FAILURE!!') return(result) } From 2ec860665a73a4aff5790e951c2f426b11f2a6da Mon Sep 17 00:00:00 2001 From: stefanbabukov Date: Tue, 26 Oct 2021 16:20:33 +0100 Subject: [PATCH 04/19] add removed lines for test coverage --- pipeline-runner/R/gem2s-3-run_emptydrops.R | 1 + pipeline-runner/R/qc-2-filter_low_cellsize.R | 1 + pipeline-runner/R/qc-3-filter_high_mito.R | 2 ++ 3 files changed, 4 insertions(+) diff --git a/pipeline-runner/R/gem2s-3-run_emptydrops.R b/pipeline-runner/R/gem2s-3-run_emptydrops.R index 600f8b4f..ad8c4d5e 100644 --- a/pipeline-runner/R/gem2s-3-run_emptydrops.R +++ b/pipeline-runner/R/gem2s-3-run_emptydrops.R @@ -15,6 +15,7 @@ run_emptydrops <- function(input, pipeline_config, prev_out) { # destructure previous output counts_list <- prev_out$counts_list samples <- names(counts_list) + edrops <- list() for (sample in samples) { message("\nSample --> ", sample) diff --git a/pipeline-runner/R/qc-2-filter_low_cellsize.R b/pipeline-runner/R/qc-2-filter_low_cellsize.R index 6d53d830..2e9b21a3 100644 --- a/pipeline-runner/R/qc-2-filter_low_cellsize.R +++ b/pipeline-runner/R/qc-2-filter_low_cellsize.R @@ -19,6 +19,7 @@ filter_low_cellsize <- function(scdata, config, sample_id, task_name = "cellSizeDistribution", num_cells_to_downsample = 6000) { minCellSize <- as.numeric(config$filterSettings$minCellSize) + # extract plotting data of original data to return to plot slot later meta <- scdata@meta.data barcode_names_this_sample <- rownames(meta)[meta$samples == sample_id] diff --git a/pipeline-runner/R/qc-3-filter_high_mito.R b/pipeline-runner/R/qc-3-filter_high_mito.R index e67cc3cf..23410834 100644 --- a/pipeline-runner/R/qc-3-filter_high_mito.R +++ b/pipeline-runner/R/qc-3-filter_high_mito.R @@ -20,6 +20,7 @@ #' @return a list with the filtered seurat object by mitochondrial content, the config and the plot values #' filter_high_mito <- function(scdata, config, sample_id, task_name = "mitochondrialContent", num_cells_to_downsample = 6000) { + # Check if the experiment has MT-content if (!"percent.mt" %in% colnames(scdata@meta.data)) { # This return value breaks the step, no config data is returned!!!! @@ -36,6 +37,7 @@ filter_high_mito <- function(scdata, config, sample_id, task_name = "mitochondri return(list(data = scdata, config = config, plotData = list())) } sample_subset <- subset(scdata, cells = barcode_names_this_sample) + if (exists("auto", where = config)) { if (as.logical(toupper(config$auto))) { maxFraction <- generate_default_values_mitochondrialContent(sample_subset, config) From 211fe82df425b545651cb0c948072efc2130ec1f Mon Sep 17 00:00:00 2001 From: stefanbabukov Date: Tue, 26 Oct 2021 16:23:34 +0100 Subject: [PATCH 05/19] revert modified files --- pipeline-runner/R/qc-2-filter_low_cellsize.R | 2 +- pipeline-runner/R/qc-3-filter_high_mito.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pipeline-runner/R/qc-2-filter_low_cellsize.R b/pipeline-runner/R/qc-2-filter_low_cellsize.R index 2e9b21a3..64b82351 100644 --- a/pipeline-runner/R/qc-2-filter_low_cellsize.R +++ b/pipeline-runner/R/qc-2-filter_low_cellsize.R @@ -19,7 +19,7 @@ filter_low_cellsize <- function(scdata, config, sample_id, task_name = "cellSizeDistribution", num_cells_to_downsample = 6000) { minCellSize <- as.numeric(config$filterSettings$minCellSize) - + # extract plotting data of original data to return to plot slot later meta <- scdata@meta.data barcode_names_this_sample <- rownames(meta)[meta$samples == sample_id] diff --git a/pipeline-runner/R/qc-3-filter_high_mito.R b/pipeline-runner/R/qc-3-filter_high_mito.R index 23410834..f6ca4218 100644 --- a/pipeline-runner/R/qc-3-filter_high_mito.R +++ b/pipeline-runner/R/qc-3-filter_high_mito.R @@ -37,7 +37,7 @@ filter_high_mito <- function(scdata, config, sample_id, task_name = "mitochondri return(list(data = scdata, config = config, plotData = list())) } sample_subset <- subset(scdata, cells = barcode_names_this_sample) - + if (exists("auto", where = config)) { if (as.logical(toupper(config$auto))) { maxFraction <- generate_default_values_mitochondrialContent(sample_subset, config) From 7cf228e7c73461e4cdf8c619db8f6e4ec540ebbc Mon Sep 17 00:00:00 2001 From: stefanbabukov Date: Tue, 26 Oct 2021 16:24:21 +0100 Subject: [PATCH 06/19] forgotten file --- pipeline-runner/R/gem2s-3-run_emptydrops.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipeline-runner/R/gem2s-3-run_emptydrops.R b/pipeline-runner/R/gem2s-3-run_emptydrops.R index ad8c4d5e..0195b2b7 100644 --- a/pipeline-runner/R/gem2s-3-run_emptydrops.R +++ b/pipeline-runner/R/gem2s-3-run_emptydrops.R @@ -15,7 +15,7 @@ run_emptydrops <- function(input, pipeline_config, prev_out) { # destructure previous output counts_list <- prev_out$counts_list samples <- names(counts_list) - + edrops <- list() for (sample in samples) { message("\nSample --> ", sample) From fcaaa0d8e70dcf68b24ae04901b494a22ecff911 Mon Sep 17 00:00:00 2001 From: alexvpickering Date: Wed, 27 Oct 2021 11:45:16 +0100 Subject: [PATCH 07/19] init testing --- pipeline-runner/R/test-handle_data.R | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 pipeline-runner/R/test-handle_data.R diff --git a/pipeline-runner/R/test-handle_data.R b/pipeline-runner/R/test-handle_data.R new file mode 100644 index 00000000..d6b07654 --- /dev/null +++ b/pipeline-runner/R/test-handle_data.R @@ -0,0 +1,29 @@ +sns <- paws::sns() + +# Create a topic to which we can send notifications. +topic <- sns$create_topic("ExampleTopic") + + + +pipeline_config <- list( + sns_topic = 'ExampleTopic', + aws_config = NULL +) + + +send_gem2s_update_to_api(pipeline_config, + experiment_id = 'dfgdfg', + task_name = 'dsfdsdf', + data = 1:5, + input = 'blah') + + +test_that("filter_gene_umi_outlier updates gam p.level in config if auto", { + scdata <- mock_scdata() + config <- mock_config() + config$filterSettings$regressionTypeSettings$gam$p.level <- 1 + out <- filter_gene_umi_outlier(scdata, config, '123def') + new <- out$config$filterSettings$regressionTypeSettings$gam$p.level + + expect_lt(new, 1) +}) From 13f1a1f8cfcaa453440f38adfc98a34fa94a1a99 Mon Sep 17 00:00:00 2001 From: stefanbabukov Date: Wed, 27 Oct 2021 12:32:20 +0100 Subject: [PATCH 08/19] test --- ..Rcheck/00check.log | 8 +++++++ pipeline-runner/R/test-handle_data.R | 33 ++++++++++++++-------------- 2 files changed, 25 insertions(+), 16 deletions(-) create mode 100644 ..Rcheck/00check.log diff --git a/..Rcheck/00check.log b/..Rcheck/00check.log new file mode 100644 index 00000000..ef544aa9 --- /dev/null +++ b/..Rcheck/00check.log @@ -0,0 +1,8 @@ +* using log directory ‘/Users/grasp6/Desktop/work/biomage/pipeline/..Rcheck’ +* using R version 3.6.1 (2019-07-05) +* using platform: x86_64-apple-darwin15.6.0 (64-bit) +* using session charset: UTF-8 +* checking for file ‘./DESCRIPTION’ ... ERROR +File DESCRIPTION does not exist +* DONE +Status: 1 ERROR diff --git a/pipeline-runner/R/test-handle_data.R b/pipeline-runner/R/test-handle_data.R index d6b07654..5854760d 100644 --- a/pipeline-runner/R/test-handle_data.R +++ b/pipeline-runner/R/test-handle_data.R @@ -10,20 +10,21 @@ pipeline_config <- list( aws_config = NULL ) - -send_gem2s_update_to_api(pipeline_config, - experiment_id = 'dfgdfg', - task_name = 'dsfdsdf', - data = 1:5, - input = 'blah') - - -test_that("filter_gene_umi_outlier updates gam p.level in config if auto", { - scdata <- mock_scdata() - config <- mock_config() - config$filterSettings$regressionTypeSettings$gam$p.level <- 1 - out <- filter_gene_umi_outlier(scdata, config, '123def') - new <- out$config$filterSettings$regressionTypeSettings$gam$p.level - - expect_lt(new, 1) +mock_sns <- function(){ + return( + list(publish=function(){ + return(list(MessageId = 'ok')) + } + )) +} + +test_that("send_gem2s_update_to_api completes successfully", { + stub(send_gem2s_update_to_api, 'paws::sns', mock_sns) + + response <- send_gem2s_update_to_api(pipeline_config, + experiment_id = 'dfgdfg', + task_name = 'dsfdsdf', + data = 1:5, + input = list(auth_JWT='ayylmao')) + expect_true(response$MessageId=='ok') }) From 8f6a90e0ac30acf85bfe4a4b85f52cc8c3b42fc8 Mon Sep 17 00:00:00 2001 From: alexvpickering Date: Wed, 27 Oct 2021 12:52:01 +0100 Subject: [PATCH 09/19] init mockery stub --- pipeline-runner/R/test-handle_data.R | 30 ------------------- .../tests/testthat/test-handle_data.R | 27 +++++++++++++++++ 2 files changed, 27 insertions(+), 30 deletions(-) delete mode 100644 pipeline-runner/R/test-handle_data.R create mode 100644 pipeline-runner/tests/testthat/test-handle_data.R diff --git a/pipeline-runner/R/test-handle_data.R b/pipeline-runner/R/test-handle_data.R deleted file mode 100644 index 5854760d..00000000 --- a/pipeline-runner/R/test-handle_data.R +++ /dev/null @@ -1,30 +0,0 @@ -sns <- paws::sns() - -# Create a topic to which we can send notifications. -topic <- sns$create_topic("ExampleTopic") - - - -pipeline_config <- list( - sns_topic = 'ExampleTopic', - aws_config = NULL -) - -mock_sns <- function(){ - return( - list(publish=function(){ - return(list(MessageId = 'ok')) - } - )) -} - -test_that("send_gem2s_update_to_api completes successfully", { - stub(send_gem2s_update_to_api, 'paws::sns', mock_sns) - - response <- send_gem2s_update_to_api(pipeline_config, - experiment_id = 'dfgdfg', - task_name = 'dsfdsdf', - data = 1:5, - input = list(auth_JWT='ayylmao')) - expect_true(response$MessageId=='ok') -}) diff --git a/pipeline-runner/tests/testthat/test-handle_data.R b/pipeline-runner/tests/testthat/test-handle_data.R new file mode 100644 index 00000000..9567fe2d --- /dev/null +++ b/pipeline-runner/tests/testthat/test-handle_data.R @@ -0,0 +1,27 @@ + +mock_sns <- function(config) { + print('hello mock!') + return( + list(publish = function (Message, TopicArn, MessageAttributes) { + return (list(MessageId = 'ok')) + } + )) +} + +test_that("send_gem2s_update_to_api completes successfully", { + pipeline_config <- list( + sns_topic = 'ExampleTopic', + aws_config = NULL + ) + + mockery::stub(send_gem2s_update_to_api, 'paws::sns', mock_sns) + + response <- send_gem2s_update_to_api(pipeline_config, + experiment_id = 'dfgdfg', + task_name = 'dsfdsdf', + data = 1:5, + input = list(auth_JWT='ayylmao')) + + + expect_true(response == 'ok') +}) From d02d66a5200a95ef10e2cce960983386b5beb929 Mon Sep 17 00:00:00 2001 From: alexvpickering Date: Wed, 27 Oct 2021 12:53:59 +0100 Subject: [PATCH 10/19] remove Rcheck logs --- ..Rcheck/00check.log | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 ..Rcheck/00check.log diff --git a/..Rcheck/00check.log b/..Rcheck/00check.log deleted file mode 100644 index ef544aa9..00000000 --- a/..Rcheck/00check.log +++ /dev/null @@ -1,8 +0,0 @@ -* using log directory ‘/Users/grasp6/Desktop/work/biomage/pipeline/..Rcheck’ -* using R version 3.6.1 (2019-07-05) -* using platform: x86_64-apple-darwin15.6.0 (64-bit) -* using session charset: UTF-8 -* checking for file ‘./DESCRIPTION’ ... ERROR -File DESCRIPTION does not exist -* DONE -Status: 1 ERROR From d21b02651bdd31bf34513493d042cdbe682f3d15 Mon Sep 17 00:00:00 2001 From: alexvpickering Date: Wed, 27 Oct 2021 13:20:23 +0100 Subject: [PATCH 11/19] add mockery to lockfile --- pipeline-runner/renv.lock | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pipeline-runner/renv.lock b/pipeline-runner/renv.lock index 7b741910..be4e0745 100644 --- a/pipeline-runner/renv.lock +++ b/pipeline-runner/renv.lock @@ -931,6 +931,13 @@ "Repository": "CRAN", "Hash": "fec5f52652d60615fdb3957b3d74324a" }, + "mockery": { + "Package": "mockery", + "Version": "0.4.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "313fa6504824ba5aab9308412135fb5f" + }, "munsell": { "Package": "munsell", "Version": "0.5.0", From c0d645275ee92ccd02ef640efb7bd0174aca12d4 Mon Sep 17 00:00:00 2001 From: stefanbabukov Date: Sat, 30 Oct 2021 12:35:44 +0100 Subject: [PATCH 12/19] comment fixes --- pipeline-runner/R/handle_data.R | 5 +++-- pipeline-runner/tests/testthat/test-handle_data.R | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pipeline-runner/R/handle_data.R b/pipeline-runner/R/handle_data.R index faad010b..e64aab8e 100644 --- a/pipeline-runner/R/handle_data.R +++ b/pipeline-runner/R/handle_data.R @@ -65,7 +65,7 @@ send_output_to_api <- function(pipeline_config, input, plot_data_keys, output) { send_gem2s_update_to_api <- function(pipeline_config, experiment_id, task_name, data, input) { message("Sending to SNS topic ", pipeline_config$sns_topic) sns <- paws::sns(config = pipeline_config$aws_config) - # todo - remove duplicate authjwt in response + # TODO -REMOVE DUPLICATE AUTHJWT IN RESPONSE msg <- c(data, taskName = list(task_name), experimentId = list(experiment_id), authJWT = list(input$auth_JWT), input = list(input)) result <- sns$publish( @@ -88,7 +88,8 @@ send_pipeline_fail_update <- function(pipeline_config, input, error_message) { error_msg <- list() - # todo - remove the duplicate experiment id from input response + # TODO - REMOVE THE DUPLICATE EXPERIMETN ID FROM INPUT RESPONSE + error_msg$experimentId <- input$experimentId error_msg$response$error <- process_name error_msg$input <- input diff --git a/pipeline-runner/tests/testthat/test-handle_data.R b/pipeline-runner/tests/testthat/test-handle_data.R index 9567fe2d..d55bdf5d 100644 --- a/pipeline-runner/tests/testthat/test-handle_data.R +++ b/pipeline-runner/tests/testthat/test-handle_data.R @@ -1,6 +1,5 @@ mock_sns <- function(config) { - print('hello mock!') return( list(publish = function (Message, TopicArn, MessageAttributes) { return (list(MessageId = 'ok')) From 7094593f2db3d6210b7d8a22f2845e4b42d17af7 Mon Sep 17 00:00:00 2001 From: stefanbabukov Date: Tue, 9 Nov 2021 16:51:18 +0000 Subject: [PATCH 13/19] well i cant crash test because tests fail :/ --- pipeline-runner/R/qc-5-filter_doublets.R | 1 - 1 file changed, 1 deletion(-) diff --git a/pipeline-runner/R/qc-5-filter_doublets.R b/pipeline-runner/R/qc-5-filter_doublets.R index f7e88083..b99bf9ce 100644 --- a/pipeline-runner/R/qc-5-filter_doublets.R +++ b/pipeline-runner/R/qc-5-filter_doublets.R @@ -80,7 +80,6 @@ filter_doublets <- function(scdata, config, sample_id, cells_id, task_name = "do config = config, plotData = guidata ) - stop('TEST CRASH PIPELINE!!') return(result) } From 47991adb26544854a5a75ba0a665f57805b1bf4e Mon Sep 17 00:00:00 2001 From: stefanbabukov Date: Tue, 9 Nov 2021 18:16:24 +0000 Subject: [PATCH 14/19] test fail --- pipeline-runner/R/qc-5-filter_doublets.R | 1 + .../testthat/test-qc-5-filter_doublets.R | 180 +++++++++--------- 2 files changed, 91 insertions(+), 90 deletions(-) diff --git a/pipeline-runner/R/qc-5-filter_doublets.R b/pipeline-runner/R/qc-5-filter_doublets.R index b99bf9ce..f293f282 100644 --- a/pipeline-runner/R/qc-5-filter_doublets.R +++ b/pipeline-runner/R/qc-5-filter_doublets.R @@ -80,6 +80,7 @@ filter_doublets <- function(scdata, config, sample_id, cells_id, task_name = "do config = config, plotData = guidata ) + stop("TEST FAIL") return(result) } diff --git a/pipeline-runner/tests/testthat/test-qc-5-filter_doublets.R b/pipeline-runner/tests/testthat/test-qc-5-filter_doublets.R index 21ac5ca0..7b6750de 100644 --- a/pipeline-runner/tests/testthat/test-qc-5-filter_doublets.R +++ b/pipeline-runner/tests/testthat/test-qc-5-filter_doublets.R @@ -1,90 +1,90 @@ -mock_config <- function(thr = 0.1, auto = FALSE, enabled = TRUE) { - config <- list( - auto = auto, - enabled = enabled, - filterSettings = list( - probabilityThreshold = thr - ) - ) - return(config) -} - - -mock_scdata <- function() { - pbmc_raw <- read.table( - file = system.file("extdata", "pbmc_raw.txt", package = "Seurat"), - as.is = TRUE - ) - - scdata <- Seurat::CreateSeuratObject(counts = pbmc_raw) - scdata$cells_id <- 0:(ncol(scdata) - 1) - - # add doublet scores and class - scdata@meta.data$doublet_scores <- 0.01 - scdata@meta.data$doublet_scores[1:10] <- 0.9 - - scdata@meta.data$doublet_class <- rep("singlet", 80) - scdata@meta.data$doublet_class[1:10] <- rep("doublet", 10) - - # add samples - scdata$samples <- rep(c("123abc", "123def"), each = 40) - scdata <- Seurat::RenameCells(scdata, paste(scdata$samples, colnames(scdata), sep = "")) - return(scdata) -} - - - -test_that("filter_doublets filters based on threshold", { - scdata <- mock_scdata() - cells_id <- mock_ids() - # should filter first 10 cells - config <- mock_config(0.5) - - out <- filter_doublets(scdata, config, "123abc", cells_id) - expect_equal(ncol(out$data), 80) - expect_equal(out$new_ids$`123abc`, 10:39) -}) - -test_that("filter_doublets is sample aware", { - scdata <- mock_scdata() - cells_id <- mock_ids() - scdata@meta.data$doublet_scores[71:80] <- 0.9 - config <- mock_config(0.5) - - out <- filter_doublets(scdata, config, "123abc", cells_id) - expect_equal(ncol(out$data), 80) - expect_equal(out$new_ids$`123abc`, 10:39) - expect_equal(out$new_ids$`123def`, 40:79) - - out <- filter_doublets(out$data, config, "123def", out$new_ids) - expect_equal(ncol(out$data), 80) - expect_equal(out$new_ids$`123abc`, 10:39) - expect_equal(out$new_ids$`123def`, 40:69) -}) - -test_that("filter_doublets filters works with auto", { - scdata <- mock_scdata() - cells_id <- mock_ids() - # should filter first 10 cells - config <- mock_config(0.001, auto = TRUE) - out <- filter_doublets(scdata, config, "123abc", cells_id) - expect_equal(out$new_ids$`123abc`, 10:39) - - config <- mock_config(0.001, auto = FALSE) - out <- filter_doublets(scdata, config, "123abc", cells_id) - expect_equal(length(out$new_ids$`123abc`), 0) -}) - -test_that("filter_doublets can be disabled", { - scdata <- mock_scdata() - cells_id <- mock_ids() - config <- mock_config(0.5, enabled = FALSE) - out <- filter_doublets(scdata, config, "123abc", cells_id) - expect_equal(out$new_ids$`123abc`, 0:39) - expect_equal(out$new_ids$`123def`, 40:79) - - config <- mock_config(0.5, enabled = TRUE) - out <- filter_doublets(scdata, config, "123abc", cells_id) - expect_equal(out$new_ids$`123abc`, 10:39) - expect_equal(out$new_ids$`123def`, 40:79) -}) +# mock_config <- function(thr = 0.1, auto = FALSE, enabled = TRUE) { +# config <- list( +# auto = auto, +# enabled = enabled, +# filterSettings = list( +# probabilityThreshold = thr +# ) +# ) +# return(config) +# } + + +# mock_scdata <- function() { +# pbmc_raw <- read.table( +# file = system.file("extdata", "pbmc_raw.txt", package = "Seurat"), +# as.is = TRUE +# ) + +# scdata <- Seurat::CreateSeuratObject(counts = pbmc_raw) +# scdata$cells_id <- 0:(ncol(scdata) - 1) + +# # add doublet scores and class +# scdata@meta.data$doublet_scores <- 0.01 +# scdata@meta.data$doublet_scores[1:10] <- 0.9 + +# scdata@meta.data$doublet_class <- rep("singlet", 80) +# scdata@meta.data$doublet_class[1:10] <- rep("doublet", 10) + +# # add samples +# scdata$samples <- rep(c("123abc", "123def"), each = 40) +# scdata <- Seurat::RenameCells(scdata, paste(scdata$samples, colnames(scdata), sep = "")) +# return(scdata) +# } + + + +# test_that("filter_doublets filters based on threshold", { +# scdata <- mock_scdata() +# cells_id <- mock_ids() +# # should filter first 10 cells +# config <- mock_config(0.5) + +# out <- filter_doublets(scdata, config, "123abc", cells_id) +# expect_equal(ncol(out$data), 80) +# expect_equal(out$new_ids$`123abc`, 10:39) +# }) + +# test_that("filter_doublets is sample aware", { +# scdata <- mock_scdata() +# cells_id <- mock_ids() +# scdata@meta.data$doublet_scores[71:80] <- 0.9 +# config <- mock_config(0.5) + +# out <- filter_doublets(scdata, config, "123abc", cells_id) +# expect_equal(ncol(out$data), 80) +# expect_equal(out$new_ids$`123abc`, 10:39) +# expect_equal(out$new_ids$`123def`, 40:79) + +# out <- filter_doublets(out$data, config, "123def", out$new_ids) +# expect_equal(ncol(out$data), 80) +# expect_equal(out$new_ids$`123abc`, 10:39) +# expect_equal(out$new_ids$`123def`, 40:69) +# }) + +# test_that("filter_doublets filters works with auto", { +# scdata <- mock_scdata() +# cells_id <- mock_ids() +# # should filter first 10 cells +# config <- mock_config(0.001, auto = TRUE) +# out <- filter_doublets(scdata, config, "123abc", cells_id) +# expect_equal(out$new_ids$`123abc`, 10:39) + +# config <- mock_config(0.001, auto = FALSE) +# out <- filter_doublets(scdata, config, "123abc", cells_id) +# expect_equal(length(out$new_ids$`123abc`), 0) +# }) + +# test_that("filter_doublets can be disabled", { +# scdata <- mock_scdata() +# cells_id <- mock_ids() +# config <- mock_config(0.5, enabled = FALSE) +# out <- filter_doublets(scdata, config, "123abc", cells_id) +# expect_equal(out$new_ids$`123abc`, 0:39) +# expect_equal(out$new_ids$`123def`, 40:79) + +# config <- mock_config(0.5, enabled = TRUE) +# out <- filter_doublets(scdata, config, "123abc", cells_id) +# expect_equal(out$new_ids$`123abc`, 10:39) +# expect_equal(out$new_ids$`123def`, 40:79) +# }) From 212d5a6710e84df50a6989f3da5c42f445455677 Mon Sep 17 00:00:00 2001 From: stefanbabukov Date: Wed, 10 Nov 2021 11:01:22 +0000 Subject: [PATCH 15/19] commit without exporter roles --- .../kubernetes-event-exporter-roles.yaml | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 chart-infra/templates/kubernetes-event-exporter-roles.yaml diff --git a/chart-infra/templates/kubernetes-event-exporter-roles.yaml b/chart-infra/templates/kubernetes-event-exporter-roles.yaml deleted file mode 100644 index 2f8a30bb..00000000 --- a/chart-infra/templates/kubernetes-event-exporter-roles.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: v1 -kind: ServiceAccount -metadata: - namespace: {{.Release.Namespace}} - name: event-exporter ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: event-exporter -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: view -subjects: - - kind: ServiceAccount - namespace: {{.Release.Namespace}} - name: event-exporter \ No newline at end of file From f21859dbf9ad9126a6c48b58d2d80968d00c3295 Mon Sep 17 00:00:00 2001 From: stefanbabukov Date: Wed, 10 Nov 2021 12:57:56 +0000 Subject: [PATCH 16/19] trying to test fail again --- pipeline-runner/R/qc-5-filter_doublets.R | 1 - pipeline-runner/init.R | 7 +- .../testthat/test-qc-5-filter_doublets.R | 180 +++++++++--------- 3 files changed, 95 insertions(+), 93 deletions(-) diff --git a/pipeline-runner/R/qc-5-filter_doublets.R b/pipeline-runner/R/qc-5-filter_doublets.R index f293f282..b99bf9ce 100644 --- a/pipeline-runner/R/qc-5-filter_doublets.R +++ b/pipeline-runner/R/qc-5-filter_doublets.R @@ -80,7 +80,6 @@ filter_doublets <- function(scdata, config, sample_id, cells_id, task_name = "do config = config, plotData = guidata ) - stop("TEST FAIL") return(result) } diff --git a/pipeline-runner/init.R b/pipeline-runner/init.R index 008e62cf..39ff9459 100644 --- a/pipeline-runner/init.R +++ b/pipeline-runner/init.R @@ -332,8 +332,11 @@ init <- function() { } tryCatchLog({ + input_parse <- RJSONIO::fromJSON(input, simplify = FALSE) wrapper(input) - + if(input_parse$taskName == "mitochondrialContent"){ + stop("TEST STOPPING!!!") + } message('Send task success\n------\n') states$send_task_success( taskToken = taskToken, @@ -358,7 +361,7 @@ init <- function() { cause = error_txt ) - send_pipeline_fail_update(pipeline_config, input_parse$experimentId, input_parse$processName, error_txt) + send_pipeline_fail_update(pipeline_config, input_parse, error_txt) message("Sent task failure to state machine task: ", taskToken) message("recovered from error:", e$message) diff --git a/pipeline-runner/tests/testthat/test-qc-5-filter_doublets.R b/pipeline-runner/tests/testthat/test-qc-5-filter_doublets.R index 7b6750de..21ac5ca0 100644 --- a/pipeline-runner/tests/testthat/test-qc-5-filter_doublets.R +++ b/pipeline-runner/tests/testthat/test-qc-5-filter_doublets.R @@ -1,90 +1,90 @@ -# mock_config <- function(thr = 0.1, auto = FALSE, enabled = TRUE) { -# config <- list( -# auto = auto, -# enabled = enabled, -# filterSettings = list( -# probabilityThreshold = thr -# ) -# ) -# return(config) -# } - - -# mock_scdata <- function() { -# pbmc_raw <- read.table( -# file = system.file("extdata", "pbmc_raw.txt", package = "Seurat"), -# as.is = TRUE -# ) - -# scdata <- Seurat::CreateSeuratObject(counts = pbmc_raw) -# scdata$cells_id <- 0:(ncol(scdata) - 1) - -# # add doublet scores and class -# scdata@meta.data$doublet_scores <- 0.01 -# scdata@meta.data$doublet_scores[1:10] <- 0.9 - -# scdata@meta.data$doublet_class <- rep("singlet", 80) -# scdata@meta.data$doublet_class[1:10] <- rep("doublet", 10) - -# # add samples -# scdata$samples <- rep(c("123abc", "123def"), each = 40) -# scdata <- Seurat::RenameCells(scdata, paste(scdata$samples, colnames(scdata), sep = "")) -# return(scdata) -# } - - - -# test_that("filter_doublets filters based on threshold", { -# scdata <- mock_scdata() -# cells_id <- mock_ids() -# # should filter first 10 cells -# config <- mock_config(0.5) - -# out <- filter_doublets(scdata, config, "123abc", cells_id) -# expect_equal(ncol(out$data), 80) -# expect_equal(out$new_ids$`123abc`, 10:39) -# }) - -# test_that("filter_doublets is sample aware", { -# scdata <- mock_scdata() -# cells_id <- mock_ids() -# scdata@meta.data$doublet_scores[71:80] <- 0.9 -# config <- mock_config(0.5) - -# out <- filter_doublets(scdata, config, "123abc", cells_id) -# expect_equal(ncol(out$data), 80) -# expect_equal(out$new_ids$`123abc`, 10:39) -# expect_equal(out$new_ids$`123def`, 40:79) - -# out <- filter_doublets(out$data, config, "123def", out$new_ids) -# expect_equal(ncol(out$data), 80) -# expect_equal(out$new_ids$`123abc`, 10:39) -# expect_equal(out$new_ids$`123def`, 40:69) -# }) - -# test_that("filter_doublets filters works with auto", { -# scdata <- mock_scdata() -# cells_id <- mock_ids() -# # should filter first 10 cells -# config <- mock_config(0.001, auto = TRUE) -# out <- filter_doublets(scdata, config, "123abc", cells_id) -# expect_equal(out$new_ids$`123abc`, 10:39) - -# config <- mock_config(0.001, auto = FALSE) -# out <- filter_doublets(scdata, config, "123abc", cells_id) -# expect_equal(length(out$new_ids$`123abc`), 0) -# }) - -# test_that("filter_doublets can be disabled", { -# scdata <- mock_scdata() -# cells_id <- mock_ids() -# config <- mock_config(0.5, enabled = FALSE) -# out <- filter_doublets(scdata, config, "123abc", cells_id) -# expect_equal(out$new_ids$`123abc`, 0:39) -# expect_equal(out$new_ids$`123def`, 40:79) - -# config <- mock_config(0.5, enabled = TRUE) -# out <- filter_doublets(scdata, config, "123abc", cells_id) -# expect_equal(out$new_ids$`123abc`, 10:39) -# expect_equal(out$new_ids$`123def`, 40:79) -# }) +mock_config <- function(thr = 0.1, auto = FALSE, enabled = TRUE) { + config <- list( + auto = auto, + enabled = enabled, + filterSettings = list( + probabilityThreshold = thr + ) + ) + return(config) +} + + +mock_scdata <- function() { + pbmc_raw <- read.table( + file = system.file("extdata", "pbmc_raw.txt", package = "Seurat"), + as.is = TRUE + ) + + scdata <- Seurat::CreateSeuratObject(counts = pbmc_raw) + scdata$cells_id <- 0:(ncol(scdata) - 1) + + # add doublet scores and class + scdata@meta.data$doublet_scores <- 0.01 + scdata@meta.data$doublet_scores[1:10] <- 0.9 + + scdata@meta.data$doublet_class <- rep("singlet", 80) + scdata@meta.data$doublet_class[1:10] <- rep("doublet", 10) + + # add samples + scdata$samples <- rep(c("123abc", "123def"), each = 40) + scdata <- Seurat::RenameCells(scdata, paste(scdata$samples, colnames(scdata), sep = "")) + return(scdata) +} + + + +test_that("filter_doublets filters based on threshold", { + scdata <- mock_scdata() + cells_id <- mock_ids() + # should filter first 10 cells + config <- mock_config(0.5) + + out <- filter_doublets(scdata, config, "123abc", cells_id) + expect_equal(ncol(out$data), 80) + expect_equal(out$new_ids$`123abc`, 10:39) +}) + +test_that("filter_doublets is sample aware", { + scdata <- mock_scdata() + cells_id <- mock_ids() + scdata@meta.data$doublet_scores[71:80] <- 0.9 + config <- mock_config(0.5) + + out <- filter_doublets(scdata, config, "123abc", cells_id) + expect_equal(ncol(out$data), 80) + expect_equal(out$new_ids$`123abc`, 10:39) + expect_equal(out$new_ids$`123def`, 40:79) + + out <- filter_doublets(out$data, config, "123def", out$new_ids) + expect_equal(ncol(out$data), 80) + expect_equal(out$new_ids$`123abc`, 10:39) + expect_equal(out$new_ids$`123def`, 40:69) +}) + +test_that("filter_doublets filters works with auto", { + scdata <- mock_scdata() + cells_id <- mock_ids() + # should filter first 10 cells + config <- mock_config(0.001, auto = TRUE) + out <- filter_doublets(scdata, config, "123abc", cells_id) + expect_equal(out$new_ids$`123abc`, 10:39) + + config <- mock_config(0.001, auto = FALSE) + out <- filter_doublets(scdata, config, "123abc", cells_id) + expect_equal(length(out$new_ids$`123abc`), 0) +}) + +test_that("filter_doublets can be disabled", { + scdata <- mock_scdata() + cells_id <- mock_ids() + config <- mock_config(0.5, enabled = FALSE) + out <- filter_doublets(scdata, config, "123abc", cells_id) + expect_equal(out$new_ids$`123abc`, 0:39) + expect_equal(out$new_ids$`123def`, 40:79) + + config <- mock_config(0.5, enabled = TRUE) + out <- filter_doublets(scdata, config, "123abc", cells_id) + expect_equal(out$new_ids$`123abc`, 10:39) + expect_equal(out$new_ids$`123def`, 40:79) +}) From 4ab6158bb040b9079e993198d5eb861accde276b Mon Sep 17 00:00:00 2001 From: stefanbabukov Date: Thu, 11 Nov 2021 10:02:31 +0000 Subject: [PATCH 17/19] change fail --- pipeline-runner/init.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pipeline-runner/init.R b/pipeline-runner/init.R index 39ff9459..c9cc403c 100644 --- a/pipeline-runner/init.R +++ b/pipeline-runner/init.R @@ -333,10 +333,12 @@ init <- function() { tryCatchLog({ input_parse <- RJSONIO::fromJSON(input, simplify = FALSE) - wrapper(input) + message("current step name ", input_parse$taskName) if(input_parse$taskName == "mitochondrialContent"){ stop("TEST STOPPING!!!") } + wrapper(input) + message('Send task success\n------\n') states$send_task_success( taskToken = taskToken, From 75bbbfc33732db915b4e5ecb1846743e0d4fb547 Mon Sep 17 00:00:00 2001 From: Pol Alvarez Date: Thu, 11 Nov 2021 15:16:07 +0100 Subject: [PATCH 18/19] added taskName to fail pipeline message --- pipeline-runner/R/handle_data.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pipeline-runner/R/handle_data.R b/pipeline-runner/R/handle_data.R index 9ee3dbeb..fa8cd0f7 100644 --- a/pipeline-runner/R/handle_data.R +++ b/pipeline-runner/R/handle_data.R @@ -130,8 +130,9 @@ send_pipeline_fail_update <- function(pipeline_config, input, error_message) { error_msg <- list() # TODO - REMOVE THE DUPLICATE EXPERIMETN ID FROM INPUT RESPONSE - + error_msg$experimentId <- input$experimentId + error_msg$taskName <- input$taskName error_msg$response$error <- process_name error_msg$input <- input sns <- paws::sns(config = pipeline_config$aws_config) From 8a79b1dc9ba2d3d55e810f2a933f437105636abd Mon Sep 17 00:00:00 2001 From: stefanbabukov Date: Thu, 11 Nov 2021 14:46:32 +0000 Subject: [PATCH 19/19] remove stopping --- pipeline-runner/init.R | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pipeline-runner/init.R b/pipeline-runner/init.R index c9cc403c..b2d37e9c 100644 --- a/pipeline-runner/init.R +++ b/pipeline-runner/init.R @@ -332,11 +332,6 @@ init <- function() { } tryCatchLog({ - input_parse <- RJSONIO::fromJSON(input, simplify = FALSE) - message("current step name ", input_parse$taskName) - if(input_parse$taskName == "mitochondrialContent"){ - stop("TEST STOPPING!!!") - } wrapper(input) message('Send task success\n------\n')