Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use at-withprogress from ProgressLogging.jl #64

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ ArgCheck = "dce04be8-c92d-5529-be00-80e4d2c0e197"
BangBang = "198e06fe-97b7-11e9-32a5-e1d131e6ad66"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
InitialValues = "22cec73e-a1b8-11e9-2c92-598750a2cf9c"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
ProgressLogging = "33c8b6b6-d38a-422a-b730-caa89a2f386c"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"

Expand Down
10 changes: 9 additions & 1 deletion benchmark/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ version = "0.2.6"
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[[ProgressLogging]]
deps = ["Logging"]
git-tree-sha1 = "aac07ef3cc8d6d8e0ccf476d649c32feb7cb1860"
repo-rev = "logprogress"
repo-url = "https://github.com/tkf/ProgressLogging.jl.git"
uuid = "33c8b6b6-d38a-422a-b730-caa89a2f386c"
version = "0.1.0"

[[ProgressMeter]]
deps = ["Distributed", "Printf"]
git-tree-sha1 = "fab12b19f198dd148ca467ac4e4f12ecd0241819"
Expand Down Expand Up @@ -191,7 +199,7 @@ uuid = "0796e94c-ce3b-5d07-9a54-7f471281c624"
version = "0.5.6"

[[Transducers]]
deps = ["ArgCheck", "BangBang", "Distributed", "InitialValues", "Logging", "Markdown", "Requires", "Setfield"]
deps = ["ArgCheck", "BangBang", "Distributed", "InitialValues", "Markdown", "ProgressLogging", "Requires", "Setfield"]
path = ".."
uuid = "28d57a85-8fef-5791-bfe6-a80928e7c999"
version = "0.4.3-DEV"
Expand Down
1 change: 1 addition & 0 deletions benchmark/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
PkgBenchmark = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d"
ProgressLogging = "33c8b6b6-d38a-422a-b730-caa89a2f386c"
Referenceables = "42d2dcc6-99eb-4e98-b66c-637b7d73030e"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Transducers = "28d57a85-8fef-5791-bfe6-a80928e7c999"
10 changes: 9 additions & 1 deletion docs/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,14 @@ uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[[ProgressLogging]]
deps = ["Logging"]
git-tree-sha1 = "aac07ef3cc8d6d8e0ccf476d649c32feb7cb1860"
repo-rev = "logprogress"
repo-url = "https://github.com/tkf/ProgressLogging.jl.git"
uuid = "33c8b6b6-d38a-422a-b730-caa89a2f386c"
version = "0.1.0"

[[REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
Expand Down Expand Up @@ -258,7 +266,7 @@ uuid = "0796e94c-ce3b-5d07-9a54-7f471281c624"
version = "0.5.6"

[[Transducers]]
deps = ["ArgCheck", "BangBang", "Distributed", "InitialValues", "Logging", "Markdown", "Requires", "Setfield"]
deps = ["ArgCheck", "BangBang", "Distributed", "InitialValues", "Markdown", "ProgressLogging", "Requires", "Setfield"]
path = ".."
uuid = "28d57a85-8fef-5791-bfe6-a80928e7c999"
version = "0.4.3-DEV"
Expand Down
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ InitialValues = "22cec73e-a1b8-11e9-2c92-598750a2cf9c"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
OnlineStats = "a15396b6-48d5-5d58-9928-6d29437db91e"
ProgressLogging = "33c8b6b6-d38a-422a-b730-caa89a2f386c"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Expand Down
2 changes: 1 addition & 1 deletion src/Transducers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ using Base.Broadcast: Broadcasted
using ArgCheck
using BangBang: push!!, empty!!, setindex!!
using Distributed: Distributed, @everywhere
using Logging: LogLevel, @logmsg
using ProgressLogging: @withprogress, @logprogress
using Requires
using InitialValues: InitialValues, InitialValue, SpecificInitialValue, Init,
hasinitialvalue
Expand Down
29 changes: 7 additions & 22 deletions src/progress.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,30 +54,15 @@ struct ProgressLoggingFoldable{T} <: Foldable
interval::Float64
end

# Use Juno/Atom-compatible log-level. See:
# https://github.com/JunoLab/Atom.jl/blob/v0.11.1/src/progress.jl#L75-L76
const PROGRESSLEVEL = LogLevel(-1)

# Juno.progress
function __progress(f; name = "")
_id = gensym()
@logmsg PROGRESSLEVEL name progress=0.0 _id=_id
try
f(_id)
finally
@logmsg PROGRESSLEVEL name progress="done" _id=_id
end
end

function __foldl__(rf0, init, coll::ProgressLoggingFoldable)
__progress() do id
@withprogress name = "foldl" begin
n = length(coll.foldable)
progress_interval = coll.interval
scaninit = (0, time())
xf = ScanEmit(scaninit) do (i, t0), x
t1 = time()
if t1 - t0 > progress_interval
@logmsg PROGRESSLEVEL "foldl" _id=id progress=i/n
@logprogress i/n
t0 = t1
end
x, (i + 1, t0)
Expand Down Expand Up @@ -142,9 +127,9 @@ function _reduce_progress(reduce_impl, rf0, init, coll)

reducible = @set coll.reducible = coll.reducible.foldable
progress_task = @async let n = length(coll.reducible.foldable)
__progress() do id
@withprogress name = "reduce" begin
foreach(Scan(+), chan) do i
@logmsg PROGRESSLEVEL "reduce" _id=id progress=i/n
@logprogress i/n
end
end
end
Expand Down Expand Up @@ -211,19 +196,19 @@ function dtransduce(
chan = Distributed.RemoteChannel()
remote_foldl_with_logging = RemoteFoldlWithLogging(chan, coll.interval)
progress_task = @async let n = length(coll.foldable)
__progress() do id
@withprogress name = "dreduce" begin
i = 0
while true
i += try
take!(chan)
catch
return
end
@logmsg PROGRESSLEVEL "dreduce" _id=id progress=i/n
@logprogress i/n
end
#=
foreach(Scan(+), chan) do i
@logmsg PROGRESSLEVEL "dreduce" _id=id progress=i/n
@logprogress i/n
end
=#
end
Expand Down
10 changes: 9 additions & 1 deletion test/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,14 @@ uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[[ProgressLogging]]
deps = ["Logging"]
git-tree-sha1 = "aac07ef3cc8d6d8e0ccf476d649c32feb7cb1860"
repo-rev = "logprogress"
repo-url = "https://github.com/tkf/ProgressLogging.jl.git"
uuid = "33c8b6b6-d38a-422a-b730-caa89a2f386c"
version = "0.1.0"

[[REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
Expand Down Expand Up @@ -278,7 +286,7 @@ uuid = "0796e94c-ce3b-5d07-9a54-7f471281c624"
version = "0.5.6"

[[Transducers]]
deps = ["ArgCheck", "BangBang", "Distributed", "InitialValues", "Logging", "Markdown", "Requires", "Setfield"]
deps = ["ArgCheck", "BangBang", "Distributed", "InitialValues", "Markdown", "ProgressLogging", "Requires", "Setfield"]
path = ".."
uuid = "28d57a85-8fef-5791-bfe6-a80928e7c999"
version = "0.4.3-DEV"
Expand Down
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
OnlineStats = "a15396b6-48d5-5d58-9928-6d29437db91e"
ProgressLogging = "33c8b6b6-d38a-422a-b730-caa89a2f386c"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Expand Down