diff --git a/Project.toml b/Project.toml index 1bc53ff4..cac18ad2 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "MLJFlux" uuid = "094fc8d1-fd35-5302-93ea-dabda2abf845" authors = ["Anthony D. Blaom ", "Ayush Shridhar "] -version = "0.3.0" +version = "0.3.1" [deps] CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597" diff --git a/src/mlj_model_interface.jl b/src/mlj_model_interface.jl index f3af0774..5ffe903f 100644 --- a/src/mlj_model_interface.jl +++ b/src/mlj_model_interface.jl @@ -59,6 +59,7 @@ function MLJModelInterface.fit(model::MLJFluxModel, build(model, rng, shape) |> move catch ex @error ERR_BUILDER + rethrow() end penalty = Penalty(model) diff --git a/test/mlj_model_interface.jl b/test/mlj_model_interface.jl index 6f07a661..a2e6c8fe 100644 --- a/test/mlj_model_interface.jl +++ b/test/mlj_model_interface.jl @@ -52,3 +52,31 @@ end @test length(losses) == 10 end +mutable struct LisasBuilder + n1::Int +end + +@testset "builder errors and issue #237" begin + # create a builder with an intentional flaw; + # `Chains` is undefined - it should be `Chain` + function MLJFlux.build(builder::LisasBuilder, rng, nin, nout) + return Flux.Chains( + Flux.Dense(nin, builder.n1), + Flux.Dense(builder.n1, nout) + ) + end + + model = NeuralNetworkRegressor( + epochs = 2, + batch_size = 32, + builder = LisasBuilder(10), + ) + + X, y = @load_boston + @test_logs( + (:error, MLJFlux.ERR_BUILDER), + @test_throws UndefVarError(:Chains) MLJBase.fit(model, 0, X, y) + ) +end + +true