From edff6fe04b482332b5a741236eb45b6112305359 Mon Sep 17 00:00:00 2001 From: Matthew Hamilton Date: Tue, 22 Feb 2022 08:00:45 +1100 Subject: [PATCH] edits to work with new mdl_ingredients_ls --- .github/workflows/R-CMD-check.yaml | 8 -------- .github/workflows/pkgdown.yaml | 2 +- R/fn_get.R | 15 ++++++++++----- R/fn_make.R | 4 ++++ data-raw/fns/get.R | 29 ++++++++++++++++++----------- data-raw/fns/make.R | 16 +++++++++++----- data/mdls_lup.rda | Bin 555 -> 543 bytes 7 files changed, 44 insertions(+), 30 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index bbbc7e0b..30ec185a 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -73,7 +73,6 @@ jobs: do eval sudo $cmd done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "20.04"), sep = "\n")') - - name: Install system dependencies if: runner.os == 'MacOS' && !matrix.config.autobrew run: brew install harfbuzz fribidi @@ -88,13 +87,6 @@ jobs: remotes::install_cran("rcmdcheck") shell: Rscript {0} - - name: Address conditional specific install fail - if: runner.os == 'Linux' - run: | - Rscript -e "remove.packages(c('igraph'))" - conda install -c r r-igraph - Rscript -e "install.packages('remotes')" -e "options(timeout=600)" -e "remotes::install_github('ready4-dev/specific')" - - name: Session info run: | options(width = 100) diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index bf6668ac..63cbb18a 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -11,7 +11,7 @@ name: pkgdown jobs: pkgdown: - runs-on: macOS-latest + runs-on: ubuntu-latest env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: diff --git a/R/fn_get.R b/R/fn_get.R index ca91814e..81b0107e 100644 --- a/R/fn_get.R +++ b/R/fn_get.R @@ -232,7 +232,7 @@ get_mdl_smrys <- function (ingredients_ls, mdl_nms_chr = NULL) #' @export #' @importFrom purrr map2_dfr map_chr map_lgl #' @importFrom ready4 get_from_lup_obj -#' @importFrom dplyr filter mutate +#' @importFrom dplyr filter mutate case_when #' @keywords internal get_mdls_lup <- function (ttu_dv_dss_tb = NULL, mdl_predrs_in_ds_chr = NULL, utility_type_chr = NULL, ttu_dv_nms_chr = "TTU", server_1L_chr = "dataverse.harvard.edu", @@ -263,6 +263,8 @@ get_mdls_lup <- function (ttu_dv_dss_tb = NULL, mdl_predrs_in_ds_chr = NULL, character(0)) })) %>% dplyr::mutate(ds_url = urls_chr) }) + mdls_lup <- mdls_lup %>% dplyr::mutate(source_chr = dplyr::case_when(is.na(source_chr) ~ + "Primary Analysis", T ~ source_chr)) } else { mdls_lup <- NULL @@ -280,8 +282,8 @@ get_mdls_lup <- function (ttu_dv_dss_tb = NULL, mdl_predrs_in_ds_chr = NULL, #' @return Model (a model) #' @rdname get_model #' @export -#' @importFrom specific get_table_predn_mdl #' @importFrom ready4 get_from_lup_obj +#' @importFrom specific get_table_predn_mdl #' @keywords internal get_model <- function (mdls_lup, mdl_nm_1L_chr, make_from_tbl_1L_lgl = T, mdl_meta_data_ls = NULL, server_1L_chr = "dataverse.harvard.edu", @@ -292,10 +294,13 @@ get_model <- function (mdls_lup, mdl_nm_1L_chr, make_from_tbl_1L_lgl = T, mdl_meta_data_ls <- get_mdl_metadata(mdls_lup, mdl_nm_1L_chr = mdl_nm_1L_chr, server_1L_chr = server_1L_chr, key_1L_chr = key_1L_chr) } + analysis_1L_chr <- ready4::get_from_lup_obj(mdls_lup, + match_value_xx = mdl_nm_1L_chr, match_var_nm_1L_chr = "mdl_nms_chr", + target_var_nm_1L_chr = "source_chr", evaluate_1L_lgl = F) + if (analysis_1L_chr == "Primary Analysis") + analysis_1L_chr <- NULL model_mdl <- specific::get_table_predn_mdl(mdl_nm_1L_chr, - ingredients_ls = mdl_meta_data_ls, analysis_1L_chr = ready4::get_from_lup_obj(mdls_lup, - match_value_xx = mdl_nm_1L_chr, match_var_nm_1L_chr = "mdl_nms_chr", - target_var_nm_1L_chr = "source_chr", evaluate_1L_lgl = F)) + ingredients_ls = mdl_meta_data_ls, analysis_1L_chr = analysis_1L_chr) } else { model_mdl <- get_mdl_from_dv(mdl_nm_1L_chr, dv_ds_nm_1L_chr = get_mdl_ds_url(mdls_lup, diff --git a/R/fn_make.R b/R/fn_make.R index 3610a287..d5b05be2 100644 --- a/R/fn_make.R +++ b/R/fn_make.R @@ -356,6 +356,10 @@ make_predn_metadata_ls <- function (data_tb, cmprsn_groups_chr = NULL, cmprsn_va data_tb <- specific::rename_from_nmd_vec(data_tb, nmd_vec_chr = predr_vars_nms_chr, vec_nms_as_new_1L_lgl = T) } + if (is.null(mdl_meta_data_ls)) { + mdl_meta_data_ls <- get_mdl_metadata(mdls_lup, mdl_nm_1L_chr = mdl_nm_1L_chr, + key_1L_chr = key_1L_chr, server_1L_chr = server_1L_chr) + } predictors_lup <- get_predictors_lup(mdl_meta_data_ls = mdl_meta_data_ls, mdls_lup = mdls_lup, mdl_nm_1L_chr = mdl_nm_1L_chr, outp_is_abbrs_tb = F, server_1L_chr = server_1L_chr, key_1L_chr = key_1L_chr) diff --git a/data-raw/fns/get.R b/data-raw/fns/get.R index 81372400..de592e33 100644 --- a/data-raw/fns/get.R +++ b/data-raw/fns/get.R @@ -71,11 +71,12 @@ get_mdl_ctlg_url <- function(mdls_lup, all_lbls_chr <- purrr::map_chr(ds_ls,~.x$label) include_lgl <- all_lbls_chr %>% purrr::map_lgl(~startsWith(.x,"AAA_TTU_MDL_CTG")) all_descs_chr <- purrr::map_chr(ds_ls,~.x$description) - include_lgl <- include_lgl & (all_descs_chr %>% purrr::map_lgl(~stringr::str_detect(.x, - ready4::get_from_lup_obj(mdls_lup, - match_value_xx = mdl_nm_1L_chr, - match_var_nm_1L_chr = "mdl_nms_chr", - target_var_nm_1L_chr = "source_chr", + include_lgl <- include_lgl & (all_descs_chr %>% + purrr::map_lgl(~stringr::str_detect(.x, + ready4::get_from_lup_obj(mdls_lup, + match_value_xx = mdl_nm_1L_chr, + match_var_nm_1L_chr = "mdl_nms_chr", + target_var_nm_1L_chr = "source_chr", evaluate_1L_lgl = F)))) idx_1L_int <- which(include_lgl) if(identical(idx_1L_int,integer(0))){ @@ -147,6 +148,9 @@ get_mdls_lup <- function(ttu_dv_dss_tb = NULL, character(0))})) %>% dplyr::mutate(ds_url = urls_chr) }) + mdls_lup <- mdls_lup %>% + dplyr::mutate(source_chr = dplyr::case_when(is.na(source_chr) ~ "Primary Analysis", + T ~ source_chr)) }else{ mdls_lup <- NULL } @@ -199,13 +203,16 @@ get_model <- function(mdls_lup, server_1L_chr = server_1L_chr, key_1L_chr = key_1L_chr) } + analysis_1L_chr <- ready4::get_from_lup_obj(mdls_lup, + match_value_xx = mdl_nm_1L_chr, + match_var_nm_1L_chr = "mdl_nms_chr", + target_var_nm_1L_chr = "source_chr", + evaluate_1L_lgl = F) + if(analysis_1L_chr == "Primary Analysis") + analysis_1L_chr <- NULL model_mdl <- specific::get_table_predn_mdl(mdl_nm_1L_chr, - ingredients_ls = mdl_meta_data_ls, - analysis_1L_chr = ready4::get_from_lup_obj(mdls_lup, - match_value_xx = mdl_nm_1L_chr, - match_var_nm_1L_chr = "mdl_nms_chr", - target_var_nm_1L_chr = "source_chr", - evaluate_1L_lgl = F)) + ingredients_ls = mdl_meta_data_ls, + analysis_1L_chr = analysis_1L_chr) }else{ model_mdl <- get_mdl_from_dv(mdl_nm_1L_chr, dv_ds_nm_1L_chr = get_mdl_ds_url(mdls_lup, diff --git a/data-raw/fns/make.R b/data-raw/fns/make.R index de2321a5..cef21bce 100644 --- a/data-raw/fns/make.R +++ b/data-raw/fns/make.R @@ -274,11 +274,17 @@ make_predn_metadata_ls <- function(data_tb, utl_var_nm_1L_chr = "AQoL6D_HU", server_1L_chr = "dataverse.harvard.edu", key_1L_chr = NULL){ - if(!is.null(predr_vars_nms_chr)){ - data_tb <- specific::rename_from_nmd_vec(data_tb, - nmd_vec_chr = predr_vars_nms_chr, - vec_nms_as_new_1L_lgl = T) - } + if(!is.null(predr_vars_nms_chr)){ + data_tb <- specific::rename_from_nmd_vec(data_tb, + nmd_vec_chr = predr_vars_nms_chr, + vec_nms_as_new_1L_lgl = T) + } + if(is.null(mdl_meta_data_ls)){ + mdl_meta_data_ls <- get_mdl_metadata(mdls_lup, + mdl_nm_1L_chr = mdl_nm_1L_chr, + key_1L_chr = key_1L_chr, + server_1L_chr = server_1L_chr) + } predictors_lup <- get_predictors_lup(mdl_meta_data_ls = mdl_meta_data_ls, mdls_lup = mdls_lup, mdl_nm_1L_chr = mdl_nm_1L_chr, diff --git a/data/mdls_lup.rda b/data/mdls_lup.rda index 0d208d83b57f9e8c94c02944e641fcc2a7983698..de1343f13fc76e5ac503ebada7a018ba9f9ce418 100644 GIT binary patch delta 529 zcmV+s0`C2*1fK*ELRx4!F+o`-Q&}7G+9v=7Rgn=Ie_g2nR)ng9ARnq4G#UT^28JL2 z0Av!H5}v3UG-!H2000000iXknnKaW0k&rMW6GjNa4H{qoK&d4)N2ZxH#EjEWGynrY z^%zVw15G_maz;{Ir7>9yM%}FgVu;+mXeV<7j5`cpOmpfZYg)SUku-3D6i%54slr9v z5wB4ue;idgb^o^HNA93@_4_Y%P)RnZMt$`hU>6yh&sr1^ff-q8UL=tOJl;f7%1gy0 zEe2;O1Y-*O+h%KbEoUYrAxd!q$K<-glIo#!CxU`fLMTX4P@7alNzL)JkZsZoEn<_W zUZ8Ap4bpTGnUI->5j)8_$w@m2HxGvnpO*nQe{!lxNhczA2H3l+Ci7{g0_hZNO z4WOEc$W8-?>&La^37jT?Y=bZ^2Jm4Al``>W&B@7plK?pJRFb5b(UQh`Z0z%qr@l`c zp=6Y@oT=H-moGMq1m6boP3(x?raX7#wXG)TEWK4&#-QfA=c7)WE~`?hRaCXDby}s> zcWQys8iBA20+UfaUF!1=JWq+u_t@e;U=GxLfhtMK3or%omhQQAb!x~kT*HU?e8xJR zh3q!3xcKn(UZ07HTm)UvBcKwNd$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