posit-dev / positron

Positron, a next-generation data science IDE
Other
2.56k stars 80 forks source link

App Frameworks on Workbench: Dash app involves extra step to delete .env file #5028

Open sharon-wang opened 4 days ago

sharon-wang commented 4 days ago

System details:

Positron and OS details:

Latest on main.

Interpreter details:

Any supported Python. I've used 3.12 and 3.10.

Describe the issue:

When running a Dash app in Positron on Workbench, the Workbench extension creates a .env file as part of its Dash app handling. The .env file sets a variable which conflicts with Positron's Dash app handling env vars, resulting in an error in the Terminal when the Dash app is run. Deleting the .env and running the app again gets past the issue.

The Workbench extension will be updated to skip its custom handling when running in Positron: https://github.com/rstudio/rstudio-workbench-vscode-ext/issues/262.

This issue is a reminder for us to test Dash apps in Positron on Workbench once https://github.com/rstudio/rstudio-workbench-vscode-ext/issues/262 is complete.

Steps to reproduce the issue:

  1. Run this app in Positron on Workbench
  2. Error in the Terminal where the app was run
  3. Look for a .env file that was created by the Workbench Extension (probably at the root of the folder you currently have open in Positron)
  4. Delete the .env file
  5. Run the app again
  6. No issues!

Expected or desired behavior:

Dash apps should work in Positron on Workbench, running and displaying successfully in the Viewer, without having to delete the .env file / or the .env should not be generated when a Dash app is run in Positron on Workbench.

Were there any error messages in the UI, Output panel, or Developer Tools console?

Terminal error

$     ~/qa-
example-content/.venv/bin/python /opt/sharondev/qa-example-content/workspaces/python_apps/dash_example/dash_example.py
Traceback (most recent call last):
  File "/opt/sharondev/qa-example-content/workspaces/python_apps/dash_example/dash_example.py", line 2, in <module>
    app = Dash()
          ^^^^^^
  File "/opt/sharondev/qa-example-content/.venv/lib/python3.12/site-packages/dash/dash.py", line 443, in __init__
    base_prefix, routes_prefix, requests_prefix = pathname_configs(
                                                  ^^^^^^^^^^^^^^^^^
  File "/opt/sharondev/qa-example-content/.venv/lib/python3.12/site-packages/dash/_configs.py", line 85, in pathname_configs
    raise exceptions.InvalidConfig(
dash.exceptions.InvalidConfig: You supplied `url_base_pathname` and `requests_pathname_prefix`. This is ambiguous.
To fix this, set `routes_pathname_prefix` instead of `url_base_pathname`.

Note that `requests_pathname_prefix` is the prefix for the AJAX calls that
originate from the client (the web browser) and `routes_pathname_prefix` is
the prefix for the API routes on the backend (this flask server).
`url_base_pathname` will set `requests_pathname_prefix` and
`routes_pathname_prefix` to the same value.
If you need these to be different values then you should set

Related things

jmcphers commented 4 days ago

Tracking work in https://github.com/rstudio/rstudio-workbench-vscode-ext/issues/262; we'll verify this on the Positron side when complete.

sharon-wang commented 2 days ago

Workbench changes now available in https://dailies.rstudio.com/version/2024.11.0-daily+299.pro3/!