Skip to content

lazy activation of models not working from within packages #22

Closed
@rssdev10

Description

@rssdev10

I'm trying to make a module with MLJModel:

module Abc

import XGBoost: dump_model, save, Booster

using MLJ
using MLJBase
import MLJModels

using MLJModels.XGBoost_

function __init__()
    @info "Abc"
end

end

but having an error ERROR: LoadError: UndefVarError: XGBoost_ not defined.

Looks like there is an issue with lazy activation in

@require XGBoost = "009559a3-9522-5dbb-924b-0b6ed2b22bb9" include("XGBoost.jl")

One workaround I found is

module Abc

using XGBoost
#import XGBoost: dump_model, save, Booster

using MLJ
using MLJBase
import MLJModels

include(joinpath(MLJModels.srcdir, "XGBoost.jl"))
#using MLJModels.XGBoost_

function __init__()
    @info "Abc"
end

end

Also I added debug output into function __init__ of the module MLJModels and I see that this method is called twice. I have something like:

[ Info: Precompiling Abc [top-level]
[ Info: MLJModels!!!
[ Info: MLJModels!!!
[ Info: Abc

May be it is related to a chain of __init__ methods.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions