Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Object validation in Project #728

Draft
wants to merge 11 commits into
base: implement-project
Choose a base branch
from

Conversation

AKostiv8
Copy link
Contributor

@AKostiv8 AKostiv8 commented Oct 14, 2024

Originally: #710

AKostiv8 and others added 3 commits October 4, 2024 13:31
* fix save function

* Fix tests

* Remove duplicated tests

* fix bad merge conflict resolution

* Restore populationsFolder to populationCSV

* remove PI as dependency

* Update project directory structure in presentation

* Add prerequisite section for installation

* Use latest functions in README
+ knit

* Rename Population Folder ProjectConfiguration property
- Property is named populationsFolder
- Project template folder contains populations is named PopulationsCSV

* styler::style_pkg()

* correct object case

* Add a test that makes sure that ProjectConfiguration can be customize but throws warning if wront value are provided.

* Add NEWS entries
+ format

* devtools::document()

* extend project configuration tests
+fix typo

* Prevent user from modifying scenarios directly

* Refactor repeated error messages

* fix files names

* Improve readme (closes #721)

* Update documentation

* Remove pksim initialization steps (closes #693)

* replace deprecated function

* pull from main

* Update path to where results are stored now

* Remove embeded shiny apps

* Update plots test for new project structure

* remove/relocate outdated test

* update snaps

* Rename / Comment out of date tests

* remove shiny app launching script

* merge from main

* devtools::documen()

* Revert "Validation object & individual modification validation" (#726)

* update snapshot after updating packages

---------

Co-authored-by: Felix MIL <[email protected]>
@AKostiv8 AKostiv8 requested a review from Felixmil October 14, 2024 12:03
@Felixmil Felixmil changed the title Implement project (#710) Add Object validation in Project Oct 14, 2024
@Felixmil Felixmil marked this pull request as draft October 14, 2024 13:58
@Felixmil
Copy link
Collaborator

I think something went wrong during some merge or PR creation: some files are missing (WarningManager is one of them I think)

Copy link

codecov bot commented Oct 15, 2024

Codecov Report

Attention: Patch coverage is 48.14815% with 112 lines in your changes missing coverage. Please review.

Project coverage is 70.37%. Comparing base (84aea3b) to head (e33c65c).

Files with missing lines Patch % Lines
R/project.R 43.37% 47 Missing ⚠️
R/scenario-configuration.R 65.00% 21 Missing ⚠️
R/project-configuration.R 0.00% 19 Missing ⚠️
R/configuration.R 0.00% 13 Missing ⚠️
R/utilities.R 0.00% 12 Missing ⚠️
Additional details and impacted files
@@                  Coverage Diff                  @@
##           implement-project     #728      +/-   ##
=====================================================
- Coverage              71.32%   70.37%   -0.95%     
=====================================================
  Files                     34       35       +1     
  Lines                   4226     4368     +142     
=====================================================
+ Hits                    3014     3074      +60     
- Misses                  1212     1294      +82     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

test_that("Export aborts with invalid directory in non-interactive mode", {
p <- testProject()
# Capture cli output using testthat::expect_message()
expect_message(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use expect_error and fill the regex argument to check for error message

@@ -185,19 +185,33 @@ Project <-
#' @description Export the entire project to a JSON file
#' @param filePath The file path where the JSON will be saved
#' @return NULL
exportToJSON = function() {
exportToJSON = function(interactiveInput = TRUE, dirPath = NULL, fileName = NULL) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also provide an export() function defined like this:

export <- function(project, json = TRUE, xlsx = TRUE){}

This function would call internally project$exportToJSON and in the future project$exportToExcel once we have it.

R/project.R Outdated
}
# Validate directory path
if (!dir.exists(dirPath)) {
cli::cli_alert_danger("Invalid directory path. Export aborted.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use cli_abort instead and do not return anything ?

@@ -126,3 +126,44 @@ test_that("Model is not defined", {
"MODEL_NOT_FOUND"
)
})


# Project export test ----------------------------------------------------------
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also add tests for import.

R/project.R Outdated
# Ensure both parameters are provided if interactiveInput is FALSE
if (is.null(dirPath) || is.null(fileName)) {
cli::cli_alert_danger("Both 'dirPath' and 'fileName' must be provided when 'interactiveInput' is FALSE.")
return(invisible(NULL))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not the first time I see functions returning NULL when everything's ok. But could you elaborate why we want to do so ?

We don't usually do it in the rest of the package now for homogeneity concerns I would either: not do it or implement it everywhere (but it requires a very good reason to spend time on this).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants