-
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
base: dev
Are you sure you want to change the base?
Changes from 7 commits
3503d12
56c7402
46cdfd1
7daef86
aa1565b
95f9f11
bf173dd
776727b
7caa754
a8fbcb1
b5d631f
cfe7130
2ee494d
7f84adc
e4be379
cd8b547
d0403fd
212a90b
72fe125
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,17 +32,59 @@ 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, app_tables, & 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, | ||
| all_forms = app_vars$all_forms, | ||
| form_repeat_name = with( | ||
| meta[["table_names"]], | ||
|
aclark02-arcus marked this conversation as resolved.
Outdated
|
||
| table_name[raw_name == "form_repeat"] | ||
| ) |> | ||
| tryCatch(error = \(e) "N") | ||
| ) | ||
|
|
||
| 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", | ||
| "available_data") | ||
| purrr::walk(save_objs, function(x){ | ||
|
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. Keep in mind that |
||
| 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( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.