-
Notifications
You must be signed in to change notification settings - Fork 83
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
@expressify
puts shinylive into a strange state
#1042
Comments
I also found that if you load the app, then change the function name to
|
Appears |
This has to do with the python stdlib module
We look in the linecache for source code instead of on disk, for performance reasons but also because there was some mode I was running in where the source .py file was being generated as a temp file and somehow deleted before these decorators had a chance to run. We might just need shinylive to call |
There's also a |
I think we can use |
I think you’ll have the same problem without special evaluation, if the app.py loads another .py that uses those decorators? Maybe linecache.checkcache() (with no args) when the run button is pushed? |
clearcache-half.mp4 |
It doesn’t explain what you’re seeing, I don’t think, but we do also have our own cache here: https://github.com/posit-dev/py-shiny/blob/main/shiny/express/expressify_decorator/_expressify.py#L33 |
Yes, it looks like the This is where it checks if the bytecode object py-shiny/shiny/express/expressify_decorator/_expressify.py Lines 99 to 100 in 64d8036
Here's a minimal reprex. import contextlib
def card():
with contextlib.nullcontext():
"This is text"
print(card)
print(card.__code__.__hash__())
def card():
with contextlib.nullcontext():
"This is other text"
print(card)
print(card.__code__.__hash__()) If I run this in my normal Python in a terminal, I get the following output:
This is what I would expect. However, if I run it in Pyodide (via Shinylive), this is what it looks like:
In Pyodide, both of the Shinylive using Pyodide 0.22.1. I also tested that code in their web console at https://pyodide.org/en/0.22.1/console.html and was able to reproduce the problem there as well. However, when I tried a newer version, like https://pyodide.org/en/0.23.0/console.html, the hashes are different. So it might have been fixed in that version. |
In the dev version of Shinylive,
@expressify
puts it in a strange state where it doesn't seem to recognize changes to the function body.For example, with this app, if you change the body of the
card
function and restart the app, the card doesn't change.Live example
expressify-shinylive-half.mp4
Although the problem is happening in Shinylive, I think that's probably just a symptom of a deeper issue that's in the implementation of
expressify
.The text was updated successfully, but these errors were encountered: