Skip to content

Commit c35207e

Browse files
authored
Merge pull request #590 from JuliaAI/rm-registry-tools
Remove MLJ Model Registry tools
2 parents 38cc0c9 + 53892ae commit c35207e

25 files changed

+6944
-7773
lines changed

.github/workflows/check_registry.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ jobs:
4141
${{ runner.os }}-
4242
- uses: julia-actions/julia-buildpkg@v1
4343
- uses: julia-actions/julia-runtest@v1
44+
env:
45+
# This environment variable enables the integration tests:
46+
MLJ_TEST_INTEGRATION: '1'
4447
- uses: julia-actions/julia-processcoverage@v1
4548
- uses: codecov/codecov-action@v4
4649
with:

Project.toml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,37 @@ Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
3131
CategoricalArrays = "0.9, 0.10"
3232
CategoricalDistributions = "0.1"
3333
Combinatorics = "1.0"
34-
Dates = "<0.0.1, 1"
34+
Dates = "1"
3535
Distances = "0.9,0.10"
36+
Distributed = "1"
3637
Distributions = "0.25"
37-
InteractiveUtils = "<0.0.1, 1"
38-
LinearAlgebra = "<0.0.1, 1"
39-
Markdown = "<0.0.1, 1"
38+
InteractiveUtils = "1"
39+
LinearAlgebra = "1"
4040
MLJModelInterface = "1.10"
41+
Markdown = "1"
4142
OrderedCollections = "1.1"
4243
Parameters = "0.12"
43-
Pkg = "<0.0.1, 1"
44+
Pkg = "1"
4445
PrettyPrinting = "0.3, 0.4"
45-
Random = "<0.0.1, 1"
46+
Random = "1"
4647
RelocatableFolders = "0.3, 1"
4748
ScientificTypes = "3"
4849
StatisticalTraits = "3"
49-
Statistics = "<0.0.1, 1"
50+
Statistics = "1"
5051
StatsBase = "0.32,0.33, 0.34"
52+
Suppressor = "0.2.8"
5153
Tables = "0.2,1.0"
52-
julia = "1.6"
54+
julia = "1.10"
5355

5456
[extras]
57+
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
5558
MLJBase = "a7f614a8-145f-11e9-1d2a-a57a1082229d"
5659
MLJDecisionTreeInterface = "c6f25543-311c-4c74-83dc-3ea6d1015661"
5760
MLJMultivariateStatsInterface = "1b6a4a23-ba22-4f51-9698-8599985d3728"
5861
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
5962
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
63+
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
6064
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
6165

6266
[targets]
63-
test = ["MLJBase", "MLJDecisionTreeInterface", "MLJMultivariateStatsInterface", "Pkg", "StableRNGs", "Test"]
67+
test = ["Distributed", "MLJBase", "MLJDecisionTreeInterface", "MLJMultivariateStatsInterface", "Pkg", "StableRNGs", "Suppressor", "Test"]

src/GaussianProcesses.jl

Lines changed: 0 additions & 89 deletions
This file was deleted.

src/MLJModels.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export UnivariateDiscretizer,
4848
OneHotEncoder, ContinuousEncoder, FillImputer, UnivariateFillImputer,
4949
UnivariateTimeTypeToContinuous, InteractionTransformer
5050

51-
const srcdir = dirname(@__FILE__) # the directory containing this file
5251
const MMI = MLJModelInterface
5352

5453
if VERSION < v"1.3"
@@ -64,28 +63,29 @@ include("builtins/Constant.jl")
6463
include("builtins/Transformers.jl")
6564
include("builtins/ThresholdPredictors.jl")
6665

67-
Handle = NamedTuple{(:name, :pkg), Tuple{String,String}}
68-
(::Type{Handle})(name,string) = NamedTuple{(:name, :pkg)}((name, string))
66+
# declare paths to the metadata and associated project file:
67+
const REGISTRY_PROJECT = @path joinpath(@__DIR__, "registry", "Project.toml")
68+
const REGISTRY_METADATA = @path joinpath(@__DIR__, "registry", "Metadata.toml")
69+
Base.include_dependency(REGISTRY_PROJECT)
70+
Base.include_dependency(REGISTRY_METADATA)
6971

7072
# load utilities for reading model metadata from file:
7173
include("metadata.jl")
7274

73-
# read in the metadata:
74-
metadata_file = joinpath(srcdir, "registry", "Metadata.toml")
75-
Base.include_dependency(metadata_file)
76-
const INFO_GIVEN_HANDLE = info_given_handle(metadata_file)
75+
# read in metadata:
76+
const INFO_GIVEN_HANDLE = info_given_handle(REGISTRY_METADATA)
7777
const PKGS_GIVEN_NAME = pkgs_given_name(INFO_GIVEN_HANDLE)
7878
const AMBIGUOUS_NAMES = ambiguous_names(INFO_GIVEN_HANDLE)
7979
const NAMES = model_names(INFO_GIVEN_HANDLE)
8080
const MODEL_TRAITS_IN_REGISTRY = model_traits_in_registry(INFO_GIVEN_HANDLE)
8181

82-
# model search and registry code:
82+
# include tools to search the model registry:
8383
include("model_search.jl")
84+
85+
# include tools to load model code:
8486
include("loading.jl")
85-
include("registry/src/Registry.jl")
86-
using .Registry
8787

88-
# finalize:
89-
include("init.jl")
88+
# include tool for cloning the Model Registry project file:
89+
include("registry_project.jl")
9090

9191
end # module

src/init.jl

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/metadata.jl

Lines changed: 25 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,5 @@
1-
## UTILITIES FOR ENCODING AND DECODING MODEL METADATA
2-
# (for serializing/deserializing into TOML format)
3-
4-
# fallback encoding:
5-
function encode_dic(s)
6-
prestring = string("`", s, "`")
7-
# hack for objects with gensyms in their string representation:
8-
str = replace(prestring, '#'=>'_')
9-
return str
10-
end
11-
12-
encode_dic(s::AbstractString) = string(s)
13-
encode_dic(s::Symbol) = string(":", s)
14-
encode_dic(s::Nothing) = "`nothing`"
15-
encode_dic(v::AbstractVector) = encode_dic.(v)
16-
function encode_dic(d::AbstractDict)
17-
ret = LittleDict{}()
18-
for (k, v) in d
19-
ret[encode_dic(k)] = encode_dic(v)
20-
end
21-
return ret
22-
end
1+
# # DECODING MODEL METADATA
2+
# (deserializing TOML dictionary)
233

244
function decode_dic(s::String)
255
if !isempty(s)
@@ -51,34 +31,11 @@ function decode_dic(d::AbstractDict)
5131
return ret
5232
end
5333

54-
# the inverse of a multivalued dictionary is a multivalued
55-
# dictionary:
56-
function inverse(d::LittleDict{S,Set{T}}) where {S,T}
57-
dinv = LittleDict{T,Set{S}}()
58-
for key in keys(d)
59-
for val in d[key]
60-
if val in keys(dinv)
61-
push!(dinv[val], key)
62-
else
63-
dinv[val] = Set([key,])
64-
end
65-
end
66-
end
67-
return dinv
68-
end
69-
function inverse(d::Dict{S,Set{T}}) where {S,T}
70-
dinv = Dict{T,Set{S}}()
71-
for key in keys(d)
72-
for val in d[key]
73-
if val in keys(dinv)
74-
push!(dinv[val], key)
75-
else
76-
dinv[val] = Set([key,])
77-
end
78-
end
79-
end
80-
return dinv
81-
end
34+
35+
# # MODEL HANDLES
36+
37+
Handle = NamedTuple{(:name, :pkg), Tuple{String,String}}
38+
(::Type{Handle})(name,string) = NamedTuple{(:name, :pkg)}((name, string))
8239

8340
function Base.isless(h1::Handle, h2::Handle)
8441
if isless(h1.name, h2.name)
@@ -90,30 +47,39 @@ function Base.isless(h1::Handle, h2::Handle)
9047
end
9148
end
9249

50+
function (::Type{Handle})(name::String)
51+
if name in AMBIGUOUS_NAMES
52+
return Handle(name, missing)
53+
else
54+
return Handle(name, first(PKGS_GIVEN_NAME[name]))
55+
end
56+
end
57+
9358

94-
## FUNCTIONS TO BUILD GLOBAL METADATA CONSTANTS IN MLJMODELS
95-
## INITIALIZATION
59+
# # FUNCTIONS TO BUILD GLOBAL METADATA CONSTANTS
9660

9761
# to define INFO_GIVEN_HANDLE
9862
function info_given_handle(metadata_file)
9963
metadata = LittleDict(TOML.parsefile(metadata_file))
100-
metadata_given_pkg = decode_dic(metadata)
64+
metadata_given_api_pkg = decode_dic(metadata)
10165

10266
# build info_given_handle dictionary:
10367
ret = Dict{Handle}{Any}()
104-
packages = keys(metadata_given_pkg)
105-
for pkg in packages
106-
info_given_name = metadata_given_pkg[pkg]
68+
packages = keys(metadata_given_api_pkg)
69+
for api_pkg in packages
70+
info_given_name = metadata_given_api_pkg[api_pkg]
10771
for name in keys(info_given_name)
72+
info = info_given_name[name]
73+
pkg = info[:package_name]
10874
handle = Handle(name, pkg)
109-
ret[handle] = info_given_name[name]
75+
ret[handle] = info
11076
end
11177
end
11278
return ret
11379

11480
end
11581

116-
# for use in __init__ to define AMBIGUOUS_NAMES
82+
# to define AMBIGUOUS_NAMES
11783
function ambiguous_names(info_given_handle)
11884
names_with_duplicates = map(keys(info_given_handle) |> collect) do handle
11985
handle.name
@@ -124,7 +90,7 @@ function ambiguous_names(info_given_handle)
12490
end
12591
end
12692

127-
# for use in __init__ to define PKGS_GIVEN_NAME
93+
# to define PKGS_GIVEN_NAME
12894
function pkgs_given_name(info_given_handle)
12995
handles = keys(info_given_handle) |> collect
13096
ret = Dict{String,Vector{String}}()
@@ -145,14 +111,6 @@ function model_names(info_given_handle)
145111
return unique(names_allowing_duplicates)
146112
end
147113

148-
function (::Type{Handle})(name::String)
149-
if name in AMBIGUOUS_NAMES
150-
return Handle(name, missing)
151-
else
152-
return Handle(name, first(PKGS_GIVEN_NAME[name]))
153-
end
154-
end
155-
156114
function model_traits_in_registry(info_given_handle)
157115
first_entry = info_given_handle[Handle("ConstantRegressor")]
158116
return keys(first_entry) |> collect

0 commit comments

Comments
 (0)