diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..c96f35a --- /dev/null +++ b/.github/dependabot.yml @@ -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" diff --git a/Project.toml b/Project.toml index 03726c3..7f800ee 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "MLJModelRegistryTools" uuid = "0a96183e-380b-4aa6-be10-c555140810f2" authors = ["Anthony D. Blaom "] -version = "0.1.2" +version = "0.1.3" [deps] Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" diff --git a/src/GenericRegistry.jl b/src/GenericRegistry.jl index f054ad4..eff2aaa 100644 --- a/src/GenericRegistry.jl +++ b/src/GenericRegistry.jl @@ -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). @@ -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: @@ -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 @@ -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, diff --git a/src/MLJModelRegistryTools.jl b/src/MLJModelRegistryTools.jl index ab5426c..502d962 100644 --- a/src/MLJModelRegistryTools.jl +++ b/src/MLJModelRegistryTools.jl @@ -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 @@ -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). diff --git a/src/init.jl b/src/init.jl index 6b25a1f..4e55713 100644 --- a/src/init.jl +++ b/src/init.jl @@ -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 diff --git a/src/methods.jl b/src/methods.jl index ee78438..6846f19 100644 --- a/src/methods.jl +++ b/src/methods.jl @@ -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 @@ -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) @@ -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") @@ -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 @@ -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") @@ -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) @@ -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) diff --git a/src/remote_methods.jl b/src/remote_methods.jl index ea4f949..222cf60 100644 --- a/src/remote_methods.jl +++ b/src/remote_methods.jl @@ -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 diff --git a/test/methods.jl b/test/methods.jl index 77c42b0..3368866 100644 --- a/test/methods.jl +++ b/test/methods.jl @@ -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 @@ -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