Skip to content

find_tune_id() errors if expression is namespaced #745

@EmilHvitfeldt

Description

@EmilHvitfeldt

This bug was extracted from the following this SO question https://stackoverflow.com/questions/72482220/r-tidymodels-error-when-using-a-glm-model-within-a-workflow-set. Short-term fix would be to not namespace arguments or create object outside and pass that in. Long term, this should be fixed since disallowing name-spacing seems bad

library(parsnip)

ggg <- stats::gaussian("log")

glm_model_ns <- linear_reg() %>%
   set_engine("glm", family = stats::gaussian("log"))

tune::tune_args(glm_model_ns)
#> Error in if (rlang::call_name(x) == "tune") {: argument is of length zero

ggg <- stats::gaussian("log")

glm_model_ns2 <- linear_reg() %>%
   set_engine("glm", family = ggg)

tune::tune_args(glm_model_ns2)
#> # A tibble: 0 × 6
#> # … with 6 variables: name <chr>, tunable <lgl>, id <chr>, source <chr>,
#> #   component <chr>, component_id <chr>

glm_model <- linear_reg() %>%
   set_engine("glm", family = gaussian("log"))

tune::tune_args(glm_model)
#> # A tibble: 0 × 6
#> # … with 6 variables: name <chr>, tunable <lgl>, id <chr>, source <chr>,
#> #   component <chr>, component_id <chr>

glm_model$eng_args
#> <list_of<quosure>>
#> 
#> $family
#> <quosure>
#> expr: ^gaussian("log")
#> env:  0x127046da0

parsnip:::find_tune_id(glm_model$eng_args[[1]])
#> [1] NA

glm_model_ns$eng_args
#> <list_of<quosure>>
#> 
#> $family
#> <quosure>
#> expr: ^stats::gaussian("log")
#> env:  0x1137460c0

parsnip:::find_tune_id(glm_model_ns$eng_args[[1]])
#> Error in if (rlang::call_name(x) == "tune") {: argument is of length zero

Created on 2022-06-03 by the reprex package (v2.0.1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions