plotly / Dash.jl

Dash for Julia - A Julia interface to the Dash ecosystem for creating analytic web applications in Julia. No JavaScript required.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Accept app root path as kwarg to `dash` method?

tanmaykm opened this issue · comments

Noticed that the dash method does not accept a keyword arg for the app root path, and instead calls the built in app_root_path() to determine that here:

result = DashApp(app_root_path(), isinteractive(), config, index_string)

I am facing an issue where my code layout and app invocation does not suit the heuristic the app_root_path() method uses. It would be useful if the dash method could accept a keyword arg for that.

I am facing an issue where my code layout and app invocation does not suit the heuristic the app_root_path() method uses.

Could you expand on that? Would you mind sharing a sketch of the file directory layout?


Have you tried playing around dash kwargs url_base_pathname, request_pathname_prefix and routes_pathname_prefix? From the ?dash docstring:

    •  url_base_pathname::String: A local URL prefix to use app-wide. Default nothing. Both requests_pathname_prefix and
       routes_pathname_prefix default to url_base_pathname. env: DASH_URL_BASE_PATHNAME

    •  requests_pathname_prefix::String: A local URL prefix for file requests. Defaults to url_base_pathname, and must end with
       routes_pathname_prefix env: DASH_REQUESTS_PATHNAME_PREFIX

    •  routes_pathname_prefix::String: A local URL prefix for JSON requests. Defaults to url_base_pathname, and must start and end
       with '/'. env: DASH_ROUTES_PATHNAME_PREFIX

Yes, I have tried playing with the available kwargs, but I didn't find anything suitable. The problem in my case arises because we include the Dash app into our application which has other things to run and starts with its own startup program file. The layout looks something like this:

├── dashapp
│   ├── assets
│   │   └── dashapp.css
│   ├── bin
│   │   └── main.jl
│   └── src
│       └── JuliaPackage.jl
└── launcher
    └── applaunch.jl

So applaunch.jl, among the other things it does, includes dashapp/bin/main.jl using julias include method. But since the process is started by invoking launcher/applaunch.jl the root path is resolved by app_root_path() to launcher. We would like to have a way to set it to dashapp instead so that it can locate and serve files relative to that.

Sorry for the delay.


Assuming you instantiate DashApp in dashapp/bin/main.jl, I think

app = dash(; assets_folder=joinpath(@__DIR__, "..", "assets")

should do the trick.


Thanks for responding. I had tried using joinpath(@__DIR__, "..", "assets") for assets folder earlier. The reason it did not work for us is that using @__DIR__ does not lend itself to relocating precompiled code and sysimages.

Ah I see. Maybe try using https://github.com/JuliaPackaging/RelocatableFolders.jl in this case?