Invoke user defined package functions on distributed workers

Greetings! I created a package ModelUtils and hope to run it in multiple workers. In this package, a function called linear_regression being exported. The module is under src folder and has the following content

module ModelUtils
export linear_regression
include("linear_models.jl")
end

In main.jl file where I would invoke the linear_models

using Distributed
addprocs(exeflags="--project") # the --project flags is essentially running ] activate .
@everywhere using ModelUtils

fn_arg = rand(Float64, (5,2))

@sync for i in 1:nworkers()
    @spawnat i linear_regression(fn_arg)
end

I would get the following error

UndefVarError: linear_regression not defined

What is the cause for this error? Thank you.

Is that the full error message? if the function indeed is not defined on other worker processes, the error should be

ERROR: On worker 2:
UndefVarError: linear_regression not defined

If you don’t see the On worker 2 check for typos in your function name and what you are exporting from the modula.

Thx for the answer. I checked for typos, and it’s not caused by typo.
Adding @everywhere in the linear_models.jl and include using include("src\\linear_models.jl") in main.jl would work. I haven’t got export work smoothly. Some of the complications may involve linear_regression has pyimport modules from python. I am good with include for now.