Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/" # Location of package manifests
schedule:
interval: "monthly"
- package-ecosystem: "julia"
directories: # Location of Julia projects
- "/"
- "/docs"
schedule:
interval: "weekly"
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MLJModelRegistryTools"
uuid = "0a96183e-380b-4aa6-be10-c555140810f2"
authors = ["Anthony D. Blaom <anthony.blaom@gmail.com>"]
version = "0.1.2"
version = "0.1.3"

[deps]
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Expand Down
10 changes: 5 additions & 5 deletions src/GenericRegistry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ standard library, `Pkg`.
execute a Julia expression there; results are returned as `Future` objects, to allow
asynchronous `run` calls. Useful for generating metadata about a package.

- [`GenericRegistry.close(future)`](@ref): Shut down the process intitiated by the `run`
- [`GenericRegistry.close(future)`](@ref): Shut down the process initiated by the `run`
call that returned `future` (after calling `fetch(future)` to get the result of
evaluation).

Expand Down Expand Up @@ -110,7 +110,7 @@ end
# # METHODS

"""
GenericRegistry.run([setup,] packages, program; environment=nothing)
GenericRegistry.run([setup,] packages, program; environment="")

Assuming a package `environment` path is specified, do the following in a new Julia
process:
Expand All @@ -136,13 +136,13 @@ If `environment` is unspecified, then a fresh temporary environment is activated
packages listed in `packages` are manually added between Steps 2 and 3 above.

"""
function run(setup, pkgs, program; environment=nothing)
function run(setup, pkgs, program; environment="")
pkgs isa Vector || (pkgs = [pkgs,])
imports = [:(import $(Symbol(pkg))) for pkg in pkgs]
ex = quote
using Pkg
end
if isnothing(environment)
if isempty(environment)
push!(
ex.args,
quote
Expand All @@ -158,7 +158,7 @@ function run(setup, pkgs, program; environment=nothing)
)
end
push!(ex.args, quote $setup end)
if isnothing(environment)
if isempty(environment)
additions = [:(Pkg.add($pkg)) for pkg in pkgs]
push!(
ex.args,
Expand Down
10 changes: 7 additions & 3 deletions src/MLJModelRegistryTools.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
"""
MLJModelRegistryTools

!!! note

Issues around packages in the MLJ model registry that use PythonCall necessitate `update` workarounds. See [https://github.com/JuliaAI/MLJModelRegistryTools.jl/issues/10](https://github.com/JuliaAI/MLJModelRegistryTools.jl/issues/10).

Module providing tools for managing the MLJ Model Registry. To modify the registry:

- Make sure the MLJModelRegistryTools.jl `[compat]` entry for MLJModels is up to date. If
Expand All @@ -22,11 +26,11 @@ Module providing tools for managing the MLJ Model Registry. To modify the regist
- Point the `MLJModelRegistryTools` module to the location of the registry itself within
your MLJModels.jl clone, using `setpath(path_to_registry)`, as in
`setpath("MyPkgs/MLJModels.jl/src/registry")`. To check this worked, try
`MLJRegistryTools.get("MLJBase")`, to see the MLJBase.jl models.
`MLJModelRegistryTools.get("MLJBase")`, to see the MLJBase.jl models.

- To add or update the metadata associated with a package, run [`update(pkg)`](@ref), as
in `update("MLJTransforms"). Ensure that every model provided by the package appears as a
key in the returned value. Omissions may indicate a bad `load_path`.
in `update("MLJTransforms")`. Ensure that every model provided by the package appears as
a key in the returned value. Omissions may indicate a bad `load_path`.

- Assuming this is successful, update the metadata for *all* packages in the registry
by running [`update()`](@ref).
Expand Down
8 changes: 8 additions & 0 deletions src/init.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
function __init__()
dev = parse(Bool, Base.get(ENV, "DEVELOPING_MLJ_MODEL_REGISTRY_TOOLS", "false"))
if !dev
@info "If you are developing MLJModelRegistryTools.jl, be sure to set "*
"`ENV[\"DEVELOPING_MLJ_MODEL_REGISTRY_TOOLS\"] = \"true\"`. Otherwise, "*
"the methods from `src/remote_methods.jl` from the *registered* version "*
"of MLJModelRegistryTools.jl get applied during update, not the dev "*
"versions. "
end
global REGISTRY_PATH=Ref("")
end
27 changes: 21 additions & 6 deletions src/methods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ err_invalid_packages(skip, env) = ArgumentError(
const INFO_BE_PATIENT1 = "Be patient. This could take a minute or so ... "
const INFO_BE_PATIENT10 = "Be patient. This could take ten minutes or so ..."

function warn_developing()
dev = parse(Bool, Base.get(ENV, "DEVELOPING_MLJ_MODEL_REGISTRY_TOOLS", "false"))
dev && @info "Registry tools working in development mode. Set "*
"`ENV[\"DEVELOPING_MLJ_MODEL_REGISTRY_TOOLS\"] = \"false\"` "*
"to change this. "
end


# # HELPERS

Expand All @@ -25,7 +32,7 @@ function clean!(dic, pkg)
return dic
end

# develop MLJModelRegistryTools into the specifified `registry` project:
# develop MLJModelRegistryTools into the specified `registry` project:
function setup(registry)
ex = quote
# Pkg.develop(path=$ROOT)
Expand All @@ -36,7 +43,7 @@ function setup(registry)
GenericRegistry.close(future)
end

# remove MLJModelRegistryTools from the specifified `registry` project:
# remove MLJModelRegistryTools from the specified `registry` project:
function cleanup(registry)
ex = quote
Pkg.rm("MLJModelRegistryTools")
Expand Down Expand Up @@ -64,9 +71,13 @@ function metadata(pkg; registry="", check_traits=true)
throw(err_missing_package(pkg, registry))
setup=()
else
dev = parse(Bool, Base.get(ENV, "DEVELOPING_MLJ_MODEL_REGISTRY_TOOLS", "false"))
setup = quote
# Pkg.develop(path=$ROOT)
Pkg.add("MLJModelRegistryTools")
if $dev
Pkg.develop(path=$ROOT)
else
Pkg.add("MLJModelRegistryTools")
end
end
end
program = quote
Expand Down Expand Up @@ -103,8 +114,10 @@ strings, and record this in the MLJ model registry (write it to

Assumes `pkg` is already a dependency in the Julia environment defined at `/registry/` and
uses the version of `pkg` consistent with the current environment manifest, after
MLJModelRegistryTools.jl has been `develop`ed into that environment (it is removed again after
the update). See documentation for details on the registration process.
MLJModelRegistryTools.jl has been `add`ed into that environment (it is removed again after
the update). (To `dev` the tools instead, you need to set
`ENV["DEVELOPING_MLJ_MODEL_REGISTRY_TOOLS"] = "true"`.) See documentation for details on
the registration process.

```julia-repl
julia> update("MLJDecisionTreeInterface")
Expand Down Expand Up @@ -132,6 +145,7 @@ The metadata dictionary, keyed on models (more precisely, constructors, thereof)

"""
function update(pkg; debug=false, manifest=true, check_traits=true)
warn_developing()
registry = manifest ? registry_path() : ""
@info INFO_BE_PATIENT1
update(pkg, debug ? Loud() : Quiet(), registry, check_traits)
Expand Down Expand Up @@ -186,6 +200,7 @@ function update(
manifest=true,
check_traits=true,
)
warn_developing()
registry = manifest ? registry_path() : ""
allpkgs = GenericRegistry.dependencies(registry_path())
if !isempty(registry)
Expand Down
2 changes: 1 addition & 1 deletion src/remote_methods.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Remote methods are methods called on remote processes for the purpose of when extacting
# Remote methods are methods called on remote processes for the purpose of when extracting
# model metadata for a package


Expand Down
25 changes: 18 additions & 7 deletions test/methods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ project = joinpath(registry, "Project.toml")
manifest = joinpath(registry, "Manifest.toml")
open(project, "w") do file
write(file, project_string)
end
end;

@testset "metadata" begin
@suppress begin
Expand Down Expand Up @@ -76,12 +76,23 @@ setpath(registry)

@test traits_given_model["Pipeline"][":name"] == "Pipeline"

packages = @test_logs(
(:info, ),
(:info, MLJModelRegistryTools.INFO_BE_PATIENT10),
MLJModelRegistryTools.update(),
)
@test "MLJDecisionTreeInterface" in packages
dev = parse(Bool, get(ENV, "DEVELOPING_MLJ_MODEL_REGISTRY_TOOLS", "false"))
if !dev
packages = @test_logs(
(:info, ),
(:info, MLJModelRegistryTools.INFO_BE_PATIENT10),
MLJModelRegistryTools.update(),
)
@test "MLJDecisionTreeInterface" in packages
else
packages = @test_logs(
(:info, ),
(:info, ),
(:info, MLJModelRegistryTools.INFO_BE_PATIENT10),
MLJModelRegistryTools.update(),
)
@test "MLJDecisionTreeInterface" in packages
end
end

@testset "get" begin
Expand Down
Loading