Skip to content

Commit

Permalink
Fixes for R check
Browse files Browse the repository at this point in the history
  • Loading branch information
azimov committed Jul 18, 2024
1 parent e0dd7b5 commit 9bc8512
Show file tree
Hide file tree
Showing 37 changed files with 322 additions and 84 deletions.
3 changes: 2 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ compare_versions
^Meta$
LICENSE
.git
..Rcheck
..Rcheck
errorReportSql.txt
1 change: 1 addition & 0 deletions R/ConnectionHandler.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#' @import R6
#' @importFrom DBI dbIsValid
#' @importFrom SqlRender render translate
#' @importFrom dbplyr in_schema
#'
#' @export ConnectionHandler
ConnectionHandler <- R6::R6Class(
Expand Down
11 changes: 8 additions & 3 deletions R/PooledConnectionHandler.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@


requiredPackage <- function(packageName) {
packageLoc <- tryCatch(find.package("foo"), errorr = function(...) {
return(NULL)
})
packageLoc <- tryCatch(
find.package(packageName),
errorr = function(...) {
return(NULL)
}
)

if (is.null(packageLoc)) {
stop(paste("Package", packageName, "is required please use install.packages to install"))
}
Expand Down Expand Up @@ -83,6 +87,7 @@ requiredPackage <- function(packageName) {
#'
#' @importFrom pool dbPool poolClose
#' @importFrom DBI dbIsValid
#' @importFrom withr defer
#'
#' @export PooledConnectionHandler
PooledConnectionHandler <- R6::R6Class(
Expand Down
15 changes: 11 additions & 4 deletions R/QueryNamespace.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,21 @@
#' Given a results specification and ConnectionHandler instance - this class allow queries to be namespaced within
#' any tables specified within a list of pre-determined tables. This allows the encapsulation of queries, using specific
#' table names in a consistent manner that is striaghtforward to maintain over time.
#' @importFrom fastmap fastmap
#' @examples
#'
#' library(ResultModelManager)
#'
#' # Create some junk test data
#' connectionDetails <- DatabaseConnector::createConnectionDetails(server = ":memory:", dbms = "sqlite")
#' connectionDetails <-
#' DatabaseConnector::createConnectionDetails(
#' server = "test_db.sqlite",
#' dbms = "sqlite"
#' )
#'
#' conn <- DatabaseConnector::connect(connectionDetails)
#' DatabaseConnector::insertTable(
#' connection = conn,
#' tableName = "cd_cohort",
#' data = data.frame(
#' cohort_id = c(1, 2, 3),
Expand All @@ -53,7 +59,7 @@
#' )
#'
#' cohortNamespace <- QueryNamespace$new(
#' connnectionHandler = connnectionHandler,
#' connectionHandler = connectionHandler,
#' tableSpecification = tableSpecification,
#' result_schema = "main",
#' tablePrefix = "cd_"
Expand All @@ -62,8 +68,9 @@
#' # Returns : "SELECT * FROM main.cd_cohort WHERE cohort_id = @cohort_id"
#' print(cohortNamespace$render(sql))
#' # Returns query result
#' result <- cohortNamespace$querySql(sql, cohort_id = 1)
#'
#' result <- cohortNamespace$queryDb(sql, cohort_id = 1)
#' # cleanup test data
#' unlink("test_db.sqlite")
QueryNamespace <- R6::R6Class(
classname = "QueryNamespace",
private = list(
Expand Down
2 changes: 1 addition & 1 deletion R/SchemaGenerator.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#' Take a csv schema definition and create a basic sql script with it.
#' returns string containing the sql for the table
#' @param csvFilepath Path to schema file. Csv file must have the columns:
#' "table_name", "column_name", "data_type", "is_required", "primary_key"
#' "table_name", "column_name", "data_type", "primary_key"
#' @param schemaDefinition A schemaDefintiion data.frame` with the columns:
#' tableName, columnName, dataType, isRequired, primaryKey
#' @param sqlOutputPath File to write sql to.
Expand Down
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
ResultModelManager
==================
[![Build Status](https://github.com/OHDSI/ResultModelManager/workflows/R-CMD-check/badge.svg)](https://github.com/OHDSI/ResultModelManager/actions?query=workflow%3AR-CMD-check)
[![codecov.io](https://app.codecov.io/github/OHDSI/ResultModelManager/coverage.svg?branch=main)](https://app.codecov.io/github/OHDSI/ResultModelManager?branch=main)
[![codecov.io](https://codecov.io/github/OHDSI/ResultModelManager/coverage.svg?branch=main)](https://app.codecov.io/github/OHDSI/ResultModelManager?branch=main)

ResultModelManager (RMM) [HADES](https://ohdsi.github.io/Hades/).

Introduction
============
RMM is an R package designed to handle common ohdsi results data management functions by providing a common API for data model migrations and definitions
RMM is a database data model management utilities for R packages in the [Observational Health Data Sciences and Informatics program](https://ohdsi.org). RMM provides utility functions to
allow package maintainers to migrate existing SQL database models, export and import results in consistent patterns.


System Requirements
Expand All @@ -26,6 +27,17 @@ Installation
remotes::install_github("OHDSI/ResultModelManager")
```

Usage
=====

See articles:
- [Creating migrations](https://ohdsi.github.io/ResultModelManager/articles/CreatingMigrations.html)
- [Example Project](https://ohdsi.github.io/ResultModelManager/articles/ExampleProject.html)
- [Upload functionality](https://ohdsi.github.io/ResultModelManager/articles/UploadFunctionality.html)
- [Connection handler](https://ohdsi.github.io/ResultModelManager/articles/UsingConnectionHandlers.html)
- [Using query namespaces](https://ohdsi.github.io/ResultModelManager/articles/UsingQueryNamespaces.html)


Support
=======
* Developer questions/comments/feedback: <a href="http://forums.ohdsi.org/c/developers">OHDSI Forum</a>
Expand Down
6 changes: 6 additions & 0 deletions docs/404.html

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

10 changes: 8 additions & 2 deletions docs/articles/CreatingMigrations.html

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

12 changes: 9 additions & 3 deletions docs/articles/ExampleProject.html

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

10 changes: 8 additions & 2 deletions docs/articles/PackageDesign.html

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

10 changes: 8 additions & 2 deletions docs/articles/UploadFunctionality.html

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

12 changes: 9 additions & 3 deletions docs/articles/UsingAnExportManager.html

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

10 changes: 8 additions & 2 deletions docs/articles/UsingConnectionHandlers.html

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

14 changes: 10 additions & 4 deletions docs/articles/UsingQueryNamespaces.html

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

6 changes: 6 additions & 0 deletions docs/articles/index.html

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

Loading

0 comments on commit 9bc8512

Please sign in to comment.