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

Switch to ProgressLogging.jl #13

Merged
merged 1 commit into from
Jan 19, 2024
Merged
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
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
Malt = "36869731-bdee-424d-aa32-cab38c994e3b"
PNGFiles = "f57f5aa1-a3ce-4bc8-8ab9-96f992907883"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
ProgressLogging = "33c8b6b6-d38a-422a-b730-caa89a2f386c"
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
Expand All @@ -32,7 +32,7 @@ Logging = "1.6"
Malt = "1"
PNGFiles = "0.4"
PrecompileTools = "1"
ProgressMeter = "1.9"
ProgressLogging = "0.1.4"
REPL = "1.6"
Random = "1.6"
Sockets = "1.6"
Expand Down
2 changes: 1 addition & 1 deletion src/QuartoNotebookRunner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import Logging
import Malt
import PNGFiles
import PrecompileTools
import ProgressMeter
import ProgressLogging
import REPL
import Random
import Sockets
Expand Down
31 changes: 25 additions & 6 deletions src/server.jl
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,29 @@
)
end

# Convenience macro that outputs
# ```julia
# if showprogress
# ProgressLogging.@progress exprs...
# else
# exprs[end]
# end
# ```
# TODO: Upstream to ProgressLogging?
macro maybe_progress(showprogress, exprs...)
if isempty(exprs)
throw(ArgumentError("at least one expression required"))

Check warning on line 363 in src/server.jl

View check run for this annotation

Codecov / codecov/patch

src/server.jl#L363

Added line #L363 was not covered by tests
end
expr = quote
if $(showprogress)
$ProgressLogging.@progress $(exprs...)
else
$(exprs[end])

Check warning on line 369 in src/server.jl

View check run for this annotation

Codecov / codecov/patch

src/server.jl#L369

Added line #L369 was not covered by tests
end
end
return esc(expr)
end

"""
evaluate_raw_cells!(f::File, chunks::Vector)

Expand All @@ -363,12 +386,8 @@
)
refresh!(f, frontmatter)
cells = []
ProgressMeter.@showprogress enabled = showprogress desc = "Running $(relpath(f.path, pwd()))" for (
nth,
chunk,
) in enumerate(
chunks,
)
@maybe_progress showprogress "Running $(relpath(f.path, pwd()))" for (nth, chunk) in

Check warning on line 389 in src/server.jl

View check run for this annotation

Codecov / codecov/patch

src/server.jl#L389

Added line #L389 was not covered by tests
enumerate(chunks)
if chunk.type === :code

outputs = []
Expand Down