Skip to content

read_model_info_table() only once #910

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

Merged
merged 2 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions R/aaa_models.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,8 @@ pred_types <-

# ------------------------------------------------------------------------------

read_model_info_table <- function() {
model_info_table <-
utils::read.delim(system.file("models.tsv", package = "parsnip"))

model_info_table
}
model_info_table <-
utils::read.delim(system.file("models.tsv", package = "parsnip"))

# ------------------------------------------------------------------------------

Expand Down Expand Up @@ -228,7 +224,7 @@ check_spec_mode_engine_val <- function(cls, eng, mode, call = caller_env()) {
# are contained in a different package
model_info_parsnip_only <-
dplyr::inner_join(
read_model_info_table() %>% dplyr::filter(is.na(pkg)) %>% dplyr::select(-pkg),
model_info_table %>% dplyr::filter(is.na(pkg)) %>% dplyr::select(-pkg),
model_info %>% dplyr::mutate(model = cls),
by = c("model", "engine", "mode")
)
Expand Down
6 changes: 3 additions & 3 deletions R/misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ mode_filter_condition <- function(mode, user_specified_mode) {
#' * the `model_info_table` of "pre-registered" model specifications
#'
#' to determine whether a model is well-specified. See
#' `parsnip:::read_model_info_table()` for this table.
#' `parsnip:::model_info_table` for this table.
#'
#' `spec_is_loaded()` checks only against the current parsnip model environment.
#'
Expand Down Expand Up @@ -99,7 +99,7 @@ spec_is_possible <- function(spec,

all_model_info <-
dplyr::full_join(
read_model_info_table(),
model_info_table,
rlang::env_get(get_model_env(), cls) %>% dplyr::mutate(model = cls),
by = c("model", "engine", "mode")
)
Expand Down Expand Up @@ -183,7 +183,7 @@ prompt_missing_implementation <- function(spec,
}

all <-
read_model_info_table() %>%
model_info_table %>%
dplyr::filter(model == cls, !!mode_condition, !!engine_condition, !is.na(pkg)) %>%
dplyr::select(-model)

Expand Down
2 changes: 1 addition & 1 deletion man/extension-check-helpers.Rd

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