Skip to content

Commit d3be0f2

Browse files
committed
Merge branch 'dev' into clientside_callbacks
2 parents 7d7faae + 92fd3e3 commit d3be0f2

File tree

7 files changed

+117
-10
lines changed

7 files changed

+117
-10
lines changed

CHANGELOG.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Change Log for Dash for Julia
2+
All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.
3+
4+
5+
6+
### [UNRELEASED]
7+
### Added
8+
- Support for hot reloading on application or asset changes [#25](https://github.com/plotly/Dash.jl/pull/25)
9+
- Asset serving of CSS, JavaScript, and other resources [#18](https://github.com/plotly/Dash.jl/pull/18)
10+
- Support for passing functions as layouts [#18](https://github.com/plotly/Dash.jl/pull/18)
11+
- Resource registry for component assets [#18](https://github.com/plotly/Dash.jl/pull/18)
12+
- Asynchronous component loading & fingerprinting component assets [#18](https://github.com/plotly/Dash.jl/pull/18)
13+
- Developer tools UI support [#18](https://github.com/plotly/Dash.jl/pull/18)
14+
- Dash environment variables are now supported [#18](https://github.com/plotly/Dash.jl/pull/18)
15+
- Index page/layout validation now performed [#18](https://github.com/plotly/Dash.jl/pull/18)
16+
- Support for `gzip` compression [#14](https://github.com/plotly/Dash.jl/pull/14)
17+
- Parity with core Dash API parameters [#12](https://github.com/plotly/Dash.jl/pull/12)
18+
- Integration tests are now supported, server startup message appears on app initialization [#21](https://github.com/plotly/Dash.jl/pull/21)
19+
20+
### Changed
21+
- Dash.jl now starts via `run_server` with `host` and `port` arguments [#2](https://github.com/plotly/Dash.jl/issues/2)
22+
- Defining layouts in Dash.jl now occurs similarly to Dash for Python/R [#1](https://github.com/plotly/Dash.jl/issues/1)
23+
24+
### Removed
25+
- `make_handler` no longer used to start Dash server [#2](https://github.com/plotly/Dash.jl/issues/2)
26+
- `layout_maker` has been removed [#18](https://github.com/plotly/Dash.jl/pull/18)
27+
- `layout_maker` is no longer called by the app developer to define the layout [#1](https://github.com/plotly/Dash.jl/issues/1)
28+
29+
### Fixed
30+
- Request headers are now properly specified [#28](https://github.com/plotly/Dash.jl/issues/28)
31+
- Unspecified `children` now passed as `nothing` rather than undefined [#27](https://github.com/plotly/Dash.jl/issues/27)

src/Dash.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ function run_server(app::DashApp, host = HTTP.Sockets.localhost, port = 8050;
136136
end
137137

138138
if get_devsetting(app, :hot_reload) && !is_hot_restart_available()
139-
@warn "hot restart is disabled for intereactive sessions"
139+
@warn "Hot reloading is disabled for interactive sessions. Please run your app using julia from the command line to take advantage of this feature."
140140
end
141141

142142
if get_devsetting(app, :hot_reload) && is_hot_restart_available()

src/app/dashapp.jl

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,56 @@ end
8686
get_index_string(app::DashApp) = app.component.index_string
8787

8888

89+
"""
90+
Activate the dev tools, called by `run_server`.
91+
92+
If a parameter can be set by an environment variable, that is listed as:
93+
env: `DASH_****`
94+
Values provided here take precedence over environment variables.
95+
96+
Available dev_tools environment variables:
97+
- `DASH_DEBUG`
98+
- `DASH_UI`
99+
- `DASH_PROPS_CHECK`
100+
- `DASH_SERVE_DEV_BUNDLES`
101+
- `DASH_HOT_RELOAD`
102+
- `DASH_HOT_RELOAD_INTERVAL`
103+
- `DASH_HOT_RELOAD_WATCH_INTERVAL`
104+
- `DASH_HOT_RELOAD_MAX_RETRY`
105+
- `DASH_SILENCE_ROUTES_LOGGING`
106+
- `DASH_PRUNE_ERRORS`
107+
108+
# Arguments
109+
110+
- `debug::Bool` - Enable/disable all the dev tools unless overridden by the
111+
arguments or environment variables. Default is ``true`` when
112+
``enable_dev_tools`` is called directly, and ``false`` when called
113+
via ``run_server``. env: ``DASH_DEBUG``.
114+
115+
- `dev_tools_ui::Bool` - Show the dev tools UI. env: ``DASH_UI``
116+
117+
- `dev_tools_props_check::Bool` - Validate the types and values of Dash
118+
component props. env: ``DASH_PROPS_CHECK``
119+
120+
- `dev_tools_serve_dev_bundles::Bool` - Serve the dev bundles. Production
121+
bundles do not necessarily include all the dev tools code.
122+
env: ``DASH_SERVE_DEV_BUNDLES``
123+
124+
- `dev_tools_hot_reload::Bool` - Activate hot reloading when app, assets,
125+
and component files change. env: ``DASH_HOT_RELOAD``
126+
127+
- `dev_tools_hot_reload_interval::Float64` - Interval in seconds for the
128+
client to request the reload hash. Default 3.
129+
env: ``DASH_HOT_RELOAD_INTERVAL``
130+
131+
- `dev_tools_hot_reload_watch_interval::Float64` - Interval in seconds for the
132+
server to check asset and component folders for changes.
133+
Default 0.5. env: ``DASH_HOT_RELOAD_WATCH_INTERVAL``
134+
135+
- `dev_tools_hot_reload_max_retry::Int` - Maximum number of failed reload
136+
hash requests before failing and displaying a pop up. Default 8.
137+
env: ``DASH_HOT_RELOAD_MAX_RETRY``
138+
"""
89139
function enable_dev_tools!(app::DashApp; debug = nothing,
90140
dev_tools_ui = nothing,
91141
dev_tools_props_check = nothing,
@@ -266,4 +316,4 @@ function dash(;
266316
)
267317
result = DashApp(app_root_path(), isinteractive(), config, index_string)
268318
return result
269-
end
319+
end

src/handler/handlers.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ end
1212
function process_dependencies(request::HTTP.Request, state::HandlerState)
1313
return HTTP.Response(
1414
200,
15-
["Content-Type", "application/json"],
15+
["Content-Type" => "application/json"],
1616
body = state.cache.dependencies_json
1717
)
1818
end
@@ -21,18 +21,17 @@ function process_index(request::HTTP.Request, state::HandlerState)
2121
get_cache(state).need_recache && rebuild_cache!(state)
2222
return HTTP.Response(
2323
200,
24-
["Content-Type", "text/html"],
24+
["Content-Type" => "text/html"],
2525
body = state.cache.index_string
2626
)
2727
end
2828

2929
layout_data(layout::Component) = layout
3030
layout_data(layout::Function) = layout()
3131
function process_layout(request::HTTP.Request, state::HandlerState)
32-
body =
3332
return HTTP.Response(
3433
200,
35-
["Content-Type", "application/json"],
34+
["Content-Type" => "application/json"],
3635
body = JSON2.write(layout_data(state.app.layout))
3736
)
3837
end
@@ -176,7 +175,7 @@ function process_reload_hash(request::HTTP.Request, state::HandlerState)
176175

177176
end
178177

179-
function start_reaload_poll(state::HandlerState)
178+
function start_reload_poll(state::HandlerState)
180179
folders = Set{String}()
181180
push!(folders, get_assets_path(state.app))
182181
push!(folders, state.registry.dash_renderer.path)
@@ -236,7 +235,7 @@ function make_handler(app::DashApp, registry::ResourcesRegistry; check_layout =
236235
HTTP.setheader(compile_request, "Accept-Encoding" => "gzip")
237236
HTTP.handle(handler, compile_request) #For handler precompilation
238237

239-
get_devsetting(app, :hot_reload) && start_reaload_poll(state)
238+
get_devsetting(app, :hot_reload) && start_reload_poll(state)
240239

241240
return handler
242241
end

src/utils/hot_restart.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ function is_hot_restart_available()
33
end
44
function hot_restart(func::Function; check_interval = 1., env_key = "IS_HOT_RELOADABLE", suppress_warn = false)
55
if !is_hot_restart_available()
6-
error("hot restart is disabled for intereactive sessions")
6+
error("Hot reloading is disabled for interactive sessions. Please run your app using julia from the command line to take advantage of this feature.")
77
end
88
app_path = abspath(Base.PROGRAM_FILE)
99
if get(ENV, env_key, "false") == "true"
@@ -31,4 +31,4 @@ function hot_restart(func::Function; check_interval = 1., env_key = "IS_HOT_RELO
3131
end
3232
end
3333
end
34-
end
34+
end
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Dash
2+
using DashHtmlComponents
3+
using DashCoreComponents
4+
5+
app = dash()
6+
app.layout = html_div(id="outer-div") do
7+
html_div("A div", id="first-inner-div"),
8+
html_br(),
9+
html_div("Another div", id="second-inner-div")
10+
end
11+
12+
run_server(app)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import pathlib
2+
import os.path
3+
import logging
4+
logger = logging.getLogger(__name__)
5+
6+
curr_path = pathlib.Path(__file__).parent.absolute()
7+
def jl_test_file_path(filename):
8+
return os.path.join(curr_path, "jl_default_children", filename)
9+
10+
def test_jlcmdc001_default_children(dashjl):
11+
fp = jl_test_file_path("jlcmdc001_default_children.jl")
12+
dashjl.start_server(fp)
13+
dashjl.wait_for_element_by_css_selector(
14+
"#first-inner-div", timeout=2
15+
)

0 commit comments

Comments
 (0)