Comments (6)
Well. I'll think about it a little more.
There are 2 options
- I will include it in one of the future PRs (however, the General approach of plotly is that the interface should be as simple as possible and close to what is available in other languages)
- I will soon start writing a package like
DashHelpers
orDashMeta
, which will contain all sorts of utilities and macros for advanced work withDash
Most likely there will be a second option. Among other things, it will allow us to write things specific and convenient for Julia without regard to the compatibility of interfaces and documentation with Python and without reviews from the Plotly Dash team. In other words, it will be a package for that the Julia community responsible, not Plotly Dash
from dash.jl.
@alexcjohnson Yes, of course it is possible and not difficult. The only issue that confused me was the complexity of the interface for beginners.
from dash.jl.
Hi @akdor1154!
start_server
is the internal lambda function and it has never been public. You can use make_handler
to get an HTTP-compatible handler and then use HTTP.serve
to manually start the server in synchronous or asynchronous mode.
handler = make_handler(app);
@async HTTP.serve(handler, host, port)
In this case, to enable debugging mode, you can use enable_dev_tools!(app; debug, dev_tools_ui, ...)
Just look at how run_server works (https://github.com/plotly/Dash.jl/blob/dev/src/server.jl). make_handler
is part of a public API of Dash. In addition to asynchronous server startup, you can use it to build your own handler - for example, to add authorization or any other pre/post processing.
from dash.jl.
yep for sure. It's just that it's really useful to have a non-blocking version of run_server readily available, and start_server fulfils this perfectly (I've copy/pasted it out of Dash.jl to use in my start script). If you want to keep it private then that's fine I guess, but from a user perspective it would be helpful to have access to this.
For some context, this is what I've built with it:
# this is the bit I am trying to avoid reimplementing :)
module StartServer
import Dash
import HTTP
import Sockets
import Sockets: IPAddr, TCPServer
struct CurrentServer
server :: TCPServer
task :: Task
end
export CurrentServer
get_inetaddr(host::String, port::Integer) = Sockets.InetAddr(parse(IPAddr, host), port)
get_inetaddr(host::IPAddr, port::Integer) = Sockets.InetAddr(host, port)
function start_server(app::Dash.DashApp, host::Union{String, IPAddr} = Sockets.localhost, port::Integer = 8080) :: CurrentServer
handler = Dash.make_handler(app);
server = Sockets.listen(get_inetaddr(host, port))
task = @async HTTP.serve(handler, host, port; server = server)
@info string("Running on http://", host, ":", port)
return CurrentServer(server, task)
end
export start_server
end
# once the above is available then you can use it with Revise like
using Revise
import MyDashProject
module RunRepl
import ..MyDashProject
using ..StartServer
struct ServerState
currentServer::CurrentServer
end
export ServerState
function reload(state::Union{ServerState, Nothing}) :: ServerState
if state !== nothing
println("closing server...")
close(state.currentServer.server)
end
app = MyDashProject.buildApp()
newServer = RunRepl.start_server(app)
return ServerState(newServer)
end
export reload
end
function reload()
global serverState
Revise.revise()
serverState = RunRepl.reload(serverState)
return nothing
end
serverState = RunRepl.reload(nothing)
And do your dev work with a full REPL available by calling
julia --project=@. -i ./runRepl.jl
>reload()
runs Revise() and restarts your server on demand, quicker than builtin hot reload.
from dash.jl.
Sure. I might submit a quick PR tomorrow (sorry, dinner time :)) with the sort of thing I'd be after, but with no expectation of it being merged.
Cheers, and thanks for your work on this.
from dash.jl.
@akdor1154 This is a great suggestion; in Dash for R we provide the functionality you're asking about via run_server
. All that's required is to pass block = FALSE
.
@alexcjohnson Would it make sense to add non-blocking support to the Dash.jl roadmap, controlled via an argument to run_server
here as well?
from dash.jl.
Related Issues (20)
- Can Plotly Dash animations display buttons and sliders? HOT 6
- ArgumentError: Distributed.var doesn't have a defined StructTypes.StructType HOT 2
- 3D plot combining line and surface HOT 2
- Feature: Type -> Component mapping with weakdeps
- Using python libs in Dash.jl
- Write (python) dash vs Dash.jl feature comparison table HOT 4
- markdown with latex support HOT 1
- Warning during precompilation HOT 1
- Advanced checklist HOT 1
- Support background callbacks HOT 1
- Support figures generated by Plots.jl with a PlotlyBackend HOT 1
- UndefVarError for html components HOT 3
- Try Dash.jl with React 18
- Move `DashBase.to_dash` type-piracy definitions to DashBase repo HOT 2
- Experiment with `PrecompileTools.jl` to speed up TTFX
- Test failing with Julia 1.10.0-beta3 HOT 2
- Circular callbacks with multiple callbacks seem to work HOT 2
- Accept app root path as kwarg to `dash` method? HOT 5
- Why has the DashCoreResources repo been archived? HOT 9
- Editable Tables examples not working HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dash.jl.