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

feat: allow root path to run the app on /path #14972

Merged
merged 24 commits into from Oct 7, 2022
Merged

feat: allow root path to run the app on /path #14972

merged 24 commits into from Oct 7, 2022

Conversation

pritamsoni-hsr
Copy link
Contributor

@pritamsoni-hsr pritamsoni-hsr commented Oct 2, 2022

What does this PR do?

allow apps to be served from a custom path when running app behind a proxy.

by default apps are served from https://<app_id>.litng-ai-03.litng.ai, this PR adds a feature so apps can be served from 'https://mydomain.com/<my_app>'.

if you want to build custom UI, make sure all internal links are prefixed with window.app_prefix

  • this works only behind a proxy and not on the api_id.litng-ai-03.litng.ai/<custom_path> and this is because of uvicorn's root path param.

Limitations

relative links inside the app will break, so user should use window.app_prefix in their JS, there is no warning around that atm.

breaking changes

none

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or minor internal changes/refactors)

PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing, make sure you have read the review guidelines. In short, see the following bullet-list:

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

Did you have fun?

Make sure you had fun coding 🙃

@github-actions github-actions bot added the app Generic label for Lightning App package label Oct 2, 2022
@Borda Borda added the priority: 0 High priority task label Oct 5, 2022
@Borda Borda added this to the app:0.6.x milestone Oct 5, 2022
@Borda Borda mentioned this pull request Oct 5, 2022
12 tasks
@kaushikb11 kaushikb11 changed the title feat: add base path feat: add root path Oct 6, 2022
@pritamsoni-hsr pritamsoni-hsr marked this pull request as ready for review October 6, 2022 14:06
@pritamsoni-hsr pritamsoni-hsr marked this pull request as draft October 6, 2022 14:06
@pritamsoni-hsr pritamsoni-hsr changed the title feat: add root path feat: allow root path to run the app on /path Oct 6, 2022
@hhsecond
Copy link
Contributor

hhsecond commented Oct 6, 2022

relative links inside the app will break, so user should use window.app_prefix in their JS, there is no warning around that atm.

Can this be updated in the docs?

@kaushikb11 kaushikb11 marked this pull request as ready for review October 6, 2022 14:17
Copy link
Contributor

@hhsecond hhsecond left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor nits and clarification on the docs

src/lightning_app/core/app.py Show resolved Hide resolved
src/lightning_app/utilities/frontend.py Outdated Show resolved Hide resolved
src/lightning_app/utilities/frontend.py Outdated Show resolved Hide resolved
Copy link
Contributor

@tchaton tchaton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
@pritamsoni-hsr Do you think it would make sense to extract those metadata directly into a private file under a .lightning folder?

@Borda
Copy link
Member

Borda commented Oct 6, 2022

Do you think it would make sense to extract those metadata directly into a private file under a .lightning folder?

let's leave it s separate feature :)

src/lightning_app/core/app.py Show resolved Hide resolved
src/lightning_app/core/app.py Show resolved Hide resolved
src/lightning_app/frontend/web.py Outdated Show resolved Hide resolved
"""Start the process that serves the UI at the given hostname and port number.

Arguments:
host: The hostname where the UI will be served. This gets determined by the dispatcher (e.g., cloud),
but defaults to localhost when running locally.
port: The port number where the UI will be served. This gets determined by the dispatcher, which by default
chooses any free port when running locally.

root_path: root_path for the server if app in exposed via a proxy at `/<root_path>`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
root_path: root_path for the server if app in exposed via a proxy at `/<root_path>`
root_path: root_path for the server if app in exposed via a proxy at `/<root_path>`

You need to leave an empty line

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we include an example like https://domain.com/<root_path>/my_page to visualize what it means.

tests/tests_app/frontend/test_web.py Outdated Show resolved Hide resolved
@mergify mergify bot added the ready PRs ready to be merged label Oct 7, 2022
@Borda Borda enabled auto-merge (squash) October 7, 2022 13:07
@pritamsoni-hsr
Copy link
Contributor Author

@tchaton we could, but I think maintaining it in the app is easiest, we can later serialize and deserialize .lightning file

@Borda Borda merged commit 8008055 into Lightning-AI:master Oct 7, 2022
Borda pushed a commit that referenced this pull request Oct 7, 2022
* feat: add base path
* uvicorn fix arg
* Add prefix
* update with base_path fix
* replace base path with root path
* Apply suggestions from code review

Co-authored-by: Kaushik B <45285388+kaushikb11@users.noreply.github.com>
Co-authored-by: Kaushik B <kaushikbokka@gmail.com>
Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
Co-authored-by: Adrian Wälchli <aedu.waelchli@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
(cherry picked from commit 8008055)
lexierule pushed a commit that referenced this pull request Oct 7, 2022
* feat: add base path
* uvicorn fix arg
* Add prefix
* update with base_path fix
* replace base path with root path
* Apply suggestions from code review

Co-authored-by: Kaushik B <45285388+kaushikb11@users.noreply.github.com>
Co-authored-by: Kaushik B <kaushikbokka@gmail.com>
Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
Co-authored-by: Adrian Wälchli <aedu.waelchli@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
(cherry picked from commit 8008055)
nicolai86 pushed a commit that referenced this pull request Oct 13, 2022
* feat: add base path
* uvicorn fix arg
* Add prefix
* update with base_path fix
* replace base path with root path
* Apply suggestions from code review

Co-authored-by: Kaushik B <45285388+kaushikb11@users.noreply.github.com>
Co-authored-by: Kaushik B <kaushikbokka@gmail.com>
Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
Co-authored-by: Adrian Wälchli <aedu.waelchli@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app Generic label for Lightning App package priority: 0 High priority task ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants