From 0b33755acb1645252fbd7282b28d196b838608fb Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Wed, 2 Nov 2022 12:10:35 +0100 Subject: [PATCH] Don't keep notebooks running if they appear in SliderServer.exclude (#95) --- src/Actions.jl | 10 +++------- test/HTTP requests.jl | 30 +++++++++++++++++++++++++++--- test/runtests.jl | 2 ++ test/static export.jl | 2 -- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/Actions.jl b/src/Actions.jl index b6918d5..7b2aca2 100644 --- a/src/Actions.jl +++ b/src/Actions.jl @@ -63,7 +63,8 @@ function process( @warn "Notebook file does not have desired hash. This probably means that the file changed too quickly. Continuing and hoping for the best!" s.path new_hash s.desired_hash end - keep_running = settings.SliderServer.enabled + keep_running = + settings.SliderServer.enabled && !is_glob_match(path, settings.SliderServer.exclude) skip_cache = keep_running || is_glob_match(path, settings.Export.ignore_cache) cached_state = skip_cache ? nothing : try_fromcache(settings.Export.cache_dir, new_hash) @@ -114,12 +115,7 @@ function process( @info "### ✓ $(progress) Ready" s.path new_hash - NotebookSession(; - path=s.path, - current_hash=new_hash, - desired_hash=s.desired_hash, - run=run, - ) + NotebookSession(; path, current_hash=new_hash, desired_hash=s.desired_hash, run) end ### diff --git a/test/HTTP requests.jl b/test/HTTP requests.jl index d59586a..3798157 100644 --- a/test/HTTP requests.jl +++ b/test/HTTP requests.jl @@ -26,6 +26,7 @@ using UUIDs, Random PlutoSliderServer.run_directory( test_dir; Export_enabled=false, + Export_cache_dir=cache_dir, SliderServer_port=port, notebook_paths, on_ready, @@ -119,7 +120,7 @@ using UUIDs, Random end - +find(f, xs) = xs[findfirst(f, xs)] original_dir1 = joinpath(@__DIR__, "dir1") @@ -133,6 +134,15 @@ make_test_dir() = @testset "HTTP requests: static" begin test_dir = make_test_dir() + let + # add one more file that we will only export, but not run in the slider server + old = read(joinpath(test_dir, "a.jl"), String) + new = replace(old, "Hello" => "Hello again") + @assert old != new + + mkpath(joinpath(test_dir, "x", "y", "z")) + write(joinpath(test_dir, "x", "y", "z", "export_only.jl"), new) + end port = rand(12345:65000) @@ -150,7 +160,9 @@ make_test_dir() = Export_enabled=true, Export_baked_notebookfile=false, Export_baked_state=false, + Export_cache_dir=cache_dir, SliderServer_port=port, + SliderServer_exclude=["*/export_only*"], on_ready, ) end @@ -165,14 +177,26 @@ make_test_dir() = - s = notebook_sessions[1] + s_a = find(s -> occursin("a.jl", s.path), notebook_sessions) + s_export_only = find(s -> occursin("export_only", s.path), notebook_sessions) + response = - HTTP.request("GET", "http://localhost:$(port)/bondconnections/$(s.current_hash)/") + HTTP.request("GET", "http://localhost:$(port)/bondconnections/$(s_a.current_hash)/") data = Pluto.unpack(response.body) @test data isa Dict @test isempty(data) # these notebooks don't have any bonds + @test s_export_only.run isa PlutoSliderServer.var"../Types.jl".FinishedNotebook + + response_export_only = HTTP.request( + "GET", + "http://localhost:$(port)/bondconnections/$(s_export_only.current_hash)/"; + status_exception=false, + ) + + @test response_export_only.status == 404 # this notebook is not in the slider server + asset_urls = [ "" "pluto_export.json" diff --git a/test/runtests.jl b/test/runtests.jl index 697d6cf..86054d4 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -14,6 +14,8 @@ just_run_test_server = false if just_run_test_server include("./runtestserver.jl") else + cache_dir = tempname(cleanup=false) + ENV["HIDE_PLUTO_EXACT_VERSION_WARNING"] = "true" include("./plutohash.jl") include("./configuration.jl") diff --git a/test/static export.jl b/test/static export.jl index 91b9328..04a22ba 100644 --- a/test/static export.jl +++ b/test/static export.jl @@ -15,8 +15,6 @@ make_test_dir() = new end -cache_dir = tempname(cleanup=false) - @testset "static - Basic github action" begin test_dir = make_test_dir()