-
Notifications
You must be signed in to change notification settings - Fork 77
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
Draft: Generic "Run app" framework #4616
Conversation
One more thing. The approach of finding a free port and passing it as a command-line arg doesn't work if the user hardcodes the port in their application, which is possible in some of these frameworks. In those cases it would have still been possible to determine the port by scraping the terminal. However, I don't think that would be helpful for Workbench, where I think we have to configure the app framework to use a URL prefix that depends on the port. Determining the port from the terminal would be too late. |
I don't feel super strongly about this, but if it is equal convenience/difficulty in either location, I would rather have it in Positron core. I imagine it would be more convenient there (especially if UI elements change later or anything like that). |
I took a look at what is here so far and I tend to think that it is better not to build out the application runner infrastructure into the Positron core without a motivating example, given that extensions can already provide tasks or run things in the terminal. Maybe we can outline what we would do instead:
There are a few other bits of this PR that we may still need to add to Positron itself, like finding a port. |
What's here looks good to me. I haven't had time to fully consider the solution space but I like this. My vote would be keeping as much in core as possible to make it as easy as possible for new languages to be added. That being said this could be a massive instance of premature optimization so if the workload/ complexity is much less to put that logic into language packs then I will defer that decision to the implementer. |
What I'd suggest is moving this logic into its own extension that exposes an API that other extensions can use. That will allow you to centralize the logic around finding ports, starting terminals, etc. without making a bunch of changes to the core. You can see the Jupyter Adapter for an example of how this is done:
|
adding some context on ports, from an offline discussion with @seeM possible ways to find if users have set ports themselves:
|
Thank you all for the feedback! I'm closing this and will work on a separate PR where this lives in a built-in extension with an exposed API. I've also asked the Workbench team for feedback on how to design the API (or any other necessary changes) to improve Workbench integration and will factor that in, either to the next PR or future work. |
The purpose of this draft PR is to gather feedback about a generic approach to support a bunch of Python app frameworks. Feedback about code details isn't needed at this stage. You should be able to open a Shiny, Dash, Gradio, Streamlit, Flask, or FastAPI app and run it with the corresponding command. I haven't hooked up
when
clauses to only show the relevant command.The idea is to allow extensions to register "application runners", implementing a
getRunOptions
method that returns the terminal command and set of environment variables needed to run an application, given some required information. The implementation of therunApplication
method was adapted from the shiny-vscode extension.In hindsight, I think the "application runner" concept is unnecessary at this stage. It's already possible to do all of this in extension land (e.g. shiny-vscode). I'm now leaning toward moving all of the logic into the Python extension. That'd mean duplicating code across extensions for different language packs, but I don't think that's a problem.
Before I make any further changes, what do folks think?