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

python: implement generic "Run app" button #4557

Closed
isabelizimm opened this issue Sep 3, 2024 · 1 comment
Closed

python: implement generic "Run app" button #4557

isabelizimm opened this issue Sep 3, 2024 · 1 comment

Comments

@isabelizimm
Copy link
Contributor

Once the Positron Python extension has determined a user is in an app, there should be a "Run App" option (perhaps with a "Debug App" option as well) in the play button. Clicking this button should call the appropriate command for the app framework in a new terminal instance.

Related to #4555 #3023 #3025 #3024 #3027

@isabelizimm isabelizimm added this to the 2024.10.0 Pre-Release milestone Sep 3, 2024
@seeM seeM self-assigned this Sep 4, 2024
seeM added a commit that referenced this issue Sep 23, 2024
This PR adds support for local Python application development for the
following frameworks:

* Streamlit
* Dash
* Gradio
* FastAPI
* Flask

This is facilitated by a new extension: `positron-run-app`.

Addresses #4557,
#4555, #3023, #3027, #3024.

https://github.com/user-attachments/assets/d72e5028-a8c9-4aab-b927-4413c4e74b24

### QA notes

1. Open an application developed using one of the supported frameworks.
2. Run the relevant "Python: Run X App in Terminal" command. It should
also be the default action if you click the run button in the editor
menu.
3. It should create a terminal named after the framework, and
automatically show the app in the Viewer pane once its ready.

Here are example apps for all of the supported frameworks:

#### Streamlit

```python
import streamlit as st
x = st.slider('x')
st.write(x, 'squared is', x * x)
```

#### Dash

```python
from dash import Dash, html
app = Dash()
app.layout = [html.Div(children='Hello World')]
if __name__ == '__main__':
    app.run(debug=True)
```

#### Gradio

```python
import gradio as gr
def image_classifier(inp):
    return {'cat': 0.3, 'dog': 0.7}
demo = gr.Interface(fn=image_classifier, inputs="image", outputs="label")
demo.launch()
```

#### FastAPI

```python
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
    return {"message": "Hello World"}
```

#### Flask

```python
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello_world():
    return "<p>Hello, World!</p>"
```

### Next steps: Workbench integration

To support Workbench, we'll need to 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`.
@testlabauto
Copy link
Contributor

Verified Fixed

Positron Version(s) : 2024.09.0-95
OS Version          : OSX

Test scenario(s)

Verified with FastAPI. Will cross check with other apps.

Link(s) to TestRail test cases run or created:

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants