-
Notifications
You must be signed in to change notification settings - Fork 2
Preprocess heavy computations before run_app()
#245
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
Open
aclark02-arcus
wants to merge
19
commits into
dev
Choose a base branch
from
ac-223
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
3503d12
Increment version number to 0.3.0.9001
aclark02-arcus 56c7402
export 'get_available_data()' & update docs
aclark02-arcus 46cdfd1
add news
aclark02-arcus 7daef86
export check_appdata() and get_meta_vars() & update docs
aclark02-arcus aa1565b
setup clinsight to use other objects besides
aclark02-arcus 95f9f11
move a comment
aclark02-arcus bf173dd
remove unneccessary comments
aclark02-arcus 776727b
Merge branch 'dev' into ac-223
aclark02-arcus 7caa754
Merge branch 'ac-223' of https://github.com/openpharma/clinsight into…
aclark02-arcus a8fbcb1
extract creation of timeline_data outside of the app & remove app_tab…
aclark02-arcus b5d631f
removed duplicate str(metadata)
aclark02-arcus cfe7130
fixed creation of 'cs_available_data'
aclark02-arcus 2ee494d
Update R/run_app.R to check for character timeline_data object before…
aclark02-arcus 7f84adc
fix typo in Rd
aclark02-arcus e4be379
Merge branch 'ac-223' of https://github.com/openpharma/clinsight into…
aclark02-arcus cd8b547
Update R/fct_test_clinsight.R to use 'meta_data' instead of 'meta'
aclark02-arcus d0403fd
whoops, fix a couple of issues copilot caught
aclark02-arcus 212a90b
Merge branch 'ac-223' of https://github.com/openpharma/clinsight into…
aclark02-arcus 72fe125
Merge branch 'dev' into ac-223
aclark02-arcus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,17 +32,67 @@ test_clinsight <- function( | |
| meta_data_path <- get_golem_config("meta_data", config = clinsight_config) | ||
| if ( | ||
| clinsight_config %in% c("default", "dev") | | ||
| !is.character(study_data_path) | !is.character(meta_data_path) | ||
| !is.character(study_data_path) | | ||
| !is.character(meta_data_path) #| | ||
| ){ | ||
| stop("The 'default' or 'dev' config cannot be used with custom data, ", | ||
| "and study_data and meta_data in the config file ", | ||
| "should be character vectors.") | ||
| "and meta_data, app_data, app_vars, timeline_data, & available_data ", | ||
| "in the config file should be character vectors.") | ||
| } | ||
| # Build a version of `app_data` & app_vars | ||
| app_data <- get_appdata(data = clinsight_data, meta = meta_data) | ||
| app_vars <- get_meta_vars(data = app_data, meta = meta_data) | ||
|
|
||
| # Build a 'app_tables' | ||
| # app_tables <- lapply( | ||
| # setNames(names(app_data), names(app_data)), \(x){ | ||
| # create_table(app_data[[x]], expected_columns = names(app_vars$items[[x]])) | ||
| # }) | ||
|
|
||
| # Build a 'available_data' | ||
| available_data <- get_available_data( | ||
| data = app_data, | ||
| # tables = app_tables, # outdated arg | ||
| # all_forms = app_vars$all_forms, # outdated arg | ||
| form_repeat_name = with( | ||
| meta_data[["table_names"]], | ||
| table_name[raw_name == "form_repeat"] | ||
| ) |> | ||
| tryCatch(error = \(e) "N") | ||
| ) | ||
|
|
||
| # For timeline data | ||
| timeline_data <- get_timeline_data( | ||
| app_data, | ||
| available_data = available_data, | ||
| treatment_label = meta_data$settings$treatment_label %||% "\U1F48A T\U2093" | ||
| ) | ||
|
|
||
| temp_folder <- tempfile(tmpdir = tempdir()) | ||
| dir.create(temp_folder, recursive = TRUE) | ||
| saveRDS(clinsight_data, file.path(temp_folder, basename(study_data_path))) | ||
| saveRDS(meta_data, file.path(temp_folder, basename(meta_data_path))) | ||
| # saveRDS(clinsight_data, file.path(temp_folder, basename(study_data_path))) | ||
| # saveRDS(meta_data, file.path(temp_folder, basename(meta_data_path))) | ||
| db_path <- file.path(temp_folder, "user_db.sqlite") | ||
| if(file.exists(db_path)) file.remove(db_path) | ||
| db_create(get_review_data(clinsight_data), | ||
| db_path = db_path | ||
| ) | ||
| save_objs <- c( | ||
| "clinsight_data", | ||
| "meta_data", | ||
| "app_data", | ||
| "app_vars", | ||
| # "app_tables", | ||
| "timeline_data", | ||
| "available_data") | ||
| purrr::walk(save_objs, function(x){ | ||
| rds_file <- file.path(temp_folder, paste0(x, ".rds")) | ||
| saveRDS(get(x), rds_file) | ||
| if(inherits(get(x), "data.frame")) { | ||
| pq_file <- file.path(temp_folder, paste0(x, ".parquet")) | ||
| arrow::write_parquet(get(x), pq_file) | ||
| } | ||
| }) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think adding parquet files here will make it significantly slower to test clinsight with this function because it is fairly slow to write parquet files. Can this be changed/removed here? |
||
| old_config <- Sys.getenv("GOLEM_CONFIG_ACTIVE") | ||
| Sys.setenv("GOLEM_CONFIG_ACTIVE" = clinsight_config) | ||
| run_app( | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep in mind that
purrris currently only insuggestsin the description. We should either use base R or move the package toImports.