Skip to content

Commit 33f1a9e

Browse files
committed
rework artifacts and add schema
1 parent 674663f commit 33f1a9e

File tree

5 files changed

+36
-35
lines changed

5 files changed

+36
-35
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ Manifest.toml
1010
*.log
1111
*.tar
1212
*.tar.gz
13-
artifacts/
13+
deps/plotly_artifacts*
14+
notebooks/

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ authors = ["joshday <emailjoshday@gmail.com>"]
44
version = "0.5.2"
55

66
[deps]
7+
ArtifactUtils = "8b73e784-e7d8-4ea5-973d-377fed4e3bce"
78
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
89
Cobweb = "ec354790-cf28-43e8-bb59-b484409b7bad"
910
DefaultApplication = "3f0dd361-4fe0-5fc6-8523-80b14ec94d85"
@@ -15,10 +16,10 @@ StructTypes = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
1516

1617
[compat]
1718
Cobweb = "0.1, 0.2"
18-
StructTypes = "1"
1919
DefaultApplication = "1"
2020
EasyConfig = "0.1.10"
2121
JSON3 = "1.8"
22+
StructTypes = "1"
2223
julia = "^1.6"
2324

2425
[extras]

deps/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
44
Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d"
55
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
66
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
7+
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
78
PlotlyLight = "ca7969ec-10b3-423e-8d99-40f33abb42bf"
89
Tar = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"

deps/artifact_bundle.jl

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,53 @@
11
using Pkg
22
Pkg.activate(@__DIR__)
33

4-
using Downloads, Tar, ArtifactUtils, Artifacts, Dates, Pkg
4+
using Downloads, Tar, ArtifactUtils, Artifacts, Dates, JSON3
55

66
#-----------------------------------------------------------------------------# Start from scratch
7-
for file in readdir(@__DIR__)
8-
if endswith(file, ".tar") || endswith(file, ".gz")
9-
rm(joinpath(@__DIR__, file), force=true)
10-
end
11-
end
7+
rm("plotlylight_artifacts.tar.gz", force=true)
8+
dir = mkpath(joinpath(@__DIR__, "plotly_artifacts"))
129

1310
#-----------------------------------------------------------------------------# Templates
1411
# Need to install plotly.py in order to get themes because they are generated in python
15-
# run(`conda create -n conda_jl python conda`)
16-
# ENV["CONDA_JL_HOME"] = "/opt/homebrew/Caskroom/miniconda/base/envs/conda_jl"
17-
# Pkg.build("Conda")
18-
# using Conda
19-
# Conda.add("plotly")
20-
21-
dir = "/opt/homebrew/Caskroom/miniconda/base/envs/conda_jl/pkgs"
22-
templates = joinpath(dir, filter(x -> startswith(x, "plotly"), readdir(dir))[1], "site-packages/plotly/package_data/templates")
23-
24-
25-
run(`gzip $(Tar.create(templates, joinpath(@__DIR__, "templates.tar")))`)
26-
12+
run(`conda env remove -n _plotly_artifacts`) # start from scratch
13+
run(`conda create -n _plotly_artifacts -y`) # create env
14+
run(`conda install -y plotly -n _plotly_artifacts`)
15+
16+
# get path of `_plotly_artifacts` env
17+
io = IOBuffer()
18+
# run(pipeline(`conda info --json`, stdout=io))
19+
run(pipeline(`conda list -n _plotly_artifacts --json`; stdout=io))
20+
pkgs = JSON3.read(String(take!(io)))
21+
metadata = only(filter(x -> x.name == "plotly", pkgs))
22+
template_dir = "/opt/homebrew/Caskroom/miniconda/base/pkgs/$(metadata.dist_name)/lib/python3.10/site-packages/plotly/package_data/templates/"
23+
for file in readdir(template_dir)
24+
cp(joinpath(template_dir, file), joinpath(dir, file))
25+
end
2726

28-
#-----------------------------------------------------------------------------# Plotly.js
29-
url = "https://cdn.plot.ly/plotly-2.14.0.min.js"
27+
#-----------------------------------------------------------------------------# plotly.min.js
28+
url = "https://cdn.plot.ly/plotly-2.16.1.min.js"
3029
file = basename(url)
31-
dir = mkpath(joinpath(@__DIR__, "plotlyjs"))
3230
Downloads.download(url, joinpath(dir, file))
3331

34-
run(`gzip $(Tar.create(dir, joinpath(@__DIR__, "plotly.tar")))`)
32+
#-----------------------------------------------------------------------------# schema
33+
schema_url = "https://api.plot.ly/v2/plot-schema?format=json&sha1=%27%27"
34+
Downloads.download(schema_url, joinpath(dir, "schema.json"))
35+
36+
#-----------------------------------------------------------------------------# tar it up
37+
run(`gzip $(Tar.create(dir, joinpath(@__DIR__, "plotly_artifacts.tar")))`)
3538

3639
#-----------------------------------------------------------------------------# upload
3740
try
3841
artifacts_today = "artifacts_$(today())"
3942

40-
run(`gh release create $artifacts_today $(joinpath(@__DIR__, "templates.tar.gz")) $(joinpath(@__DIR__, "plotly.tar.gz")) --title $artifacts_today --notes ""`)
43+
run(`gh release create $artifacts_today $(joinpath(@__DIR__, "plotly_artifacts.tar.gz")) --title $artifacts_today --notes ""`)
4144

4245
@info "Sleeping so artifacts are ready on GitHub..."
4346
sleep(10)
4447
add_artifact!(
4548
"Artifacts.toml",
46-
"plotly.min.js",
47-
"https://github.com/joshday/PlotlyLight.jl/releases/download/$artifacts_today/plotly.tar.gz",
48-
force=true,
49-
)
50-
add_artifact!(
51-
"Artifacts.toml",
52-
"plotly_templates",
53-
"https://github.com/joshday/PlotlyLight.jl/releases/download/$artifacts_today/templates.tar.gz",
49+
"plotlylight",
50+
"https://github.com/joshday/PlotlyLight.jl/releases/download/$artifacts_today/plotly_artifacts.tar.gz",
5451
force=true,
5552
)
5653
catch ex

src/PlotlyLight.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ using Artifacts
99

1010
export Plot, Config, collectrows
1111

12-
const cdn_url = "https://cdn.plot.ly/plotly-2.14.0.min.js"
13-
const plotlyjs = joinpath(artifact"plotly.min.js", basename(cdn_url))
12+
const cdn_url = "https://cdn.plot.ly/plotly-2.16.1.min.js"
13+
const plotlyjs = joinpath(artifact"plotlylight", basename(cdn_url))
14+
const schema = open(io -> JSON3.read(io), joinpath(artifact"plotlylight", "schema.json"))
1415
const templates_dir = artifact"plotly_templates"
1516
const templates = map(x -> replace(x, ".json" => ""), readdir(templates_dir))
1617

0 commit comments

Comments
 (0)