posit-dev / posit-dev/py-shiny
Should have better error messages when running Shiny Express app as regular Python code
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.8k
- Forks
- 135
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 21
Description
For example, for this app:
from shiny.express import input, render, ui
ui.page_opts(title="App title")
"Hello"
If you run it as regular Python code, it emits this error message:
> python testapp.py
Traceback (most recent call last):
File "/Users/winston/Projects/py-shiny/_dev/express/testapp.py", line 3, in <module>
ui.page_opts(title="App title")
File "/Users/winston/Projects/py-shiny/shiny/express/ui/_page.py", line 59, in page_opts
cm = get_top_level_recall_context_manager()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/winston/Projects/py-shiny/shiny/express/_run.py", line 150, in get_top_level_recall_context_manager
return _top_level_recall_context_manager
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
NameError: name '_top_level_recall_context_manager' is not defined. Did you mean: 'get_top_level_recall_context_manager'?
That error message comes up because of the page_opts() function. However, another app which doesn't use that function might emit no information at all. For example:
from shiny.express import input, render, ui
ui.input_text("info", "Info", "Some info")
@render.text
def value():
return input.info()
If this app is run as regular Python code, it does nothing. I'm not sure what we can do about this case.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the two examples with python testapp.py, then inspect shiny/express/ui/_page.py and shiny/express/_run.py, especially the page_opts() and get_top_level_recall_context_manager() paths. Determine how both regular-Python execution cases can report a useful error, and add or update tests if the repository provides coverage for these paths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- developer-experience
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100