@@ -25,34 +25,60 @@ function clean!(dic, pkg)
25
25
return dic
26
26
end
27
27
28
+ # develop MLJModelRegistry into the specifified `registry` project:
29
+ function setup (registry)
30
+ ex = quote
31
+ # REMOVE THIS NEXT LINE AFTER TAGGING NEW MLJMODELINTERFACE
32
+ Pkg. develop (path= " /Users/anthony/MLJ/MLJModelInterface/" )
33
+ Pkg. develop (path= $ ROOT) # MLJModelRegistry
34
+ end
35
+ future = GenericRegistry. run ([], ex; environment= registry)
36
+ fetch (future)
37
+ GenericRegistry. close (future)
38
+ end
39
+
40
+ # remove MLJModelRegistry from the specifified `registry` project:
41
+ function cleanup (registry)
42
+ ex = quote
43
+ Pkg. rm (" MLJModelRegistry" )
44
+ end
45
+ future = GenericRegistry. run ([], ex; environment= registry)
46
+ fetch (future)
47
+ GenericRegistry. close (future)
48
+ end
49
+
28
50
"""
29
- metadata(pkg; manifest=true , check_traits=true)
51
+ metadata(pkg; registry="" , check_traits=true)
30
52
31
53
*Private method.*
32
54
33
55
Extract the metadata for a package. Returns a `Future` object that must be `fetch`ed to
34
56
get the metadata. See, [`MLJModelRegistry.update`](@ref), which calls this method, for
35
57
more details.
36
58
59
+ Assumes that MLJModelRegistry has been `develop`ed into `registry` if this is non-empty.
60
+
37
61
"""
38
- function metadata (pkg; environment= nothing , check_traits= true )
39
- if ! isnothing (environment)
40
- pkg in GenericRegistry. dependencies (environment) ||
41
- throw (err_missing_package (pkg, environment))
42
- end
43
- setup = quote
44
- # REMOVE THIS NEXT LINE AFTER TAGGING NEW MLJMODELINTERFACE
45
- Pkg. develop (path= " /Users/anthony/MLJ/MLJModelInterface/" )
46
- Pkg. develop (path= $ ROOT)
62
+ function metadata (pkg; registry= " " , check_traits= true )
63
+ if ! isempty (registry)
64
+ pkg in GenericRegistry. dependencies (registry) ||
65
+ throw (err_missing_package (pkg, registry))
66
+ setup= ()
67
+ else
68
+ setup = quote
69
+ # REMOVE THIS NEXT LINE AFTER TAGGING NEW MLJMODELINTERFACE
70
+ Pkg. develop (path= " /Users/anthony/MLJ/MLJModelInterface/" )
71
+ Pkg. develop (path= $ ROOT) # MLJModelRegistry
72
+ end
47
73
end
48
74
program = quote
49
75
import MLJModelRegistry
50
- dic = MLJModelRegistry. traits_given_constructor_name (
76
+ MLJModelRegistry. traits_given_constructor_name (
51
77
$ pkg,
52
78
check_traits= $ check_traits,
53
79
)
54
80
end
55
- return GenericRegistry. run (setup, pkg, program; environment)
81
+ return GenericRegistry. run (setup, pkg, program; environment= registry )
56
82
end
57
83
58
84
@@ -67,7 +93,7 @@ registry.
67
93
This is performed automatically after `update()`, but not after `update(pkg)`.
68
94
69
95
"""
70
- gc () = GenericRegistry. gc (REGISTRY )
96
+ gc () = GenericRegistry. gc (registry_path () )
71
97
72
98
73
99
"""
@@ -78,28 +104,27 @@ strings, and record this in the MLJ model registry (write it to
78
104
`/registry/Metadata.toml`).
79
105
80
106
Assumes `pkg` is already a dependency in the Julia environment defined at `/registry/` and
81
- uses the version of `pkg` consistent with the current environment manifest. See
82
- documentation for details on the registration process.
107
+ uses the version of `pkg` consistent with the current environment manifest, after
108
+ MLJModelRegistry.jl has been `develop`ed into that environment (it is removed again after
109
+ the update). See documentation for details on the registration process.
83
110
84
111
```julia-repl
85
112
julia> update("MLJDecisionTreeInterface")
86
113
```
87
114
88
115
# Return value
89
116
90
- A set of all names of all models (more precisely, constructors) for which metadata was
91
- recorded.
117
+ The metadata dictionary, keyed on models (more precisely, constructors, thereof).
92
118
93
119
# Advanced options
94
120
95
121
!!! warning
96
122
97
123
Advanced options are intented primarily for diagnostic purposes.
98
124
99
- - `manifest=true`: Set to `false` to ignore the registry environment manifest (at
100
- `/registry/Manifest.toml`) and instead add only the specified packages to a new
101
- temporary environment. Useful to temporarily force latest versions if these are being
102
- blocked by other packages.
125
+ - `manifest=true`: Set to `false` to ignore the registry environment manifest and instead
126
+ add only the specified packages to a new temporary environment. Useful to temporarily
127
+ force latest versions if these are being blocked by other packages.
103
128
104
129
- `debug=false`: Calling `update` opens a temporary Julia process to extract the trait
105
130
metadata (see [`MLJModelRegistry.GenericRegistry.run`](@ref)). By default, this process
@@ -109,23 +134,26 @@ recorded.
109
134
110
135
"""
111
136
function update (pkg; debug= false , manifest= true , check_traits= true )
112
- environment = manifest ? REGISTRY : nothing
137
+ registry = manifest ? registry_path () : " "
113
138
@info INFO_BE_PATIENT1
114
- update (pkg, debug ? Loud () : Quiet (), environment , check_traits)
139
+ update (pkg, debug ? Loud () : Quiet (), registry , check_traits)
115
140
end
116
- update (pkg, :: Loud , environment, check_traits) = _update (pkg, environment, check_traits)
117
- update (pkg, :: Quiet , environment, check_traits) =
118
- @suppress _update (pkg, environment, check_traits)
119
- function _update (pkg, environment, check_traits)
120
- future = MLJModelRegistry. metadata (pkg; environment, check_traits)
141
+ update (pkg, :: Loud , registry, check_traits) = _update (pkg, true , registry, check_traits)
142
+ update (pkg, :: Quiet , registry, check_traits) =
143
+ @suppress _update (pkg, false , registry, check_traits)
144
+ function _update (pkg, debug, registry, check_traits)
145
+ isempty (registry) || setup (registry)
146
+ future = MLJModelRegistry. metadata (pkg; registry, check_traits)
121
147
metadata = try
122
148
fetch (future)
123
149
catch excptn
150
+ isempty (registry) || cleanup (registry)
124
151
debug || GenericRegistry. close (future)
125
152
rethrow (excptn)
126
153
end
127
- GenericRegistry. close (future)
128
- GenericRegistry. put (pkg, metadata, REGISTRY)
154
+ isempty (registry) || cleanup (registry)
155
+ debug || GenericRegistry. close (future)
156
+ GenericRegistry. put (pkg, metadata, registry_path ())
129
157
end
130
158
131
159
"""
@@ -147,8 +175,10 @@ A set of all names of all packages for which metadata was recorded.
147
175
updates in parallel. Metadata is extracted in parallel, but written to file
148
176
sequentially.
149
177
150
- - `debug=false`, `manifest=true`: These are applied as indicated above for each package
151
- added.
178
+ - `debug=false`: Set to `true` to leave temporary processes open; see the `update(pkg;
179
+ ...)` document string above.
180
+
181
+ - `manifest=true`: See the `update(pkg; ...)` document string above.
152
182
153
183
"""
154
184
function update (
@@ -158,35 +188,38 @@ function update(
158
188
manifest= true ,
159
189
check_traits= true ,
160
190
)
161
- environment = manifest ? REGISTRY : nothing
162
- allpkgs = GenericRegistry. dependencies (REGISTRY)
163
- if ! isnothing (environment)
164
- issubset (skip, allpkgs) || throw (err_invalid_packages (skip, environment))
191
+ registry = manifest ? registry_path () : " "
192
+ allpkgs = GenericRegistry. dependencies (registry_path ())
193
+ if ! isempty (registry)
194
+ issubset (skip, allpkgs) || throw (err_invalid_packages (skip, registry))
195
+ @suppress setup (registry)
165
196
end
166
197
pkgs = setdiff (allpkgs, skip)
167
198
N = length (pkgs)
168
199
pos = 1
169
- @info " Processing $nworkers packages at a time. "
200
+ @info " Processing up to $nworkers packages at a time. "
170
201
@info INFO_BE_PATIENT10
171
202
while N ≥ 1
172
203
print (" \r Packages remaining: $N " )
173
204
n = min (nworkers, N)
174
205
batch = pkgs[pos: pos + n - 1 ]
175
206
@suppress begin
176
207
futures =
177
- [MLJModelRegistry. metadata (pkg; environment , check_traits) for pkg in batch]
208
+ [MLJModelRegistry. metadata (pkg; registry , check_traits) for pkg in batch]
178
209
try
179
210
for (i, f) in enumerate (futures)
180
- GenericRegistry. put (batch[i], fetch (f), REGISTRY )
211
+ GenericRegistry. put (batch[i], fetch (f), registry_path () )
181
212
end
182
213
catch excptn
214
+ isempty (registry) || cleanup (registry)
183
215
debug || GenericRegistry. close .(futures)
184
216
rethrow (excptn)
185
217
end
186
- GenericRegistry. close .(futures)
218
+ debug || GenericRegistry. close .(futures)
187
219
end
188
220
N -= n
189
221
end
222
+ isempty (registry) || @suppress cleanup (registry)
190
223
gc ()
191
224
println (" \r Packages remaining: 0 " )
192
225
return pkgs
@@ -200,4 +233,4 @@ Inspect the model trait metadata recorded in the Model Registry for those models
200
233
see [`MLJModelRegistry.encode_dic`](@ref).
201
234
202
235
"""
203
- get (pkg) = GenericRegistry. get (pkg, REGISTRY )
236
+ get (pkg) = GenericRegistry. get (pkg, registry_path () )
0 commit comments