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

Accept app root path as kwarg to dash method? #232

Open
tanmaykm opened this issue Nov 30, 2023 · 5 comments · May be fixed by #233
Open

Accept app root path as kwarg to dash method? #232

tanmaykm opened this issue Nov 30, 2023 · 5 comments · May be fixed by #233

Comments

@tanmaykm
Copy link

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.

tanmaykm added a commit to tanmaykm/Dash.jl that referenced this issue Nov 30, 2023
Allow the app root path to be specified explicitly for the `dash()` method. The default is `app_root_path()` and does not break compatibilty.

fixes: plotly#232
@tanmaykm tanmaykm linked a pull request Nov 30, 2023 that will close this issue
@etpinard
Copy link
Collaborator

etpinard commented Nov 30, 2023

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

@tanmaykm
Copy link
Author

tanmaykm commented Dec 1, 2023

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.

@etpinard
Copy link
Collaborator

etpinard commented Dec 8, 2023

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.


@tanmaykm
Copy link
Author

tanmaykm commented Dec 9, 2023

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.

@etpinard
Copy link
Collaborator

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

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.

2 participants