Skip to content

Commit 1c8929e

Browse files
committed
fix bug around update() not updating all packages
1 parent 2663167 commit 1c8929e

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/methods.jl

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ err_invalid_packages(skip, env) = ArgumentError(
1111
"\"$env\". "
1212
)
1313

14-
const INFO_BE_PATIENT1 = "Be patient. This could take a minute or so... "
15-
const INFO_BE_PATIENT10 = "Be patient. This could take ten minutes or so..."
14+
const INFO_BE_PATIENT1 = "Be patient. This could take a minute or so ... "
15+
const INFO_BE_PATIENT10 = "Be patient. This could take ten minutes or so ..."
1616

1717

1818
# # HELPERS
@@ -195,18 +195,23 @@ function update(
195195
issubset(skip, allpkgs) || throw(err_invalid_packages(skip, registry))
196196
@suppress setup(registry)
197197
end
198-
pkgs = setdiff(allpkgs, skip)
199-
N = length(pkgs)
200-
pos = 1
198+
pkgs = setdiff(allpkgs, skip) |> sort
199+
pkg_set = OrderedSet(pkgs)
200+
201201
@info "Processing up to $nworkers packages at a time. "
202202
@info INFO_BE_PATIENT10
203-
while N 1
204-
print("\rPackages remaining: $N ")
205-
n = min(nworkers, N)
206-
batch = pkgs[pos:pos + n - 1]
203+
while !isempty(pkg_set)
204+
print("\rPackages remaining: $(length(pkgs)) ")
205+
n = min(nworkers, length(pkg_set))
206+
batch = [pop!(pkg_set) for _ in 1:n]
207207
@suppress begin
208-
futures =
209-
[MLJModelRegistryTools.metadata(pkg; registry, check_traits) for pkg in batch]
208+
futures = [
209+
MLJModelRegistryTools.metadata(
210+
pkg;
211+
registry,
212+
check_traits,
213+
) for pkg in batch
214+
]
210215
try
211216
for (i, f) in enumerate(futures)
212217
GenericRegistry.put(batch[i], fetch(f), registry_path())
@@ -218,7 +223,6 @@ function update(
218223
end
219224
debug || GenericRegistry.close.(futures)
220225
end
221-
N -= n
222226
end
223227
isempty(registry) || @suppress cleanup(registry)
224228
gc()

0 commit comments

Comments
 (0)