Is there a way for a Pluto notebook to print/log into the REPL from which I launched it? I would need that to track progress of notebook CI runs
1 Like
I am not at the pc to try but setting this flag to false should work:
"""
EvaluationOptions([; kwargs...])
Options to change Pluto's evaluation behaviour during internal testing and by downstream packages.
These options are not intended to be changed during normal use.
- `run_notebook_on_load::Bool = $RUN_NOTEBOOK_ON_LOAD_DEFAULT` When running a notebook (not in Safe mode), should all cells evaluate immediately? Warning: this is only for internal testing, and using it will lead to unexpected behaviour and hard-to-reproduce notebooks. It's not the Pluto way!
- `workspace_use_distributed::Bool = $WORKSPACE_USE_DISTRIBUTED_DEFAULT` Whether to start notebooks in a separate process.
- `workspace_use_distributed_stdlib::Bool? = $WORKSPACE_USE_DISTRIBUTED_STDLIB_DEFAULT` Should we use the Distributed stdlib to run processes? Distributed will be replaced by Malt.jl, you can use this option to already get the old behaviour. `nothing` means: determine automatically (which is currently `false`).
- `lazy_workspace_creation::Bool = $LAZY_WORKSPACE_CREATION_DEFAULT`
- `capture_stdout::Bool = $CAPTURE_STDOUT_DEFAULT`
- `workspace_custom_startup_expr::Union{Nothing,String} = $WORKSPACE_CUSTOM_STARTUP_EXPR_DEFAULT` An expression to be evaluated in the workspace process before running notebook code.
"""
@option mutable struct EvaluationOptions
run_notebook_on_load::Bool = RUN_NOTEBOOK_ON_LOAD_DEFAULT
workspace_use_distributed::Bool = WORKSPACE_USE_DISTRIBUTED_DEFAULT
workspace_use_distributed_stdlib::Union{Bool,Nothing} = WORKSPACE_USE_DISTRIBUTED_STDLIB_DEFAULT
lazy_workspace_creation::Bool = LAZY_WORKSPACE_CREATION_DEFAULT
capture_stdout::Bool = CAPTURE_STDOUT_DEFAULT
workspace_custom_startup_expr::Union{Nothing,String} = WORKSPACE_CUSTOM_STARTUP_EXPR_DEFAULT
end
3 Likes
gdalle
June 6, 2024, 12:33pm
3
Thanks for the pointer.
Since I’m using static-export-template I had to do a little more digging to modify the GitHub action, and I’m still stuck:
The export action calls PlutoSliderServer.github_action
:
import PlutoSliderServer
PlutoSliderServer.github_action(".";
Export_cache_dir="pluto_state_cache",
Export_baked_notebookfile=false,
Export_baked_state=false,
# more parameters can go here
)'
The function github_action
is a shortcut for export_directory
, which is itself a shortcut for run_directory
. I can’t figure out if run_directory
can accept the same kwargs as Pluto.run
?
function run_directory(
start_dir::String=".";
notebook_paths::Union{Nothing,Vector{String}}=nothing,
on_ready::Function=((args...) -> nothing),
config_toml_path::Union{String,Nothing}=default_config_path(),
kwargs...,
)
1 Like
I can’t figure out if run_directory
can accept the same kwargs as Pluto.run
?
You would need to prefix the keyword arguments with Pluto_<option_type>_
(here option_type = evaluation
) so:
PlutoSliderServer.github_action(".";
Export_cache_dir="pluto_state_cache",
Export_baked_notebookfile=false,
Export_baked_state=false,
Pluto_evaluation_capture_stdout=false,
# more parameters can go here
)
There may need to enable Pluto_evaluation_workspace_use_distributed_stdlib=true
since Malt (the new notebook process manager does not have stdout forwarding).
1 Like
Even locally with
Pluto.run(
capture_stdout=false,
workspace_use_distributed_stdlib=true
)
the print statements don’t display in my REPL. Anything else I might be missing?
EDIT: I was inside a @progress
for loop from ProgressLogging.jl, removing the macro enabled the prints for some reason. Thanks for your help!
2 Likes