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

Add project kwarg to Pluto.run() defaulting to nothing #2614

Open
wants to merge 1 commit into
base: main
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
6 changes: 6 additions & 0 deletions src/Configuration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ const WORKSPACE_USE_DISTRIBUTED_DEFAULT = true
const LAZY_WORKSPACE_CREATION_DEFAULT = false
const CAPTURE_STDOUT_DEFAULT = true
const WORKSPACE_CUSTOM_STARTUP_EXPR_DEFAULT = nothing
const PROJECT_DEFAULT = nothing

"""
EvaluationOptions([; kwargs...])
Expand All @@ -155,13 +156,15 @@ These options are not intended to be changed during normal use.
- `lazy_workspace_creation::Bool = $LAZY_WORKSPACE_CREATION_DEFAULT`
- `capture_stdout::Bool = $CAPTURE_STDOUT_DEFAULT`
- `workspace_custom_startup_expr::Union{Nothing,Expr} = $WORKSPACE_CUSTOM_STARTUP_EXPR_DEFAULT` An expression to be evaluated in the workspace process before running notebook code.
- `project::Union{Nothing, String} = $PROJECT_DEFAULT` Optionally supply project environment for Pluto notebooks. Disables Pluto's built-in package manager. Useful e.g. for batch runs during continuous integration.
"""
@option mutable struct EvaluationOptions
run_notebook_on_load::Bool = RUN_NOTEBOOK_ON_LOAD_DEFAULT
workspace_use_distributed::Bool = WORKSPACE_USE_DISTRIBUTED_DEFAULT
lazy_workspace_creation::Bool = LAZY_WORKSPACE_CREATION_DEFAULT
capture_stdout::Bool = CAPTURE_STDOUT_DEFAULT
workspace_custom_startup_expr::Union{Nothing,Expr} = WORKSPACE_CUSTOM_STARTUP_EXPR_DEFAULT
project::Union{Nothing, String} = PROJECT_DEFAULT
end

const COMPILE_DEFAULT = nothing
Expand Down Expand Up @@ -311,6 +314,8 @@ function from_flat_kwargs(;
startup_file::Union{Nothing,String} = STARTUP_FILE_DEFAULT,
history_file::Union{Nothing,String} = HISTORY_FILE_DEFAULT,
threads::Union{Nothing,String,Int} = default_number_of_threads(),

project::Union{Nothing,String} = nothing,
)
server = ServerOptions(;
root_url,
Expand Down Expand Up @@ -343,6 +348,7 @@ function from_flat_kwargs(;
lazy_workspace_creation,
capture_stdout,
workspace_custom_startup_expr,
project,
)
compiler = CompilerOptions(;
compile,
Expand Down
6 changes: 6 additions & 0 deletions src/packages/Packages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,12 @@ In addition to the steps performed by [`sync_nbpkg_core`](@ref):
- `try` `catch` and reset the package environment on failure.
"""
function sync_nbpkg(session, notebook, old_topology::NotebookTopology, new_topology::NotebookTopology; save::Bool=true, take_token::Bool=true)
if session.options.evaluation.project!=nothing
Pkg.activate(session.options.evaluation.project)
notebook.nbpkg_ctx=nothing
return true
end

cleanup = Ref{Function}(_default_cleanup)
try
Status.report_business_started!(notebook.status_tree, :pkg)
Expand Down
Loading