From 501ffacd1644b978a16ac09866b0ec56e36c1a2e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Feb 2026 16:12:30 +0000 Subject: [PATCH 1/5] Initial plan From 18f6bf5cd3dfc87670bd06602b17ebd6af1dbcd0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Feb 2026 16:18:52 +0000 Subject: [PATCH 2/5] Add finalize method to MeanModelWorkflow for lifecycle management Co-authored-by: KatrinCoboeken <28564329+KatrinCoboeken@users.noreply.github.com> --- R/mean-model-workflow.R | 9 ++++++++ tests/testthat/test-workflow-structure.R | 26 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/R/mean-model-workflow.R b/R/mean-model-workflow.R index fded21a66..ba94644ba 100644 --- a/R/mean-model-workflow.R +++ b/R/mean-model-workflow.R @@ -129,6 +129,15 @@ MeanModelWorkflow <- R6::R6Class( # Stop logging messages in workflowFolder after run is completed # Prevents potential logging of new messages in previous workflowFolder setLogFolder() + }, + + #' @description + #' Finalize the `MeanModelWorkflow` object. + #' This method is called automatically when the object is garbage collected. + #' It ensures proper cleanup of resources. + finalize = function() { + # Reset log folder to prevent logging to workflow folder after object destruction + setLogFolder() } ) ) diff --git a/tests/testthat/test-workflow-structure.R b/tests/testthat/test-workflow-structure.R index 35127808e..a8e57acaf 100644 --- a/tests/testthat/test-workflow-structure.R +++ b/tests/testthat/test-workflow-structure.R @@ -62,3 +62,29 @@ test_that("Workflows initialization creates appropriate folder and logs, and war resetLogs() unlink(testFolder, recursive = TRUE) }) + +test_that("MeanModelWorkflow has finalize method for lifecycle management", { + testFolder <- "testFolder" + unlink(testFolder, recursive = TRUE) + + simSet <- SimulationSet$new( + simulationSetName = "myTest", + simulationFile = getTestDataFilePath("input-data/MiniModel2.pkml") + ) + + # Create workflow + expect_output(mWorkflow <- MeanModelWorkflow$new( + simulationSets = simSet, + workflowFolder = testFolder + )) + + # Verify that the finalize method exists + expect_true("finalize" %in% names(mWorkflow)) + + # Cleanup + rm(mWorkflow) + gc() # Force garbage collection to trigger finalize + + resetLogs() + unlink(testFolder, recursive = TRUE) +}) From b1193dc63f737f9f199c3a0a1f085f239af6cb07 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Feb 2026 16:20:03 +0000 Subject: [PATCH 3/5] Improve test to verify finalize method behavior Co-authored-by: KatrinCoboeken <28564329+KatrinCoboeken@users.noreply.github.com> --- tests/testthat/test-workflow-structure.R | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-workflow-structure.R b/tests/testthat/test-workflow-structure.R index a8e57acaf..7adec6f3a 100644 --- a/tests/testthat/test-workflow-structure.R +++ b/tests/testthat/test-workflow-structure.R @@ -72,7 +72,7 @@ test_that("MeanModelWorkflow has finalize method for lifecycle management", { simulationFile = getTestDataFilePath("input-data/MiniModel2.pkml") ) - # Create workflow + # Create workflow - this sets log folder to workflowFolder expect_output(mWorkflow <- MeanModelWorkflow$new( simulationSets = simSet, workflowFolder = testFolder @@ -81,9 +81,17 @@ test_that("MeanModelWorkflow has finalize method for lifecycle management", { # Verify that the finalize method exists expect_true("finalize" %in% names(mWorkflow)) + # Manually call finalize to test its behavior + # The finalize method should reset the log folder + mWorkflow$finalize() + + # After finalize, logging should not go to the workflow folder + # We can't directly test setLogFolder() output, but we verify no errors occur + expect_silent(mWorkflow$finalize()) + # Cleanup rm(mWorkflow) - gc() # Force garbage collection to trigger finalize + gc() # Force garbage collection to trigger finalize automatically resetLogs() unlink(testFolder, recursive = TRUE) From 4a81a6651a46859887cfe5780eb669f17eab032b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Feb 2026 16:21:30 +0000 Subject: [PATCH 4/5] Enhance test to verify log folder reset behavior in finalize method Co-authored-by: KatrinCoboeken <28564329+KatrinCoboeken@users.noreply.github.com> --- tests/testthat/test-workflow-structure.R | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-workflow-structure.R b/tests/testthat/test-workflow-structure.R index 7adec6f3a..029a3a1aa 100644 --- a/tests/testthat/test-workflow-structure.R +++ b/tests/testthat/test-workflow-structure.R @@ -81,13 +81,20 @@ test_that("MeanModelWorkflow has finalize method for lifecycle management", { # Verify that the finalize method exists expect_true("finalize" %in% names(mWorkflow)) + # Set log folder to the workflow folder to simulate active workflow state + setLogFolder(testFolder) + expect_equal(reEnv$log$folder, testFolder) + # Manually call finalize to test its behavior - # The finalize method should reset the log folder + # The finalize method should reset the log folder to NULL mWorkflow$finalize() - # After finalize, logging should not go to the workflow folder - # We can't directly test setLogFolder() output, but we verify no errors occur + # Verify that the log folder has been reset to NULL + expect_null(reEnv$log$folder) + + # Calling finalize again should be safe (idempotent) expect_silent(mWorkflow$finalize()) + expect_null(reEnv$log$folder) # Cleanup rm(mWorkflow) From 2f1b1b9a3e9d472258a03a2e706900ac2ce86540 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Feb 2026 08:22:16 +0000 Subject: [PATCH 5/5] Deprecate MeanModelWorkflow in favor of OSPSuite.ReportingFramework Co-authored-by: KatrinCoboeken <28564329+KatrinCoboeken@users.noreply.github.com> --- R/mean-model-workflow.R | 29 +++-------- tests/testthat/test-absorption.R | 3 ++ tests/testthat/test-lloq.R | 3 ++ tests/testthat/test-mass-balance.R | 3 ++ tests/testthat/test-mean-model-gof.R | 3 ++ tests/testthat/test-mean-pk-parameters.R | 4 ++ tests/testthat/test-sensitivity.R | 4 ++ tests/testthat/test-tasks-in-workflow.R | 3 ++ tests/testthat/test-workflow-structure.R | 63 ++++-------------------- 9 files changed, 38 insertions(+), 77 deletions(-) diff --git a/R/mean-model-workflow.R b/R/mean-model-workflow.R index ba94644ba..f3988eabe 100644 --- a/R/mean-model-workflow.R +++ b/R/mean-model-workflow.R @@ -29,20 +29,12 @@ MeanModelWorkflow <- R6::R6Class( #' @param ... input parameters inherited from R6 class object `Workflow`. #' @return A new `MeanModelWorkflow` object initialize = function(...) { - super$initialize(...) - logCatch({ - self$simulate <- loadSimulateTask(self) - self$calculatePKParameters <- loadCalculatePKParametersTask(self) - self$calculateSensitivity <- loadCalculateSensitivityTask(self) - - self$plotTimeProfilesAndResiduals <- loadPlotTimeProfilesAndResidualsTask(self) - self$plotMassBalance <- loadPlotMassBalanceTask(self) - self$plotAbsorption <- loadPlotAbsorptionTask(self) - self$plotPKParameters <- loadPlotPKParametersTask(self) - self$plotSensitivity <- loadPlotSensitivityTask(self) - - self$taskNames <- enum(self$getAllTasks()) - }) + stop( + "MeanModelWorkflow is no longer available. ", + "Please use OSPSuite.ReportingFramework instead. ", + "For more information, visit: https://github.com/Open-Systems-Pharmacology/OSPSuite.ReportingFramework", + call. = FALSE + ) }, #' @description @@ -129,15 +121,6 @@ MeanModelWorkflow <- R6::R6Class( # Stop logging messages in workflowFolder after run is completed # Prevents potential logging of new messages in previous workflowFolder setLogFolder() - }, - - #' @description - #' Finalize the `MeanModelWorkflow` object. - #' This method is called automatically when the object is garbage collected. - #' It ensures proper cleanup of resources. - finalize = function() { - # Reset log folder to prevent logging to workflow folder after object destruction - setLogFolder() } ) ) diff --git a/tests/testthat/test-absorption.R b/tests/testthat/test-absorption.R index b3f94b28a..9cde98b04 100644 --- a/tests/testthat/test-absorption.R +++ b/tests/testthat/test-absorption.R @@ -1,5 +1,8 @@ context("Run workflow with absorption task") +# MeanModelWorkflow is deprecated, skip all tests in this file +skip("MeanModelWorkflow is deprecated") + simulationFile <- getTestDataFilePath("input-data/Larson 2013 8-18y meal.pkml") # Output reference absorption time profiles diff --git a/tests/testthat/test-lloq.R b/tests/testthat/test-lloq.R index 4fffaf576..713383384 100644 --- a/tests/testthat/test-lloq.R +++ b/tests/testthat/test-lloq.R @@ -4,6 +4,9 @@ library(ospsuite.reportingengine) context("Observed Data in plot time profile task") +# MeanModelWorkflow is deprecated, skip all tests in this file +skip("MeanModelWorkflow is deprecated") + # Input files and structures for comparisons simulationFile <- getTestDataFilePath("input-data/MiniModel2.pkml") diff --git a/tests/testthat/test-mass-balance.R b/tests/testthat/test-mass-balance.R index 999addd70..cbe8c5862 100644 --- a/tests/testthat/test-mass-balance.R +++ b/tests/testthat/test-mass-balance.R @@ -1,5 +1,8 @@ context("Run workflow with mass balance task") +# MeanModelWorkflow is deprecated, skip all tests in this file +skip("MeanModelWorkflow is deprecated") + simulationFile <- getTestDataFilePath("input-data/Larson 2013 8-18y meal.pkml") # Output reference absorption time profiles diff --git a/tests/testthat/test-mean-model-gof.R b/tests/testthat/test-mean-model-gof.R index 015342436..7e4035095 100644 --- a/tests/testthat/test-mean-model-gof.R +++ b/tests/testthat/test-mean-model-gof.R @@ -1,5 +1,8 @@ context("Run mean model workflows with Time Profiles and Residuals task") +# MeanModelWorkflow is deprecated, skip all tests in this file +skip("MeanModelWorkflow is deprecated") + simulationFile <- getTestDataFilePath("input-data/MiniModel2.pkml") dataFile <- getTestDataFilePath("input-data/SimpleData.nmdat") dictFile <- getTestDataFilePath("input-data/tpDictionary.csv") diff --git a/tests/testthat/test-mean-pk-parameters.R b/tests/testthat/test-mean-pk-parameters.R index 7b64037f4..53f72971b 100644 --- a/tests/testthat/test-mean-pk-parameters.R +++ b/tests/testthat/test-mean-pk-parameters.R @@ -1,4 +1,8 @@ context("Run workflows with PK parameters task") + +# MeanModelWorkflow is deprecated, skip all tests in this file +skip("MeanModelWorkflow is deprecated") + # Get test data simulationFile <- getTestDataFilePath("input-data/MiniModel2.pkml") diff --git a/tests/testthat/test-sensitivity.R b/tests/testthat/test-sensitivity.R index accc7483a..6d77dd677 100644 --- a/tests/testthat/test-sensitivity.R +++ b/tests/testthat/test-sensitivity.R @@ -1,4 +1,8 @@ context("Run workflows with Sensitivity tasks") + +# MeanModelWorkflow is deprecated, skip all tests in this file +skip("MeanModelWorkflow is deprecated") + # Get test data removeAllUserDefinedPKParameters() simulationFile <- getTestDataFilePath("input-data/MiniModel2.pkml") diff --git a/tests/testthat/test-tasks-in-workflow.R b/tests/testthat/test-tasks-in-workflow.R index 2dddf2def..b83cbae65 100644 --- a/tests/testthat/test-tasks-in-workflow.R +++ b/tests/testthat/test-tasks-in-workflow.R @@ -13,6 +13,9 @@ popSimSet <- PopulationSimulationSet$new( populationFile = getTestDataFilePath("input-data/Pop500_p1p2p3.csv") ) +# MeanModelWorkflow is deprecated, skip tests that use it +skip("MeanModelWorkflow is deprecated") + mWorkflow <- MeanModelWorkflow$new( simulationSets = meanSimSet, workflowFolder = meanTestFolder diff --git a/tests/testthat/test-workflow-structure.R b/tests/testthat/test-workflow-structure.R index 029a3a1aa..d77e2b4d8 100644 --- a/tests/testthat/test-workflow-structure.R +++ b/tests/testthat/test-workflow-structure.R @@ -33,19 +33,15 @@ test_that("Workflows initialization creates appropriate folder and logs, and war simulationFile = getTestDataFilePath("input-data/MiniModel2.pkml"), populationFile = "test.csv" ) - # Dummy simulation set for the example - expect_output(mWorkflow <- MeanModelWorkflow$new( - simulationSets = simSet, - workflowFolder = testFolder - )) - - expect_true(testFolder %in% list.files()) - expect_true("log-info.txt" %in% list.files(testFolder)) - expect_false("log-debug.txt" %in% list.files(testFolder)) - expect_false("log-error.txt" %in% list.files(testFolder)) - - # Make sure testFolder is not there - unlink(testFolder, recursive = TRUE) + + # MeanModelWorkflow is deprecated and should throw an error + expect_error( + MeanModelWorkflow$new( + simulationSets = simSet, + workflowFolder = testFolder + ), + "MeanModelWorkflow is no longer available" + ) # Dummy simulation set for the example expect_output(pWorkflow <- PopulationWorkflow$new( @@ -62,44 +58,3 @@ test_that("Workflows initialization creates appropriate folder and logs, and war resetLogs() unlink(testFolder, recursive = TRUE) }) - -test_that("MeanModelWorkflow has finalize method for lifecycle management", { - testFolder <- "testFolder" - unlink(testFolder, recursive = TRUE) - - simSet <- SimulationSet$new( - simulationSetName = "myTest", - simulationFile = getTestDataFilePath("input-data/MiniModel2.pkml") - ) - - # Create workflow - this sets log folder to workflowFolder - expect_output(mWorkflow <- MeanModelWorkflow$new( - simulationSets = simSet, - workflowFolder = testFolder - )) - - # Verify that the finalize method exists - expect_true("finalize" %in% names(mWorkflow)) - - # Set log folder to the workflow folder to simulate active workflow state - setLogFolder(testFolder) - expect_equal(reEnv$log$folder, testFolder) - - # Manually call finalize to test its behavior - # The finalize method should reset the log folder to NULL - mWorkflow$finalize() - - # Verify that the log folder has been reset to NULL - expect_null(reEnv$log$folder) - - # Calling finalize again should be safe (idempotent) - expect_silent(mWorkflow$finalize()) - expect_null(reEnv$log$folder) - - # Cleanup - rm(mWorkflow) - gc() # Force garbage collection to trigger finalize automatically - - resetLogs() - unlink(testFolder, recursive = TRUE) -})