Skip to content

Fix model fitting when modeltime is not attached - #267

Open
pedroborges-melo wants to merge 1 commit into
business-science:masterfrom
pedroborges-melo:fix/namespace-fit-registrations
Open

pedroborges-melo wants to merge 1 commit into
business-science:masterfrom
pedroborges-melo:fix/namespace-fit-registrations

Conversation

@pedroborges-melo

@pedroborges-melo pedroborges-melo commented Aug 29, 2026 •

Copy link
Copy Markdown

Hey @mdancho84, I came across this while using modeltime from another package.

In package code, dependencies are normally declared in DESCRIPTION and NAMESPACE, and their functions are called with modeltime::.... Calling library(modeltime) inside a package is generally avoided because it changes the user's search path.

With that setup, creating a model specification works normally:

spec <- modeltime::prophet_reg() |>
  parsnip::set_engine("prophet")

However, fitting the model can fail with:

could not find function "prophet_fit_impl"

Calling library(modeltime) makes the error disappear, but only because it places the fitting functions on the search path. The functions are currently registered without their package name, so parsnip may not be able to resolve them when modeltime is loaded as a namespace but not attached.

This PR adds pkg = "modeltime" to the affected fit registrations. It also adds a regression test covering every active modeltime fit bridge and checks that the registered functions are exported.

This allows downstream packages to use modeltime through the usual package dependency mechanism, without attaching it or importing the fitting functions individually.

Testing

The focused registration test passes all 41 assertions and covers the 20 active model and engine registrations.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant