Skip to content

Commit f6432bc

Browse files
authored
Merge pull request #152 from JuliaAI/dev
For a 1.4.4 release
2 parents fe70185 + f18bd47 commit f6432bc

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "MLJModelInterface"
22
uuid = "e80e1ace-859a-464e-9ed9-23947d8ae3ea"
33
authors = ["Thibaut Lienart and Anthony Blaom"]
4-
version = "1.4.3"
4+
version = "1.4.4"
55

66
[deps]
77
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

src/metadata_utils.jl

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ function metadata_pkg(
4444
package_license=license,
4545
)
4646
ex = quote
47-
MLJModelInterface.package_name(::Type{<:$T}) = $package_name
48-
MLJModelInterface.package_uuid(::Type{<:$T}) = $package_uuid
49-
MLJModelInterface.package_url(::Type{<:$T}) = $package_url
50-
MLJModelInterface.is_pure_julia(::Type{<:$T}) = $is_pure_julia
51-
MLJModelInterface.package_license(::Type{<:$T}) = $package_license
52-
MLJModelInterface.is_wrapper(::Type{<:$T}) = $is_wrapper
47+
$MLJModelInterface.package_name(::Type{<:$T}) = $package_name
48+
$MLJModelInterface.package_uuid(::Type{<:$T}) = $package_uuid
49+
$MLJModelInterface.package_url(::Type{<:$T}) = $package_url
50+
$MLJModelInterface.is_pure_julia(::Type{<:$T}) = $is_pure_julia
51+
$MLJModelInterface.package_license(::Type{<:$T}) = $package_license
52+
$MLJModelInterface.is_wrapper(::Type{<:$T}) = $is_wrapper
5353
end
5454
parentmodule(T).eval(ex)
5555
end
@@ -59,14 +59,20 @@ end
5959
function _extend!(program::Expr, trait::Symbol, value, T)
6060
if value !== nothing
6161
push!(program.args, quote
62-
MLJModelInterface.$trait(::Type{<:$T}) = $value
62+
$MLJModelInterface.$trait(::Type{<:$T}) = $value
6363
end)
6464
return nothing
6565
end
6666
end
6767

68+
const DEPWARN_DOCSTRING =
69+
"`metadata_model` should not be called with the keyword argument "*
70+
"`descr` or `docstring`. Implementers of the MLJ model interface "*
71+
"should instead create an MLJ-compliant docstring in the usual way. "*
72+
"See https://alan-turing-institute.github.io/MLJ.jl/dev/adding_models_for_general_use/#Document-strings for details. "
73+
6874
"""
69-
metadata_model(`T`; args...)
75+
metadata_model(T; args...)
7076
7177
Helper function to write the metadata for a model `T`.
7278
@@ -78,6 +84,7 @@ Helper function to write the metadata for a model `T`.
7884
* `supports_weights=false`: whether the model supports sample weights
7985
* `supports_class_weights=false`: whether the model supports class weights
8086
* `load_path="unknown"`: where the model is (usually `PackageName.ModelName`)
87+
* `human_name=nothing`: human name of the model
8188
8289
## Example
8390
@@ -110,6 +117,7 @@ function metadata_model(
110117
load_path::Union{Nothing,String}=path,
111118
human_name::Union{Nothing,String}=nothing
112119
)
120+
docstring === nothing || Base.depwarn(DEPWARN_DOCSTRING, :metadata_model)
113121

114122
program = quote end
115123

test/data_utils.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,3 +318,14 @@ end
318318
@test_throws M.InterfaceError UnivariateFinite(Dict(2=>3, 3=>4))
319319
@test_throws M.InterfaceError UnivariateFinite(randn(2), randn(2))
320320
end
321+
322+
@testset "not assuming MLJModelInterface symbol at user-side" begin
323+
eval(:(module UserSide
324+
import MLJModelInterface: metadata_model, metadata_pkg
325+
struct A end
326+
descr = "something"
327+
# Smoke tests.
328+
metadata_model(A; descr=descr)
329+
metadata_pkg(A)
330+
end))
331+
end

0 commit comments

Comments
 (0)