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

Fix relative path handling for ragna panel app #280

Merged
merged 21 commits into from
Jan 22, 2024

Conversation

aktech
Copy link
Member

@aktech aktech commented Jan 17, 2024

  • Fixes relative paths for panel apps

This doesn't handles the FastAPI paths yet, have just added an optional environment variable: RAGNA_API_ROOT_PATH for specifying root path for FastAPI server.

Copy link
Member

@pmeier pmeier left a comment

Choose a reason for hiding this comment

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

Thanks Amit for the PR!

This doesn't handles the FastAPI paths yet

I assume you mean "this doesn't handle FastAPI paths automatically yet", correct? I think that is ok. I don't see how the API would be able to detect this in the first place.


I have one question for the JS redirects: it seems we are doing mostly relative redirects, which have the disadvantage that the developer needs to know exactly at which path they currently are. Is there a technical blocker from always doing absolute redirects?

ragna/deploy/_ui/app.py Outdated Show resolved Hide resolved
ragna/deploy/_api/core.py Outdated Show resolved Hide resolved
ragna/deploy/_ui/js_utils.py Outdated Show resolved Hide resolved
# so /foo/bar/car/auth becomes /foo/bar/car/
>>> redirect_script(remove="auth", append="/")
"""
js_script = preformat(
Copy link
Member

Choose a reason for hiding this comment

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

IIUC, the only reason we need the preformat with six str.replace is because we want to use str.format later and our original text might already have curly braces inside of it, correct? If so, wouldn't it be easier to rely on re.sub(r"\{\{\w+\}\}") or whatever other delimiters for the substitution you want to use?

Copy link
Member Author

Choose a reason for hiding this comment

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

So you mean without using str.format?

@pmeier
Copy link
Member

pmeier commented Jan 18, 2024

Does this PR resolve #275 or is there even more to the story?

@aktech
Copy link
Member Author

aktech commented Jan 22, 2024

I assume you mean "this doesn't handle FastAPI paths automatically yet", correct? I think that is ok. I don't see how the API would be able to detect this in the first place.

Yes, FastAPI would need a root api path, which I have added. If it needs more changes, then it's beyond the scope of this PR.

Does this PR resolve #275 or is there even more to the story?

Mostly, but I am not sure as I said I have not looked at the potential issues with FastAPI redirects. I want to keep the scope of this PR limited to panel redirects only. I'll create a separate PR for potential FastAPI changes if any. I added the root api path config option because it's anyway good to have and was an easy fix to potential redirect issues.

@nenb nenb self-requested a review January 22, 2024 19:23
Copy link
Contributor

@nenb nenb left a comment

Choose a reason for hiding this comment

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

@pmeier I'm approving this as I don't see any major issues and any potential minor issues can likely be addressed in a subsequent PR.

@nenb nenb merged commit 51fcda4 into Quansight:main Jan 22, 2024
10 checks passed
@aktech aktech deleted the relative-paths branch March 27, 2024 11:47
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 this pull request may close these issues.

3 participants