Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hot reloading support in Dash.jl #20

Closed
00krishna opened this issue May 9, 2020 · 10 comments · Fixed by #25
Closed

Hot reloading support in Dash.jl #20

00krishna opened this issue May 9, 2020 · 10 comments · Fixed by #25

Comments

@00krishna
Copy link

Hey folks, I am just trying to start using Plotly Dash, just to get a feel for it. So I am just logging issues you probably know about, but just in case others run into the same issues they can reference the issues.

I notice that the hot reloading does not seem to work. When I run:

run_server(app, "0.0.0.0", 8080, debug=true)

the code does not seem to reload upon update to the original file. That might be related to the recompilation that julia usually does. Is there some planned workaround for this?

Thanks again for all the work you are all doing.

@waralex
Copy link
Collaborator

waralex commented May 9, 2020

Hi
What you are now seeing in the master is basically my Dashboards.jl package that provided only basic Dash functionality. Now there is a lot of work on bringing its functionality to the level of Dash in the dev branch.
For example, right now I'm working on the hot reload. But in addition to it, there are many other things that are in Dash that are not yet in Dash.jl. Please be patient, we will definitely bring Dash.jl to the level of other products from the PlotlyDash ecosystem.

@00krishna
Copy link
Author

Thanks @waralex I totally understand. I am new to even python Dash, so I have a parallel process of pushing my julia code through pyjulia and using python Dash, versus native Julia dash. So that is cool. I will keep playing around with the Julia dash, just to see how it is working. Let me know if I can be of any assistance.

@rpkyle rpkyle changed the title hot reloading does not seem to work yet Hot reloading support in Dash.jl May 17, 2020
@rpkyle
Copy link
Contributor

rpkyle commented May 18, 2020

Dash for Python's "hot-reloading" feature is described in plotly/dash#66, plotly/dash#362, and plotly/dash-renderer#73.

Supporting this as in the Python and R implementations would require

  • creating a hash at app initialization, and regenerating it on file change
  • adding a route to serve the hash
  • front-end hot reloading (including ability to refresh layout only when CSS updates occur, as well as formatting the JSON response with a modified file manifest)
  • back-end hot reloading (reload the app, restart HTTP.jl)
  • adding parameters for the dev tools UI: dev_tools_hot_reload, dev_tools_hot_reload_interval, dev_tools_hot_reload_watch_interval, dev_tools_silence_routes_logging
  • integration tests for "hard" (restart backend app, reload frontend) and "soft" (CSS only = layout refresh) reloading as in Python and R

On the Python side, we use the Flask debug reloader to reset the hash. We would need to find a comparable approach using HTTP.jl instead.

@waralex waralex linked a pull request May 19, 2020 that will close this issue
7 tasks
@00krishna
Copy link
Author

@waralex Alexandr, so should the hot-reload feature work now? Seems to indicate that the PR was merged.

@waralex
Copy link
Collaborator

waralex commented May 23, 2020

@00krishna Yes, it works in dev branch.

@00krishna
Copy link
Author

Oh excellent. Nice to know. I can give it a try. If I have any issues, I can always flip back to master branch.

@waralex
Copy link
Collaborator

waralex commented May 23, 2020

@00krishna dev is already very different from master

@MLackner
Copy link

Maybe this is a stupid question, but how does the hot reloading work practically?
I'm on dev branch and I have my app defined as a module like this:

module MyApp

using Dash
using DashHtmlComponents
using DashCoreComponents

app = dash(external_stylesheets = ["https://codepen.io/chriddyp/pen/bWLwgP.css"])

app.layout = html_div() do
    dcc_input(id = "my-id", value="initial value", type = "text"),
    html_div(id = "my-div")        
end

callback!(app, Output("my-div", "children"), Input("my-id", "value")) do input_value
    "You've entered $(input_value)"
end

end

I tried the following:

(1.3) pkg> activate .
Activating environment at `~/Documents/Julia/MyApp/Project.toml`
julia> using Revise
julia> using MyApp
julia> run_server(MyApp.app, "127.0.0.1", 8080; debug=true)
┌ Warning: Hot reloading is disabled for interactive sessions. Please run your app using julia from the command line to take advantage of this feature.
└ @ Dash ~/.julia/packages/Dash/b6VP7/src/Dash.jl:142
[ Info: Running on http://127.0.0.1:8080

So I put the above code in a file called runserver.jl and from the command line I did

julia --startup-file=no runserver.jl

where I get the following output:

Activating environment at `~/Documents/Julia/MyApp/Project.toml`
Activating environment at `~/Documents/Julia/MyApp/Project.toml`
[ Info: Running on http://127.0.0.1:8080

If I now change the code in my module nothing happens, even if I refresh the page in my browser.
It would be awesome if you guys could give me a hint.

@waralex
Copy link
Collaborator

waralex commented Jun 19, 2020

Hi @MLackner
Yes, this may be my mistake - autoreload will not work in this form. Autoreload monitors the executed file and all files included in it (recursively) via include. However, it does not track changes in external packages connected via using or import. If you change runserver.jl, then a restart should occur

@rpkyle
Copy link
Contributor

rpkyle commented Sep 24, 2020

This feature was added in #25, and is available now in the version released to the Julia Registry. Closing this issue as resolved.

@rpkyle rpkyle closed this as completed Sep 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants