From d0c390c6ade6c65bdccb1e680116e93a826b2541 Mon Sep 17 00:00:00 2001 From: Miles Cranmer Date: Thu, 10 Aug 2023 03:41:34 -0400 Subject: [PATCH] Fix compilation failure on Julia 1.10 (#6) * Require explicit `.start()` to fix Julia 1.10 * Turn off `test_nowarn` for import * Turn off breaking change warning --- Project.toml | 2 +- README.md | 15 ++++++++++++++- src/PlotlyKaleido.jl | 6 ++---- test/runtests.jl | 2 ++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Project.toml b/Project.toml index 2b1c33a..25b4c90 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PlotlyKaleido" uuid = "f2990250-8cf9-495f-b13a-cce12b45703c" authors = ["Simon Christ ", "Spencer Lyon "] -version = "1.0.0" +version = "2.0.0" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" diff --git a/README.md b/README.md index 74afb9b..bee7de2 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,10 @@ This code was originally part of [PlotlyJS.jl](https://github.com/JuliaPlots/Plo ```julia using PlotlyKaleido - import PlotlyLight, EasyConfig, PlotlyJS +PlotlyKaleido.start() # start Kaleido server + p1 = PlotlyLight.Plot(EasyConfig.Config(x = rand(10))) p2 = PlotlyJS.plot(PlotlyJS.scatter(x = rand(10))) @@ -35,3 +36,15 @@ p2 = PlotlyJS.plot(PlotlyJS.scatter(x = rand(10))) PlotlyKaleido.savefig(p1, "plot1.png") PlotlyKaleido.savefig(p2, "plot2.png") ``` + +If needed, you can restart the server: + +```julia +PlotlyKaleido.restart() +``` + +or simply kill it: + +```julia +PlotlyKaleido.kill_kaleido() +``` diff --git a/src/PlotlyKaleido.jl b/src/PlotlyKaleido.jl index f609f8d..8250ce5 100644 --- a/src/PlotlyKaleido.jl +++ b/src/PlotlyKaleido.jl @@ -6,8 +6,6 @@ using Kaleido_jll export savefig -__init__() = start() - #-----------------------------------------------------------------------------# Kaleido Process mutable struct Pipes stdin::Pipe @@ -19,11 +17,11 @@ end const P = Pipes() -kill() = is_running() && kill(P.proc) +kill_kaleido() = is_running() && kill(P.proc) is_running() = isdefined(P, :proc) && isopen(P.stdin) && process_running(P.proc) -restart() = (kill(); start()) +restart() = (kill_kaleido(); start()) function start() is_running() && return diff --git a/test/runtests.jl b/test/runtests.jl index 15e5bb9..e58f5a1 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,6 +1,8 @@ using Test @test_nowarn @eval using PlotlyKaleido +PlotlyKaleido.start() + import PlotlyLight, EasyConfig, PlotlyJS @testset "Saving JSON String" begin