Skip to content

Commit fece921

Browse files
authored
Merge pull request #212 from plotly/nextgen-gen_resources
Next-generation `gen_resources`
2 parents 2f8bc22 + ff135bd commit fece921

File tree

10 files changed

+124
-38
lines changed

10 files changed

+124
-38
lines changed

Artifacts.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[dash_resources]
2-
git-tree-sha1 = "c857e355d2c21dfc458fb315371431dda2506109"
2+
git-tree-sha1 = "cf73063fdfc374bc98925f87ac967051cdee66e5"
33

44
[[dash_resources.download]]
5-
sha256 = "4ff3910a8ff1f5420784397cfc6ad80341bbe03f1010eab38dcb9b8ce2423310"
6-
url = "https://github.com/plotly/DashCoreResources/releases/download/v2.0.0+0/DashCoreResources.v2.0.0.tar.gz"
5+
sha256 = "c0fda20e816034b8f97f779af8b3081d3578164649d9ff6c21a8146d4af52d96"
6+
url = "https://github.com/plotly/DashCoreResources/releases/download/v2.10.2+0/DashCoreResources.v2.10.2.tar.gz"

gen_resources/Project.toml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
55
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
66
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
77
LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433"
8+
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
89
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
910
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
1011
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"

gen_resources/README.md

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Generate Dash.jl artifacts
2+
3+
Dash.jl uses Julia
4+
[Artifacts](https://docs.julialang.org/en/v1/stdlib/Artifacts/) to load
5+
front-end resources that Dash.jl shares with the python version of
6+
[dash](https://github.com/plotly/dash).
7+
8+
The [Artifacts.toml](../Artifacts.toml) file lists the location of the
9+
publicly-available tarball containing all the required resources.
10+
11+
The tarballs are hosted on the
12+
[DashCoreResources](https://github.com/plotly/DashCoreResources) repo, under
13+
_Releases_. They are generated and deployed using the `generate.jl` script in
14+
this directory.
15+
16+
## How to run `generate.jl` ?
17+
18+
### Step 0: get push rights to `DashCoreResources`
19+
20+
### Step 1: get GitHub personal access token
21+
22+
See [GitHub docs](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token)
23+
for more info.
24+
25+
If using a fine-grained token, make sure to enable _Read and Write access to code_.
26+
27+
### Step 2: expose your token into your shell
28+
29+
```sh
30+
# for example:
31+
export GITHUB_TOKEN="<your GitHub personal access token>"
32+
```
33+
34+
### Step 3: run `generate.jl`
35+
36+
```sh
37+
cd Dash.jl/gen_resources
38+
39+
# install `generate.jl` deps
40+
julia --project -e 'import Pkg; Pkg.instantiate()'
41+
42+
# generate `gen_resources/build/deploy/` content,
43+
# but do not deploy!
44+
julia --project generate.jl
45+
46+
# if everything looks fine,
47+
# generate `gen_resources/build/deploy/` content (again) and
48+
# deploy to the `DashCoreResource` releases with:
49+
julia --project generate.jl --deploy
50+
```
51+
52+
#### If `generate.jl` errors
53+
54+
<details>
55+
<summary>with a PyError / PyImport error</summary>
56+
57+
that is an error like:
58+
59+
```sh
60+
ERROR: LoadError: PyError (PyImport_ImportModule
61+
62+
The Python package dash could not be imported by pyimport. Usually this means
63+
that you did not install dash in the Python version being used by PyCall.
64+
65+
PyCall is currently configured to use the Python version at:
66+
67+
/usr/bin/python3
68+
```
69+
70+
try
71+
72+
```jl
73+
using PyCall
74+
ENV["PYTHON"] = joinpath(homedir(), ".julia/conda/3/x86_64/bin")
75+
import Pkg
76+
Pkg.build("PyCall")
77+
# check that it matches with
78+
PyCall.pyprogramname
79+
```
80+
81+
and then re-run `generate.jl`.
82+
83+
</details>
84+
85+
### Step 4: Commit the changes to `Artifacts.toml`
86+
87+
and push to [plotly/Dash.jl](https://github.com/plotly/Dash.jl)
88+
(preferably on a new branch) to get a CI test run started.

gen_resources/Sources.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
repo = "plotly/DashCoreResources"
33
[dash]
44
url = "https://github.com/plotly/dash.git"
5-
tag = "v2.0.0"
5+
tag = "v2.10.2"
66
[dash_renderer]
7-
module = "dash_renderer"
7+
module = "dash._dash_renderer"
88
resources_path = "."
99
[components]
1010
[components.dash_html_components]

gen_resources/generator/dash.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
install_dash(url, tag)
33
4-
Clone python dash into `dash` folder and install (reinstall) it to current python enviroment
4+
Clone python dash into `dash` folder and install (reinstall) it to current python environment
55
"""
66
function install_dash(url, tag)
77
Conda.pip_interop(true)

gen_resources/generator/github.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const _github_auth = Ref{GitHub.Authorization}()
1010
function github_auth(;allow_anonymous::Bool=true)
1111
if !isassigned(_github_auth) || !allow_anonymous && isa(_github_auth[], GitHub.AnonymousAuth)
1212
# If the user is feeding us a GITHUB_TOKEN token, use it!
13-
if length(get(ENV, "GITHUB_TOKEN", "")) == 40
13+
if length(get(ENV, "GITHUB_TOKEN", "")) >= 40
1414
_github_auth[] = GitHub.authenticate(ENV["GITHUB_TOKEN"])
1515
else
1616
if allow_anonymous

src/init/resources.jl

+14-18
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,28 @@ dash_module_resource(meta) = Resource(
2323
async = haskey(meta, "async") ? string(meta["async"]) : nothing
2424
)
2525

26-
dash_module_resource_pkg(meta; resource_path, version) = ResourcePkg(
27-
meta["namespace"],
28-
resource_path, version = version,
29-
dash_module_resource.(meta["resources"])
30-
)
31-
3226
function setup_renderer_resources()
3327
renderer_meta = _metadata.dash_renderer
3428
renderer_resource_path = joinpath(artifact"dash_resources", "dash_renderer_deps")
29+
renderer_version = renderer_meta["version"]
3530
DashBase.main_registry().dash_dependency = (
3631
dev = ResourcePkg(
3732
"dash_renderer",
38-
renderer_resource_path, version = renderer_meta["version"],
33+
renderer_resource_path, version = renderer_version,
3934
dash_dependency_resource.(renderer_meta["js_dist_dependencies"]["dev"])
4035
),
4136
prod = ResourcePkg(
4237
"dash_renderer",
43-
renderer_resource_path, version = renderer_meta["version"],
38+
renderer_resource_path, version = renderer_version,
4439
dash_dependency_resource.(renderer_meta["js_dist_dependencies"]["prod"])
4540
)
4641
)
47-
48-
DashBase.main_registry().dash_renderer = dash_module_resource_pkg(
49-
renderer_meta["deps"][1],
50-
resource_path = renderer_resource_path,
51-
version = renderer_meta["version"]
52-
)
42+
renderer_renderer_meta = renderer_meta["deps"][1]
43+
DashBase.main_registry().dash_renderer = ResourcePkg(
44+
"dash_renderer",
45+
renderer_resource_path, version = renderer_version,
46+
dash_module_resource.(renderer_renderer_meta["resources"])
47+
)
5348
end
5449

5550
function load_all_metadata()
@@ -72,10 +67,11 @@ function setup_dash_resources()
7267
version = meta["version"]
7368
for dep in meta["deps"]
7469
DashBase.register_package(
75-
dash_module_resource_pkg(
76-
dep,
77-
resource_path = path,
78-
version = version
70+
ResourcePkg(
71+
dep["namespace"],
72+
path,
73+
version = version,
74+
dash_module_resource.(dep["resources"])
7975
)
8076
)
8177
end

test/integration/clientside/test_clientside.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ def test_jlclsd004_clientside_multiple_outputs(dashjl):
9595
]:
9696
dashjl.wait_for_text_to_equal(selector, expected, timeout=10)
9797

98-
def test_jlclsd005_clientside_fails_when_returning_a_promise(dashjl):
98+
def test_jlclsd005_clientside_when_returning_a_promise(dashjl):
9999
fp = jl_test_file_path("jlclsd005_clientside_fails_when_returning_a_promise.jl")
100100
dashjl.start_server(fp)
101101

102102
dashjl.wait_for_text_to_equal("#input", "hello", timeout=10)
103103
dashjl.wait_for_text_to_equal("#side-effect", "side effect")
104-
dashjl.wait_for_text_to_equal("#output", "output")
104+
dashjl.wait_for_text_to_equal("#output", "foo")
105105

106106
def test_jlclsd006_PreventUpdate(dashjl):
107107
fp = jl_test_file_path("jlclsd006_PreventUpdate.jl")

test/integration/devtools/jl_props_check/jldvpc001_prop_check_errors_with_path.jl

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ test_cases = Dict(
1313
"component"=> dcc_checklist,
1414
"props"=> (options = [Dict("label" => "hello")], value = ["test"]),
1515
),
16-
"invalid-nested-prop"=> Dict(
17-
"fail"=> true,
18-
"name"=> "invalid nested prop",
19-
"component"=> dcc_checklist,
20-
"props"=> (options = [Dict("label"=> "hello", "value"=> true)], value = ["test"]),
21-
),
2216
"invalid-arrayOf"=> Dict(
2317
"fail"=> true,
2418
"name"=> "invalid arrayOf",
@@ -73,6 +67,12 @@ test_cases = Dict(
7367
"component"=> html_div,
7468
"props"=> (children = Dict("hello" => "world"),),
7569
),
70+
"allow-nested-prop"=> Dict(
71+
"fail"=> false,
72+
"name"=> "allow nested prop",
73+
"component"=> dcc_checklist,
74+
"props"=> (options = [Dict("label"=> "hello", "value"=> true)], value = ["test"]),
75+
),
7676
"allow-null-2"=> Dict(
7777
"fail"=> false,
7878
"name"=> "allow null as value",

test/integration/devtools/test_props_check.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ def jl_test_file_path(filename):
1616
"fail": True,
1717
"name": 'missing required "value" inside options',
1818
},
19-
"invalid-nested-prop": {
20-
"fail": True,
21-
"name": "invalid nested prop",
22-
},
2319
"invalid-arrayOf": {
2420
"fail": True,
2521
"name": "invalid arrayOf",
@@ -56,6 +52,10 @@ def jl_test_file_path(filename):
5652
"fail": True,
5753
"name": "returning a dictionary",
5854
},
55+
"allow-nested-prop": {
56+
"fail": False,
57+
"name": "allow nested prop",
58+
},
5959
"allow-null-2": {
6060
"fail": False,
6161
"name": "allow null as value",
@@ -99,6 +99,7 @@ def test_jldvpc001_prop_check_errors_with_path(dashjl):
9999

100100
if test_cases[tc]["fail"]:
101101
dashjl.wait_for_element(".test-devtools-error-toggle", timeout=10).click()
102-
dashjl.wait_for_element(".dash-error-card")
102+
dashjl.wait_for_element(".dash-fe-error__info")
103103
else:
104104
dashjl.wait_for_element("#new-component", timeout=2)
105+
dashjl.wait_for_no_elements(".test-devtools-error-toggle")

0 commit comments

Comments
 (0)