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

Integrate Python web apps with Workbench #4769

Open
seeM opened this issue Sep 20, 2024 · 3 comments
Open

Integrate Python web apps with Workbench #4769

seeM opened this issue Sep 20, 2024 · 3 comments
Labels
area: workbench Issues related to Workbench category. enhancement New feature or request theme: app builder

Comments

@seeM
Copy link
Contributor

seeM commented Sep 20, 2024

Following on from #4662, we should update runApplication to detect if we're in Workbench, and if so, find a free port and corresponding proxied URL (possibly related to #4274) and pass them both to getTerminalOptions. Unfortunately, some application frameworks need the proxied URL to be configured as the "URL prefix"/"root path".

@seeM seeM added enhancement New feature or request area: workbench Issues related to Workbench category. theme: app builder labels Sep 20, 2024
@seeM seeM added this to the 2024.10.0 Pre-Release milestone Sep 20, 2024
@seeM seeM assigned seeM and unassigned seeM Sep 24, 2024
@sharon-wang
Copy link
Member

I ran a Streamlit app in Workbench and it's displaying in the Viewer successfully! It'd be nice if the proxied path was reflected in the Terminal output, but ctrl+clicking on the Local URL results in the URL getting resolved to the correct proxied path (the one shown at the top of the Viewer).

image

@sharon-wang
Copy link
Member

The Quarto preview Terminal output shows the proxied path in addition to the localhost URL:

image

The Quarto extension code that outputs "Browse at ": https://github.com/quarto-dev/quarto/blob/49abc46be3dbfd5cbd1eadf3d04cb4a7ac690b5c/apps/vscode/src/providers/preview/preview.ts#L532

@sharon-wang
Copy link
Member

Additional testing of Python web apps on Workbench: #4662 (comment)

  • Summary:
    • Working: Streamlit, Dash, Flask
    • Not working / partially working: Gradio (styles and images not loading from correct path), FastAPI (request is not proxied properly)

Just to see what would happen, I tried modifying the following to include a call to positron proxy to retrieve the proxied URI. It seemed to fix the issues with Gradio and Fastapi, but Streamlit and Dash stopped working. Flask still remained happy.

if (url) {
// Convert the url to an external URI.
const localBaseUri = vscode.Uri.parse(url.toString());
const localUri = options.urlPath ?
vscode.Uri.joinPath(localBaseUri, options.urlPath) : localBaseUri;
const externalUri = await vscode.env.asExternalUri(localUri);
// Open the server URL in the viewer pane.
positron.window.previewUrl(externalUri);
}

It seems like we're in this situation:

App Framework
👇 please provide proxy url, then I'll tell you the app url
👆 please provide app url, then I'll tell you the proxy url
Positron Proxy

@seeM is it possible to preconfigure the app url (host:port) and pass that information to Positron Proxy? I suspect that may involve a bunch of framework-specific handling which may not be preferred. I'll look into what we can do on the Positron Proxy side to provide a proxy url separately from setting up the proxied connection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: workbench Issues related to Workbench category. enhancement New feature or request theme: app builder
Projects
None yet
Development

No branches or pull requests

2 participants