From fbfe5aeb45bcf3a563cde16c6d6dba703251a6c2 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Tue, 27 Jun 2023 08:58:51 +0200 Subject: [PATCH 1/9] Update funding.yml --- .github/funding.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/funding.yml b/.github/funding.yml index 75064c1a..03fdd1f8 100644 --- a/.github/funding.yml +++ b/.github/funding.yml @@ -1 +1,2 @@ -github: sglyon +github: sglyon, JuliaPlots +open_collective: plotsjl From 43d38e97516e425dced10ae1aa9d8e638113cb5a Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Tue, 27 Jun 2023 08:59:34 +0200 Subject: [PATCH 2/9] Update funding.yml --- .github/funding.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/funding.yml b/.github/funding.yml index 03fdd1f8..c2a37134 100644 --- a/.github/funding.yml +++ b/.github/funding.yml @@ -1,2 +1,2 @@ -github: sglyon, JuliaPlots +github: [sglyon, JuliaPlots] open_collective: plotsjl From efcd6f91ba9a7dba42aa45088ef14ad7da695697 Mon Sep 17 00:00:00 2001 From: Lionel Zoubritzky Date: Tue, 11 Jul 2023 17:17:58 +0200 Subject: [PATCH 3/9] Fix precompilation of packages depending on PlotlyJS --- src/PlotlyJS.jl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/PlotlyJS.jl b/src/PlotlyJS.jl index 9d3e514e..38a662e8 100644 --- a/src/PlotlyJS.jl +++ b/src/PlotlyJS.jl @@ -95,7 +95,7 @@ function __init__() @warn("Warnings were generated during the last build of PlotlyJS: please check the build log at $_build_log") end - @async _start_kaleido_process() + kaleido_task = Base.Threads.@spawn _start_kaleido_process() if !isfile(_js_path) @info("plotly.js javascript libary not found -- downloading now") @@ -163,6 +163,19 @@ function __init__() dataset(::Type{DataFrames.DataFrame}, name::String) = DataFrames.DataFrame(dataset(CSV.File, name)) end end + + wait(kaleido_task) + + if ccall(:jl_generating_output, Cint, ()) == 1 + # ensure precompilation of packages depending on PlotlyJS finishes + if isdefined(P, :proc) + close(P.proc) + close(P.stdin) + close(P.stdout) + close(P.stderr) + sleep(0.1) # avoid a "waiting for IO to finish" warning + end + end end # for methods that update the layout, first apply to the plot, then let plotly.js From d13cf03c36c789ca1d353709b47cb09b9192e5f7 Mon Sep 17 00:00:00 2001 From: Lionel Zoubritzky Date: Tue, 11 Jul 2023 18:13:02 +0200 Subject: [PATCH 4/9] Properly close P.proc Co-authored-by: Jameson Nash --- src/PlotlyJS.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PlotlyJS.jl b/src/PlotlyJS.jl index 38a662e8..eab9c941 100644 --- a/src/PlotlyJS.jl +++ b/src/PlotlyJS.jl @@ -173,7 +173,7 @@ function __init__() close(P.stdin) close(P.stdout) close(P.stderr) - sleep(0.1) # avoid a "waiting for IO to finish" warning + wait(P.proc) end end end From f3896e59bf45335b3bdd9677ff31da2737079204 Mon Sep 17 00:00:00 2001 From: Lionel Zoubritzky Date: Tue, 11 Jul 2023 18:28:42 +0200 Subject: [PATCH 5/9] Keep change minimal Co-authored-by: Jameson Nash --- src/PlotlyJS.jl | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/PlotlyJS.jl b/src/PlotlyJS.jl index eab9c941..6e25e6c9 100644 --- a/src/PlotlyJS.jl +++ b/src/PlotlyJS.jl @@ -169,10 +169,7 @@ function __init__() if ccall(:jl_generating_output, Cint, ()) == 1 # ensure precompilation of packages depending on PlotlyJS finishes if isdefined(P, :proc) - close(P.proc) close(P.stdin) - close(P.stdout) - close(P.stderr) wait(P.proc) end end From 5562c6ca71054cac9c13fcb248e698e3c67b172c Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Sat, 14 Oct 2023 19:03:26 +0200 Subject: [PATCH 6/9] 0.18.11 [skip ci] --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index eb4cb35b..f13d217d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PlotlyJS" uuid = "f0f68f2c-4968-5e81-91da-67840de0976a" authors = ["Spencer Lyon "] -version = "0.18.10" +version = "0.18.11" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" From 9fce8ddac2adba71c5986f8778214e91b239e5f8 Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Mon, 15 Jan 2024 12:02:02 +0100 Subject: [PATCH 7/9] Use the same plotlyjs version number for all imports (#480) * Use the same plotlyjs version number for all imports * add tests for _js_path and _js_version --- .github/workflows/artifacts.yml | 5 +---- .gitignore | 4 ++-- deps/generate_artifacts.jl | 4 +++- deps/plotly_cdn_version.jl | 2 ++ src/PlotlyJS.jl | 3 ++- src/display.jl | 2 +- test/runtests.jl | 5 +++++ 7 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 deps/plotly_cdn_version.jl diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml index 40ac8504..a247ccae 100644 --- a/.github/workflows/artifacts.yml +++ b/.github/workflows/artifacts.yml @@ -13,9 +13,6 @@ jobs: gen-artifacts: # The type of runner that the job will run on runs-on: ubuntu-latest - # The plotly version. Bumping this environment variable should do the trick - env: - PLOTLY_VER: 2.3.0 # Steps represent a sequence of tasks that will be executed as part of the job steps: @@ -33,7 +30,7 @@ jobs: - name: "Get artifact" run: | cd $GITHUB_WORKSPACE - julia -e 'include(joinpath(pwd(),"deps","generate_artifacts.jl")); generate_artifacts("'"$PLOTLY_VER"'","'"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"'")' + julia -e 'include(joinpath(pwd(),"deps","generate_artifacts.jl")); generate_artifacts("'"$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"'")' - name: "Commit updated Artifacts.toml" run: | diff --git a/.gitignore b/.gitignore index 0cdd2010..aea62021 100644 --- a/.gitignore +++ b/.gitignore @@ -6,8 +6,8 @@ tags/ tags site/ .ipynb_checkpoints/ -assets/plotly-latest.min.js -deps/plotly-latest.min.js +assets/plotly-*.min.js +deps/plotly-*.min.js deps/plotschema.json deps/schema.html deps/*.csv diff --git a/deps/generate_artifacts.jl b/deps/generate_artifacts.jl index 3f6bdb93..e456a597 100644 --- a/deps/generate_artifacts.jl +++ b/deps/generate_artifacts.jl @@ -2,7 +2,9 @@ using Pkg.Artifacts using Downloads -function generate_artifacts(ver="latest", repo="https://github.com/JuliaPlots/PlotlyJS.jl") +ver = include("./plotly_cdn_version.jl") + +function generate_artifacts(repo="https://github.com/JuliaPlots/PlotlyJS.jl") artifacts_toml = joinpath(dirname(@__DIR__), "Artifacts.toml") # if Artifacts.toml does not exist we also do not have to remove it diff --git a/deps/plotly_cdn_version.jl b/deps/plotly_cdn_version.jl new file mode 100644 index 00000000..497ceca7 --- /dev/null +++ b/deps/plotly_cdn_version.jl @@ -0,0 +1,2 @@ +# run the artifacts.yml Github Action after changing this file +"2.3.0" diff --git a/src/PlotlyJS.jl b/src/PlotlyJS.jl index 6e25e6c9..36a221b0 100644 --- a/src/PlotlyJS.jl +++ b/src/PlotlyJS.jl @@ -26,7 +26,8 @@ export plot, dataset, list_datasets, make_subplots, savefig, mgrid # globals for this package const _pkg_root = dirname(dirname(@__FILE__)) const _js_path = joinpath(artifact"plotly-artifacts", "plotly.min.js") -const _js_cdn_path = "https://cdn.plot.ly/plotly-latest.min.js" +const _js_version = include(joinpath(_pkg_root, "deps", "plotly_cdn_version.jl")) +const _js_cdn_path = "https://cdn.plot.ly/plotly-$(_js_version).min.js" const _mathjax_cdn_path = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_SVG" diff --git a/src/display.jl b/src/display.jl index ba1c50ad..98f1a0bc 100644 --- a/src/display.jl +++ b/src/display.jl @@ -31,7 +31,7 @@ function SyncPlot( # setup scope deps = [ - "Plotly" => joinpath(artifact"plotly-artifacts", "plotly.min.js"), + "Plotly" => _js_path, joinpath(@__DIR__, "..", "assets", "plotly_webio.bundle.js") ] scope = Scope(imports=deps) diff --git a/test/runtests.jl b/test/runtests.jl index 5bc6a437..189372b3 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -10,4 +10,9 @@ const M = PlotlyJS # include("blink.jl") include("kaleido.jl") +# these are public API +@test isfile(PlotlyJS._js_path) +@test !isempty(PlotlyJS._js_version) +@test !startswith(PlotlyJS._js_version, "v") + end From c68b3b9f63c0699abed83756ec36c04519d51dd8 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Mon, 15 Jan 2024 13:37:56 +0100 Subject: [PATCH 8/9] 0.18.12 [skip ci] --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index f13d217d..db930197 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PlotlyJS" uuid = "f0f68f2c-4968-5e81-91da-67840de0976a" authors = ["Spencer Lyon "] -version = "0.18.11" +version = "0.18.12" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" From 457befe2e4b8f506be5723fe62bbbb4b61dbf30a Mon Sep 17 00:00:00 2001 From: Steve Kelly Date: Fri, 19 Jan 2024 08:17:05 -0500 Subject: [PATCH 9/9] migrate to weakdeps (#463) * migrate to weakdeps * Update ext/DataFramesExt.jl Co-authored-by: Thomas Christensen * fix loading issues * add weakdeps to extras also --------- Co-authored-by: Thomas Christensen Co-authored-by: Simon Christ --- Project.toml | 22 +++++++++++++++++++++- ext/CSVExt.jl | 14 ++++++++++++++ ext/DataFramesExt.jl | 10 ++++++++++ ext/IJuliaExt.jl | 21 +++++++++++++++++++++ ext/JSON3Ext.jl | 9 +++++++++ src/PlotlyJS.jl | 40 ++++++++++------------------------------ 6 files changed, 85 insertions(+), 31 deletions(-) create mode 100644 ext/CSVExt.jl create mode 100644 ext/DataFramesExt.jl create mode 100644 ext/IJuliaExt.jl create mode 100644 ext/JSON3Ext.jl diff --git a/Project.toml b/Project.toml index db930197..72cc596f 100644 --- a/Project.toml +++ b/Project.toml @@ -18,10 +18,26 @@ Reexport = "189a3867-3050-52da-a836-e630ba90ab69" Requires = "ae029012-a4dd-5104-9daa-d747884805df" WebIO = "0f1e0344-ec1d-5b48-a673-e5cf874b6c29" +[weakdeps] +CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" +DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" +IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a" +JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" + +[extensions] +CSVExt = "CSV" +DataFramesExt = ["DataFrames", "CSV"] +IJuliaExt = "IJulia" +JSON3Ext = "JSON3" + [compat] Blink = "0.12" +CSV = "0.10" +DataFrames = "1" +IJulia = "1" JSExpr = "0.5, 1" JSON = "0.20, 0.21" +JSON3 = "1" PlotlyBase = "0.8.15" Reexport = "0.2, 1" Requires = "1.0" @@ -29,7 +45,11 @@ WebIO = "0.8" julia = "1.3, 1.4, 1.5, 1.6" [extras] +CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" +DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" +IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a" +JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Test"] +test = ["Test", "CSV", "DataFrames", "IJulia", "JSON3"] diff --git a/ext/CSVExt.jl b/ext/CSVExt.jl new file mode 100644 index 00000000..fef2330a --- /dev/null +++ b/ext/CSVExt.jl @@ -0,0 +1,14 @@ +module CSVExt + +using PlotlyJS +isdefined(Base, :get_extension) ? (using CSV) : (using ..CSV) + +function PlotlyJS.dataset(::Type{CSV.File}, name::String) + ds_path = PlotlyJS.check_dataset_exists(name) + if !endswith(ds_path, "csv") + error("Can only construct CSV.File from a csv data source") + end + CSV.File(ds_path) +end + +end \ No newline at end of file diff --git a/ext/DataFramesExt.jl b/ext/DataFramesExt.jl new file mode 100644 index 00000000..bc3333ec --- /dev/null +++ b/ext/DataFramesExt.jl @@ -0,0 +1,10 @@ +module DataFramesExt + +using PlotlyJS +isdefined(Base, :get_extension) ? (using DataFrames) : (using ..DataFrames) +isdefined(Base, :get_extension) ? (using CSV) : (using ..CSV) + + +PlotlyJS.dataset(::Type{DataFrames.DataFrame}, name::String) = DataFrames.DataFrame(PlotlyJS.dataset(CSV.File, name)) + +end \ No newline at end of file diff --git a/ext/IJuliaExt.jl b/ext/IJuliaExt.jl new file mode 100644 index 00000000..9bf19748 --- /dev/null +++ b/ext/IJuliaExt.jl @@ -0,0 +1,21 @@ +module IJuliaExt + +using PlotlyJS +isdefined(Base, :get_extension) ? (using IJulia) : (using ..IJulia) +isdefined(Base, :get_extension) ? (using JSON) : (using ..JSON) +isdefined(Base, :get_extension) ? (using PlotlyBase) : (using ..PlotlyBase) + + +function IJulia.display_dict(p::PlotlyJS.SyncPlot) + Dict( + "application/vnd.plotly.v1+json" => JSON.lower(p), + "text/plain" => sprint(show, "text/plain", p), + "text/html" => let + buf = IOBuffer() + show(buf, MIME("text/html"), p) + String(resize!(buf.data, buf.size)) + end + ) +end + +end diff --git a/ext/JSON3Ext.jl b/ext/JSON3Ext.jl new file mode 100644 index 00000000..1b0ed839 --- /dev/null +++ b/ext/JSON3Ext.jl @@ -0,0 +1,9 @@ +module JSON3Ext + +using PlotlyJS +isdefined(Base, :get_extension) ? (using JSON3) : (using ..JSON3) + +JSON3.write(io::IO, p::PlotlyJS.SyncPlot) = JSON3.write(io, p.plot) +JSON3.write(p::PlotlyJS.SyncPlot) = JSON3.write(p.plot) + +end diff --git a/src/PlotlyJS.jl b/src/PlotlyJS.jl index 36a221b0..0d3b2521 100644 --- a/src/PlotlyJS.jl +++ b/src/PlotlyJS.jl @@ -19,7 +19,9 @@ using JSExpr using JSExpr: @var, @new using Blink using Pkg.Artifacts -using Requires +if !isdefined(Base, :get_extension) + using Requires +end export plot, dataset, list_datasets, make_subplots, savefig, mgrid @@ -131,37 +133,15 @@ function __init__() insert!(Base.Multimedia.displays, findlast(x -> x isa REPL.REPLDisplay, Base.Multimedia.displays) + 1, PlotlyJSDisplay()) end) - @require JSON2 = "2535ab7d-5cd8-5a07-80ac-9b1792aadce3" JSON2.write(io::IO, p::SyncPlot) = JSON2.write(io, p.plot) - @require JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" begin - JSON3.write(io::IO, p::SyncPlot) = JSON.print(io, p.plot) - JSON3.write(p::SyncPlot) = JSON.json(p.plot) - end - - @require IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a" begin - - function IJulia.display_dict(p::SyncPlot) - Dict( - "application/vnd.plotly.v1+json" => JSON.lower(p), - "text/plain" => sprint(show, "text/plain", p), - "text/html" => let - buf = IOBuffer() - show(buf, MIME("text/html"), p) - String(resize!(buf.data, buf.size)) - end - ) - end - end + @static if !isdefined(Base, :get_extension) + @require JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" include("../ext/JSON3Ext.jl") + @require IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a" include("../ext/IJuliaExt.jl") - @require CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" begin - function dataset(::Type{CSV.File}, name::String) - ds_path = check_dataset_exists(name) - if !endswith(ds_path, "csv") - error("Can only construct CSV.File from a csv data source") + @require CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" begin + include("../ext/CSVExt.jl") + @require DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" begin + include("../ext/DataFramesExt.jl") end - CSV.File(ds_path) - end - @require DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" begin - dataset(::Type{DataFrames.DataFrame}, name::String) = DataFrames.DataFrame(dataset(CSV.File, name)) end end