Conversation
- correct some spelling errors - move error management using cli_abort - compartment number is no based on ode number in file - 100% coverage
- renamed export -> BDexport - better name management - return invisible message for user when exporting
|
I am assuming this BDExport is targeted at the BestDose GUI, and not the BestDose functionality in Pmetrics, right? My perspective here is package separation, i.e. not blending dependencies with integration. If it is possible to achieve the same functionality by separating the code clearly between packages, that is always preferred. What do you think, @R-garreau ? |
There was a problem hiding this comment.
Pull request overview
Adds an experimental export path from a PM_result run into a BestDose-compatible JSON model file, backed by new helper functions and unit tests.
Changes:
- Introduce
BDexport()onPM_resultto write a BestDose JSON model file to disk. - Add
R/BD_create.Rhelper functions to convert Pmetrics model components into the BestDose schema. - Add
testthatcoverage for the BestDose export helpers.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
R/BD_create.R |
New helper functions to translate Pmetrics model/run objects into a BestDose JSON model list. |
R/PM_result.R |
Adds BDexport() method to export a run’s model as JSON. |
tests/testthat/test-BD_create.R |
Adds unit tests for the BestDose conversion helpers. |
Comments suppressed due to low confidence (1)
R/PM_result.R:331
BDexport()writes todir_pathwithout validating that the directory exists (or creating it). If the user passes a non-existent path,writeLines()will fail with a fairly opaque base error. Consider checkingdir.exists(dir_path)(and eitherdir.create(..., recursive = TRUE)orcli::cli_abort()with a clear message) before writing the JSON.
file_name <- if (is.null(dir_path)) {
paste0(drug_name, ".json")
} else {
file.path(dir_path, paste0(drug_name, ".json"))
}
# #export to JSON
jsonlite::toJSON(model_list, pretty = TRUE, auto_unbox = TRUE, null = "null") |>
writeLines(con = file_name)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
I agree about package separation but the goal here is simply to transform your final run in BestDose model file. This is more a Pmetrics functionality for me |
Ideally, BestDose should be able to read the file that is given when you use |
Can you fix this issue before it is merged? |
This is not changed i made, it comes from the bestdose branch. |
|
I've fixed the pkgdown error and merged bestdose into BD-Michael, which was the branch that had my changes. I'll create a PR to merge BD-Michael into main. |
|
@mnneely I've seen that you latest merge into BD-Michael recorrected the issue adress to Pmetrics_rust instead of Pmetrics, see DESCRIPTION |
|
Yes, I know thx. It will be updated. |
R/BD_create.R[function call]
[coverage]
[edit]
2026-03-05
@mnneely it is now ready for merge.