Skip to content

Commit

Permalink
FIXUP: improve Batcher example
Browse files Browse the repository at this point in the history
  • Loading branch information
glennmoy committed Apr 28, 2023
1 parent 786d557 commit d877b31
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions examples/tour.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,35 +155,34 @@ X2, Y2 = materialize_batch(batch)
# to scale our training process across a cluster.

# Let's start by adding a few processes and loading the necessary packages
# Note that the "Batch Manager" cannot be assigned to the primary "Manager" node (1) because XXX
addprocs(4)
batch_workers = workers()
batch_manager = popfirst!(batch_workers)
@everywhere begin
using Pkg
Pkg.activate(@__DIR__)
using OndaBatches
using Onda
end

# Note that the "Batch Manager" cannot be assigned to the primary "Manager" node (1) because XXX
batch_workers = workers()
batch_manager = popfirst!(batch_workers)

# A Batcher governs the allocation of batch processing on a distributed environment.
# We'll provide the RandomBatcher defined above.
batcher = Batcher(batch_manager, batch_workers, batches; start=false)
batcher = Batcher(batch_manager, batch_manager, batches; start=false)

# First let's check the initialised batcher hasn't started
@test get_status(batcher) == :stopped
@test !isready(batcher.channel)

# Now let's start the batcher with a fresh initial state
init_state = MersenneTwister(1)
start!(batcher, init_state)

# It should now be running and ready to allocated batches across nodes
@test get_status(batcher) == :running
@test !isready(batcher.channel)

# X3, Y3 are the same batches we sampled above.
# Similarly, we can keep sampling from this by repeatedly passing in the new_state
(X3, Y3), new_state = take!(batcher, new_state)
(X3, Y3), new_state = take!(batcher, init_state)
@test X3 == X
@test Y3 == Y

Expand Down

0 comments on commit d877b31

Please sign in to comment.