Skip to content

Commit

Permalink
Release v0.2.0 prep (#117)
Browse files Browse the repository at this point in the history
* Run styler

* Update copyright year

* Rebuild vignettes and pkg docs

* Regenerate docs
  • Loading branch information
anthonysena authored Jan 26, 2024
1 parent cc40531 commit bda6bef
Show file tree
Hide file tree
Showing 60 changed files with 1,096 additions and 119 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: Strategus
Type: Package
Title: Coordinating and Executing Analytics Using HADES Modules
Version: 0.1.0
Date: 2023-10-04
Version: 0.2.0
Date: 2023-01-26
Authors@R: c(
person("Martijn", "Schuemie", email = "[email protected]", role = c("aut")),
person("Anthony", "Sena", email = "[email protected]", role = c("aut", "cre")),
Expand Down Expand Up @@ -47,7 +47,7 @@ Remotes:
ohdsi/Eunomia
VignetteBuilder: knitr
NeedsCompilation: no
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Roxygen: list(markdown = TRUE)
Encoding: UTF-8
Config/testthat/edition: 3
11 changes: 11 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
Strategus 0.2.0
===============
- Add functions for developers to help with renv.lock file validation (#69)
- Use renv project profiles for modules (#94)
- Convert relative paths to absolute path before passing to a module (#99)
- Address missing package dependencies in modules (#99)
- Throw informative error message when connection detail reference not set in keyring (#100)
- Validate execution settings (#101)
- Pass temp emulation schema properly (#76)
- Remove local library package dependencies (#96)

Strategus 0.1.0
===============

Expand Down
2 changes: 1 addition & 1 deletion R/DatabaseMetaData.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Observational Health Data Sciences and Informatics
# Copyright 2024 Observational Health Data Sciences and Informatics
#
# This file is part of Strategus
#
Expand Down
27 changes: 15 additions & 12 deletions R/Execution.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Observational Health Data Sciences and Informatics
# Copyright 2024 Observational Health Data Sciences and Informatics
#
# This file is part of Strategus
#
Expand Down Expand Up @@ -72,18 +72,21 @@ execute <- function(analysisSpecifications,
FUN = function(tableName) {
sql <- SqlRender::render(
sql = "CREATE TABLE @table;",
table = tableName
table = tableName
)
tryCatch(
{
SqlRender::translate(
sql = sql,
targetDialect = connectionDetails$dbms
)
return(TRUE)
},
warning = function(w) {
warning(w)
return(FALSE)
}
)
tryCatch({
SqlRender::translate(
sql = sql,
targetDialect = connectionDetails$dbms
)
return(TRUE)
}, warning = function(w) {
warning(w)
return(FALSE)
})
}
)

Expand Down
2 changes: 1 addition & 1 deletion R/ModuleEnv.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Observational Health Data Sciences and Informatics
# Copyright 2024 Observational Health Data Sciences and Informatics
#
# This file is part of Strategus
#
Expand Down
23 changes: 13 additions & 10 deletions R/ModuleInstantiation.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Observational Health Data Sciences and Informatics
# Copyright 2024 Observational Health Data Sciences and Informatics
#
# This file is part of Strategus
#
Expand Down Expand Up @@ -87,9 +87,11 @@ ensureAllModulesInstantiated <- function(analysisSpecifications, forceVerificati
)
moduleInstallStatus[[length(moduleInstallStatus) + 1]] <- status
}
attr(modules, 'moduleInstallStatus') <- moduleInstallStatus
attr(modules, "moduleInstallStatus") <- moduleInstallStatus

installStatus <- unlist(lapply(moduleInstallStatus, FUN = function(x) { x$moduleInstalled }))
installStatus <- unlist(lapply(moduleInstallStatus, FUN = function(x) {
x$moduleInstalled
}))
if (!all(installStatus)) {
problemModules <- moduleInstallStatus[!installStatus]
message("There were ", length(problemModules), " issue(s) found with your Strategus modules!")
Expand Down Expand Up @@ -159,7 +161,7 @@ verifyModuleInstallation <- function(module, version, silent = FALSE, forceVerif
verifyModuleInstallationReturnValue(
moduleFolder = moduleFolder,
moduleInstalled = FALSE
)
)
)
}

Expand Down Expand Up @@ -207,7 +209,7 @@ verifyModuleInstallation <- function(module, version, silent = FALSE, forceVerif
verifyModuleInstallationReturnValue(
moduleFolder = moduleFolder,
moduleInstalled = TRUE
)
)
)
}
}
Expand All @@ -230,12 +232,13 @@ verifyModuleInstallation <- function(module, version, silent = FALSE, forceVerif
packages <- sort(union(renv::dependencies(quiet = TRUE)$Package, "renv"))
packages <- sort(unique(c(library, lockfile, packages)))
projectStatus$packages <- packages
saveRDS(object = list(
library = library,
lockfile = lockfile,
packages = packages
saveRDS(
object = list(
library = library,
lockfile = lockfile,
packages = packages
),
file="projectStatus.rds"
file = "projectStatus.rds"
)
},
moduleFolder = moduleFolder
Expand Down
45 changes: 26 additions & 19 deletions R/RenvHelpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ syncLockFile <- function(sourceOfTruthLockFileName, targetLockFileName) {
filename2 = targetLockFileName
)
verDiffs <- comparedLockFiles[!is.na(comparedLockFiles$lockfile2Version) &
comparedLockFiles$lockfile1Version != comparedLockFiles$lockfile2Version,]
verDiffs <- verDiffs[!is.na(verDiffs$lockfile1Name),]
comparedLockFiles$lockfile1Version != comparedLockFiles$lockfile2Version, ]
verDiffs <- verDiffs[!is.na(verDiffs$lockfile1Name), ]

if (nrow(verDiffs) == 0) {
rlang::inform("Lock files are already in sync.")
Expand All @@ -93,32 +93,32 @@ syncLockFile <- function(sourceOfTruthLockFileName, targetLockFileName) {

# Update the target lock file based on the source of truth
for (i in 1:nrow(verDiffs)) {
index <- findPackageByName(targetLockFile$Packages, verDiffs[i,]$lockfile1Name)
index <- findPackageByName(targetLockFile$Packages, verDiffs[i, ]$lockfile1Name)
tryCatch(expr = {
semverPattern <- "^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?(?:\\+[0-9A-Za-z-]+)?$"
sourceOfTruthVersion <- verDiffs[i,]$lockfile1Version
sourceOfTruthVersion <- verDiffs[i, ]$lockfile1Version
targetVersion <- targetLockFile$Packages[[index]]$Version
if (grepl(semverPattern, sourceOfTruthVersion) && grepl(semverPattern, targetVersion)) {
sourceOfTruthVersion <- semver::parse_version(sourceOfTruthVersion)
targetVersion <- semver::parse_version(targetVersion)
if (sourceOfTruthVersion > targetVersion) {
rlang::inform(
message = paste(verDiffs[i,]$lockfile1Name, "[", targetVersion, "->", sourceOfTruthVersion, "]")
message = paste(verDiffs[i, ]$lockfile1Name, "[", targetVersion, "->", sourceOfTruthVersion, "]")
)
targetLockFile$Packages[[index]]$Version <- verDiffs[i,]$lockfile1Version
if (!is.na(verDiffs[i,]$lockfile1RemoteRef)) {
targetLockFile$Packages[[index]]$RemoteRef <- verDiffs[i,]$lockfile1RemoteRef
targetLockFile$Packages[[index]]$Version <- verDiffs[i, ]$lockfile1Version
if (!is.na(verDiffs[i, ]$lockfile1RemoteRef)) {
targetLockFile$Packages[[index]]$RemoteRef <- verDiffs[i, ]$lockfile1RemoteRef
}
} else {
rlang::inform(
message = paste(verDiffs[i,]$lockfile1Name, "[ SKIPPING - ", targetVersion, ">", sourceOfTruthVersion, "]")
message = paste(verDiffs[i, ]$lockfile1Name, "[ SKIPPING - ", targetVersion, ">", sourceOfTruthVersion, "]")
)
}
} else {
rlang::warn(paste0("Package: [", verDiffs[i,]$lockfile1Name, "] - version number could not be parsed. Please inspect manually as it may require an upgrade."))
rlang::warn(paste0("Package: [", verDiffs[i, ]$lockfile1Name, "] - version number could not be parsed. Please inspect manually as it may require an upgrade."))
}
}, error = function(err) {
rlang::inform("An error occurred:", str(err), "\n")
rlang::inform("An error occurred:", utils::str(err), "\n")
})
}

Expand Down Expand Up @@ -154,8 +154,8 @@ validateLockFile <- function(filename) {

# Check that the mandatory dependencies are met
message("Checking mandatory packages...", appendLF = F)
if (length(mandatoryPackages()) != nrow(df[df$Name %in% mandatoryPackages(),])) {
missingPkgs <- setdiff(mandatoryPackages(), df[df$Name %in% mandatoryPackages(),]$Name)
if (length(mandatoryPackages()) != nrow(df[df$Name %in% mandatoryPackages(), ])) {
missingPkgs <- setdiff(mandatoryPackages(), df[df$Name %in% mandatoryPackages(), ]$Name)
message("FAILED!")
message(" -- Missing the mandatory packages: ", paste(missingPkgs, collapse = ", "))
message(" Please record these missing dependencies in your renv.lock file.")
Expand All @@ -165,8 +165,8 @@ validateLockFile <- function(filename) {

# Check for suggested packages
message("Checking suggested packages...", appendLF = F)
if (length(suggestedPacakges()) != nrow(df[df$Name %in% suggestedPacakges(),])) {
missingPkgs <- setdiff(suggestedPacakges(), df[df$Name %in% suggestedPacakges(),]$Name)
if (length(suggestedPacakges()) != nrow(df[df$Name %in% suggestedPacakges(), ])) {
missingPkgs <- setdiff(suggestedPacakges(), df[df$Name %in% suggestedPacakges(), ]$Name)
message("WARNING!")
message(" -- Missing the suggested packages: ", paste(missingPkgs, collapse = ", "))
message(" This is an optional set of dependencies so you may decide if you wish to have them in your renv.lock file.")
Expand All @@ -177,10 +177,10 @@ validateLockFile <- function(filename) {
# Check that we're using declared versions of all packages
message("Checking all package using tagged versions in RemoteRef...", appendLF = F)
# Start by filtering out the CRAN Repository entries
dfFiltered <- df[tolower(df$Source) != "repository",]
dfFiltered <- df[tolower(df$Source) != "repository", ]
if (!all(grepl("^(v)?\\d+(\\.\\d+){2}$", dfFiltered$RemoteRef))) {
message("FAILED! Please check the following packages:")
problemPkgs <- dfFiltered[!grepl("^(v)?\\d+(\\.\\d+){2}$", dfFiltered$RemoteRef),]
problemPkgs <- dfFiltered[!grepl("^(v)?\\d+(\\.\\d+){2}$", dfFiltered$RemoteRef), ]
for (i in 1:nrow(problemPkgs)) {
message(paste0(" -- Package: ", problemPkgs$Name[[i]], "; RemoteRef: ", problemPkgs$RemoteRef[[i]]))
}
Expand All @@ -190,6 +190,9 @@ validateLockFile <- function(filename) {
}
}

#' List of mandatory packages for a Strategus module
#'
#' @keywords internal
mandatoryPackages <- function() {
return(c(
"CohortGenerator",
Expand All @@ -201,12 +204,17 @@ mandatoryPackages <- function() {
))
}

#' List of suggested packages for a Strategus module
#'
#' @keywords internal
suggestedPacakges <- function() {
return(c("RSQLite"))
}


# internal function to read lock file into data frame
#' Convert a lock file to a data.frame
#'
#' @keywords internal
lockFileToDataFrame <- function(lf) {
df <- data.frame()
for (i in 1:length(lf$Packages)) {
Expand All @@ -222,4 +230,3 @@ lockFileToDataFrame <- function(lf) {
}
return(df)
}

2 changes: 1 addition & 1 deletion R/ResultModelCreation.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Observational Health Data Sciences and Informatics
# Copyright 2024 Observational Health Data Sciences and Informatics
#
# This file is part of Strategus
#
Expand Down
2 changes: 1 addition & 1 deletion R/ResultsUpload.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Observational Health Data Sciences and Informatics
# Copyright 2024 Observational Health Data Sciences and Informatics
#
# This file is part of Strategus
#
Expand Down
2 changes: 1 addition & 1 deletion R/RunModule.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Observational Health Data Sciences and Informatics
# Copyright 2024 Observational Health Data Sciences and Informatics
#
# This file is part of Strategus
#
Expand Down
2 changes: 1 addition & 1 deletion R/Settings.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Observational Health Data Sciences and Informatics
# Copyright 2024 Observational Health Data Sciences and Informatics
#
# This file is part of Strategus
#
Expand Down
2 changes: 1 addition & 1 deletion R/Strategus.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Observational Health Data Sciences and Informatics
# Copyright 2024 Observational Health Data Sciences and Informatics
#
# This file is part of Strategus
#
Expand Down
2 changes: 1 addition & 1 deletion docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bda6bef

Please sign in to comment.